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.

HBGames

Hi,

So before the game starts, I've got the idea to make it say a few things in text boxes, I know the code is;

Code:
 

p "Blaa blaa."

 

However, I'm trying to make it only print while a switch is turned off, as I don't want it appearing everytime the player starts the game up, cause it'll get annoying, I only want it showing the first time.

I was hoping something simple like;

Code:
 

if $game_switches[1] == false

  p "Blaa blaa."

  else

end

 

I even tried adding an initialize (Don't ask why, I had no idea if it'd help or not, I'm still a rookie scripter, lol);

 

def initialize

  if $game_switches[1] == false

    p "Blaa blaa."

  else

  end

end

 

Would do the trick, however I seem to get an error;

Code:
 

Script "TestPopupText" line 1: NoMethodError occured.

 

undefined method `[]' for nil:NilClass

 

Now, I don't see how the [1] is an undefined method as it's obviously the switch.

Does anyone have any ideas as to what the problem could be ? Am I doing something COMPLETELY wrong here ?

Thanks.

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