How do I use global variables in room scripts? (SOLVED)

Started by Dan_N, Sun 24/12/2006 15:01:58

Previous topic - Next topic

Dan_N

Hello.

From the "Possibly Stupid Questions asked by Dan" series, we bring you the "How do I use global variables in room scripts?" episode.

Right, so, I've declared a global variable and want to use it in a room script for a hotspot. But when I type up the script, it doesn't recognize it. How do I do it then? Someone, please help me.

Oh, and if it helps, here's how I declared the global variable: I made a conditional action (if variable is set to a certain value) in the interaction window for the hotspot and then edited the variables and added my global one.

I would really like a fast answer to this, 'cos my project depends on this.

Thanks in advance, you lovely person who have taken time out of your life to answer me.

SSH

For each global script variable:

put "export varname;" at the end of the global script
put "import int varname;" in the script header

Or... use the DeNGVaT module and just type Global.Set("myvar") and Global.Get("myvar")...
12

Gilbert

Or better, use the conventional way of exporting the variable after declaring it and then importing back in that room's script (or in the script header if you want it to be used in all the rooms' scripts).

Edit: Alright, SSH edited his post before me, so it might look a bit odd.

Dan_N

Wow, that was quite fast. Thanks SSH and Gilbot, I now continue working on Update Quest.

SMF spam blocked by CleanTalk