Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: Global variables  (Read 2736 times)

0 Members and 1 Guest are viewing this topic.

Slavon

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Global variables
« on: May 26, 2005, 08:34:18 PM »

First of all, Hi, I'm a newbie, I discover and use Wintermute since a few days... I programmed in some other platforms, but I don't know a lot about scripting language. I began to program a game in WME with the help of the documentation included, everything OK, but right now I have a problem:

It's the typical situation of the box that can be opened and closed, so it requires a true/false variable to determine if the main character can open or close it. Very simple, In "scene_init.script" I put something like this:


global Stateroom;

if(Stateroom==null)
{
  Stateroom.Visited = false;
  Stateroom.BoxOpen = false;
}



Everithing OK, it isn't? Well, but then, in any other .script file, I can't use "Stateroom.BoxOpen" anymore. It's just like I didn't declare it.

The log says: "Variable Stateroom is referenced but not defined". I don't understand this, I use just the same structure than in the demo, but in my game, It doesn't work.

Sorry, I know that probably it'll be a stupid newbie question, but I don't know what to do. Please, some help!
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Global variables
« Reply #1 on: May 27, 2005, 07:12:22 AM »

Hi and welcome to the forum,

you have to declare the global variable in every script where you're going to use it. They will share the same value, but they need to be declared.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Slavon

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 2
    • View Profile
Re: Global variables
« Reply #2 on: May 29, 2005, 01:32:33 AM »

Thanks a lot, I knew that It'd be nothing... I'll lurk the forum again to keep on learning  ;)
Logged
 

Page created in 0.039 seconds with 20 queries.