Help needed for Global Variables

Started by HeartHacker, Sat 07/06/2003 19:56:03

Previous topic - Next topic

HeartHacker

Hi everyone...
                 This is a simple problem but i cant get it through.I want to have a variable accessible by all room scripts in other words,throughout the game.But somehow i cant do it.And damn these Global Variables String...What Are They...........,,
   I know how to modify a variable but only this problem.Also what is the difference between STRING and INT???

Thankx for your corporation

evilspacefart

an INT is an integer, a number without decimals

SetGlobalInt(10,1);


a STRING is alphnumerical , like

SetGlobalString(1,"your mother");

you can only have 50 STRINGS, numbered 0 - 49



HeartHacker

Thankx for telling me the difference.But still i cant get through the problem.Can anyone tell me how to use a varibale accessible throughout the game.my variable is
int t_counter;
I want to use this throughout the game ie in different rooms.I can modify it from anywhere and access it from anywhere.So please anyone can help me.I read the tutorial but still i cant get through.
Thankx for ur corporation

miguel

In the global script after this line "function game_start() {"

SetGlobalInt(10,5);//global int10  has value 5

then you can call it in every room or change it's value in every room
Working on a RON game!!!!!

HeartHacker

Hey guyz...
     I tried ur script but still no luck.The problem is that i have 2 rooms.
When the player picks up an item from one room the variable(int t_counter) increases by 1
then when he places that item in another it further increases by 1.So a thing appears in the current room when the variable is 2.
I tried doing this by typing int t_counter; at the top of the main global script file.
Then i tried modifying it from different locations but it says undefined token.
I tried using Globalints but i dont know how to use them and also wht r they.Can anyone give me a good example.PLEASE!!!!.
Also one more thing.Do Globalints require a normal int to work.

Thankx....

Scummbuddy

You can not rename a global int, it just stays as a number.  Is that the problem?  Just increase a specified global int, then check it when in the other room.
- Oh great, I'm stuck in colonial times, tentacles are taking over the world, and now the toilets backing up.
- No, I mean it's really STUCK. Like adventure-game stuck.
-Hoagie from DOTT

HeartHacker

Thank you all guys for your help.I finally got this globalint thing.But I just want to ask that i know how to change its value but how to increase it.I tried doing:
SetGlobalInt(10) +=(1);
But it does not work.So plz if anyone can help me in how to increase or decrease a global variable

Thankx A Lot

Gilbert

SetGlobalInt(10,GetGlobalInt(10)+1);

Rainbow Guy

Hi, after reading this thread and the help file i found this :-

"SetGraphicalVariable

Example:

SetGraphicalVariable("climbed rock", 1);

will set the interaction editor "climbed rock" variable to 1."


so couldn't he/i used variables instead  ??? It would be allot easyer if i could give the Variables names instead of numbers.

( but i'm a little worried by the term "Graphical" what's that mean ??? )

Mr Jake

you can.
Putting:

#define saveselected 2

in the script header will name global int 2 'saveselected' so you can do

SetGlobalInt (saveselected, 1); and GetGlobalInt (saveselected) etc. etc.

Snarky

You don't need to use GlobalInts. You can define and export variables in the global script, and import them in the script header. That way they will be available everywhere in your code.

Rainbow Guy

Quote from: Hotspot on Sat 07/08/2004 11:03:29
you can Putting:
#define saveselected 2
in the script header will name global int 2 'saveselected' so you can do
SetGlobalInt (saveselected, 1); and GetGlobalInt (saveselected) etc. etc.

Thanks man, thats well worth knowing  ;D ;D ;D

Ashen

1. 'Graphical' variables refers to variables created using the interaction editor, rather than using scripting.

2. What Snarky said. Look up import and export in the manual for how to create global ints with useful names.
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk