Jump to content
Sign in to follow this  
Mudkip

Instrument Script (patly completed)

Recommended Posts

I tried to make a script for clarinet (the only instrument I have in my house, I was bored) using MephistoX's Ocarina Script as a skeleton that basically is very simple (more advanced= more room for mistakes in my God-awful lack of coding knowledge) ; you hit a key and a note is played, nothing further.  It just isn't working and I'm incredibly awful at coding; can someone tell me what I did wrong/just make a new non-awful one?  Thinking about making a piano one too...

 

 

 

## Basic Clarinet Script!This is not the script I originally posted, I've been 
## updating it
module Game_Instrumentt
  #--------------------------------------------------------------------------
  # * KeyNotes : The Input button and the assigned note
  #     - Keynotes = {Button => Note, ...} both as symbols
  #--------------------------------------------------------------------------
  KeyNotes = {"1" => :A, "2" => :B, "3" => :C, "4" => , "5" => :E,
              "6" => :F, "7" => :G, "8" => :H, "9" => :I, "0" => :J,
              :Q => :K, :W => :L, :E => :M, :R => :N, :T => , :Y => ,
              :U => :Q, :I => :R,  => :S,  => :T, :A => :U, :S => :V,
               => :W, :F => :X, :G => :Y, :H => :Z, :J => :Z, :K => "1",
              :L => "2", :Z => "3", :X => "4", :C => "5", :V => "6",
              :B => "7"                                                   }
  #--------------------------------------------------------------------------
  # * Notes : Parameters for the different playable Notes
  #     Notes = {NoteSymbol => [sE]}
  #       - Note Symbol => The Note Symbol defined at KeyNotes
  #       - SE => Sound Effect when playing a note
  #--------------------------------------------------------------------------
  Notes = {:A => ['Note1'],
           :B => ['Note2'],
           :C => ['Note3'],
            => ['Note4'],
           :E => ['Note5'],         
           :F => ['Note6'],
           :G => ['Note7'],
           :H => ['Note8'],
           :I => ['Note9'],
           :J => ['Note10'],
           :K => ['Note11'],
           :L => ['Note12'],
           :M => ['Note13'],
           :N => ['Note14'],
            => ['Note15'],
            => ['Note16'],
           :Q => ['Note17'],
           :R => ['Note18'],
           :S => ['Note19'],
           :T => ['Note20'],
           :U => ['Note21'],
           :V => ['Note22'],
           :W => ['Note23'],
           :X => ['Note24'],
           :Y => ['Note25'],
           :Z => ['Note26'],
           "1" => ['Note27'],
           "2" => ['Note28'],
           "3" => ['Note29'],
           "4" => ['Note30'],
           "5" => ['Note31'],
           "6" => ['Note32'],
           "7" => ['Note33']           }
end
#--------------------------------------------------------------------------
class Scene_Instrumentt < Scene_MenuBase
  #--------------------------------------------------------------------------
  # * Mixin Game_Instrumentt
  #--------------------------------------------------------------------------
  include Game_Instrumentt  
#--------------------------------------------------------------------------
  # * Start
  #--------------------------------------------------------------------------
  def start
    # Set BGM to last
    BattleManager.save_bgm_and_bgs
    # FadeOut Music
    fadeout_all(0)
    # SuperClass Method
    super
    end
end



















 

 

 

Thanks a lot!  I don't know what I'm doing!

P. S. I know I made a typo in the title I meant partly, whoops!

Edited by Mudkip

Share this post


Link to post
Share on other sites

I can see one problem right away and that is that you are using integer symbols as keys in the hash. A symbol cannot start with an integer and that's why you get the syntax error. Let me try and explain symbols real quick. A symbol is almost like a string, and a string is a sequence of characters. You write strings in double or single quotes in Ruby and symbols start with a colon.

"string"
:symbol
 

for now just think of a symbol as a string but you are only interested in it's name. For example, when using the symbol :symbol we only ever care about the symbol's value (it's name), and we will never add characters to the symbol, change lowercase to uppercase, look at individual characters and so on, all which you can do with a string.

 

So back to your code. You have this

 {:1 => :A}
 

which is not legal because a symbol cannot start with a number, it must start with a letter. So to fix this you could do this:

 

{:s1 => :A}
 

or this

{"1" => :A}
 

in the former snippet I added a letter to the start of the symbol making it legal. In the latter I change the symbol to a string and strings are allowed to start with anything so "1" is a perfectly legal string.

 

That should fix the first error but there has to be more to the script because what you posted will not do much of anything by itself.

Edited by kal

Share this post


Link to post
Share on other sites

That's working fine now, BUT when I tried to start my game it said

"Script 'Basic Clarinet Script' Line 69:Syntaxerror occured

unexpected $end, expecting keyword_end

end"

BTW Line 69 is just the last line on it, for some reason this website puts a blank line between everything in the code

Also this script will not do anything on its own, which is why there is an item that upon use calls up a common event

Share this post


Link to post
Share on other sites

When it says expecting keyword_end it means you have missed an end somewhere. Every class, module, method, block etc should have an end to indicate where it ends. It looks like the class Scene_Instrument is missing it's end keyword. 

Share this post


Link to post
Share on other sites

I had already tried that, but assumed it wasn't the problem because when I had put a end in there, it said almost the same thing,

 

"Script 'Basic Clarinet Script' Line 70:Syntaxerror occured

unexpected $end, expecting keyword_end"

 

I'm so sorry for being so annoying, it's just not working even with the end...  Thanks for your help!

Share this post


Link to post
Share on other sites

The script in your first post is missing two "end"s. There should be one at the end of your module Game_Instrument2 (before class Scene_Instrumentt < Scene_MenuBase) and one at the end of class Scene_Instrumentt.

Share this post


Link to post
Share on other sites

That was a typo of sorts, I didn't want to mess anything up with numbers just in case but I missed changing some of the instrument2 lines to instrumentt lines...

Regardless that worked and I am able to atleast start the game without it crashing.  When I try to play it and hit the keys, nothing happens even though I've imported the recordings of notes into Audio SE, and they are named the corresponding names I mentioned in the script...?

Edited by Mudkip

Share this post


Link to post
Share on other sites

The script, as it is in your first post, doesn't really do anything yet. You aren't checking for input or playing a sound effect, for example. Your script currently just defines two variables and creates a new scene. Also, you would need a full keyboard input script in order for you to use all those keys for input. You can use the one linked in this thread.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted