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.

Confusion on a couple of matters.

Hi, I am confused on setting properties for global variables, your supposed to be able to pull information from them even if there are in another class, but whenever I create a global variable and call it in another class and lets say I want to print the value of it(value == "text"), all I get is "nil"? Am I doing this wrong?

Also, can anyone tell me the command for putting text on a message box in game in script format (like how to call one up and put text in it.)

~ Thanks, Germen
 
just a thought, is your script something like this?
Code:
value == "text"
p value
Because I think it should be one of 2 ways:
Code:
value = "text"
p value
or
Code:
$value = "text"
p $value
 
No, I shouldn't of put the two == in this topic, you see $value = "text" but I want to be able to use its value in another class.

Here is a small example:
Code:
class Say_Something
  attr_reader :justatest
  def intialize
    $justatest = "no"
  end
end

class Something
  def initialize
    print $justatest
  end
end

(when printed, ("nil"))
 
you made a spelling error, change def intialize to def initialize

or just use this:
Code:
class Say_Something
  attr_accessor :justatest
  def initialize
    @justatest = "no"
  end
end

class Something
  def initialize
    @say_something = Say_Something.new()
    print @say_something.justatest
  end
end

Something.new()
 
nevermind i found out wat i was looking for, it was:

$game_temp.message_text = "Text"

my only problem with that is it just doesnt go away, i click enter and it just renews itself *sigh*
 

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