Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

reading text from an event

Aran

Member

hey, how do you get a script to read a parameter value that is set in an event and is a sentence in quotations (not a quoted statement ;P, btw)?

like in the event it initializes a script and the initialize method has a parameter and in the event, it initializes that script with a quoted phrase, ex:
"blah blah blah"

ex:
Event:
Code:
@>[COLOR=silver]Script: Scene_Something.new("Can you do this?")[/COLOR][COLOR=black]
[/COLOR]

Script:
Code:
[COLOR=blue]class[/COLOR] Scene_Something
 
[COLOR=blue]def[/COLOR] initialize[COLOR=blue]([/COLOR]a_phrase[COLOR=blue])[/COLOR]
a_phrase [COLOR=blue]=[/COLOR] [COLOR=darkorchid]""[/COLOR]
[COLOR=green]#blah blah blah on down to end of script[/COLOR]
 
Code:
class Scene_Something
  attr_accessor :phrase
  def initialize(phrase = "")
    @phrase = phrase
  end
end

Code:
Call Script: something = Scene_Something.new("Hello World");
print something.phrase

Try that.
 

OS

Sponsor

If you put in the semicolon after something = Scene_Something.new(etc), take it out. I don't think the compiler is reading the code right becuase that ; is there. If I am right, yay! If I am wrong, sorry to waste your time, and Good Night. Peace out!

~Broken
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top