- Joined
- Jan 26, 2014
- Messages
- 1,281
- Reaction score
- 106
- First Language
- Irish
- Primarily Uses
- N/A
I came across a weird thing about hashes.
here's my code:
module RPGMakerWeb Message_If_Actor = { 1 => "Attack", 128 => "Attack 128!" }endclass Window_BattleLog < Window_Selectable #-------------------------------------------------------------------------- # * Display Skill/Item Use #-------------------------------------------------------------------------- def display_use_item(subject, item) if item.is_a?(RPG::Skill) add_text(subject.name + RPGMakerWeb.values[item.id]) unless item.message2.empty? wait add_text(item.message2) end else add_text(sprintf(Vocab::UseItem, subject.name, item.name)) end endendso apparently, I want the subject to say for example: "Eric: Attack 128"! if I use skill 128. As you can see on my hash I have 128 key. But whenever I execute the script, somehow the hash doesn't recognize 128 as a key and so it won't display the value of key 128. It says can't convert String to nil.
Also, if possible, is there a way to make the subject talk different words depending on if they're actors or not?
here's my code:
module RPGMakerWeb Message_If_Actor = { 1 => "Attack", 128 => "Attack 128!" }endclass Window_BattleLog < Window_Selectable #-------------------------------------------------------------------------- # * Display Skill/Item Use #-------------------------------------------------------------------------- def display_use_item(subject, item) if item.is_a?(RPG::Skill) add_text(subject.name + RPGMakerWeb.values[item.id]) unless item.message2.empty? wait add_text(item.message2) end else add_text(sprintf(Vocab::UseItem, subject.name, item.name)) end endendso apparently, I want the subject to say for example: "Eric: Attack 128"! if I use skill 128. As you can see on my hash I have 128 key. But whenever I execute the script, somehow the hash doesn't recognize 128 as a key and so it won't display the value of key 128. It says can't convert String to nil.
Also, if possible, is there a way to make the subject talk different words depending on if they're actors or not?
