Jump to content

GLOBAL and LOCALS variables


Guest korean

Recommended Posts

I have had many problem about this variable type LOCALS/GLOBAL..

So i need to be well-known...

 

I have 5 questions.

 

1. What is a restriction for us to use the character length of LOCALS/GLOBAL variables? 8, 16, 24 or more?

 

2. I found by shadow keeper that PC characters have their own LOCAL variables.

LOCAL variables in a script are stored in the individual character data?

 

3. First process in a script make the LOCALS/GLOBAL variables always set to 0 before any variation has not been?

 

4. Can a area/trigger script have LOCAL variables?

 

5. LOCAL variables always cannot be shared among scripts?

 

thanks anytime!

Link to comment
1. What is a restriction for us to use the character length of LOCALS/GLOBAL variables? 8, 16, 24 or more?
I believe the limit is 32 characters, but shorter is better. It might even be a good idea to limit it to 18.

 

2. I found by shadow keeper that PC characters have their own LOCAL variables.

LOCAL variables in a script are stored in the individual character data?

That is correct.

 

3. First process in a script make the LOCALS/GLOBAL variables always set to 0 before any variation has not been?
The default value of any variable, before it is set, is 0. If you check it in game using the console, it will show "does not exist." If you check it using Shadowkeeper, you will not see it on the variable list. If you deliberately set a variable to 0, it will appear as 0 using the console or SK. Note that using Global("variable","GLOBAL",0) as a trigger in script serves a different purpose, as well. If you go on to set it to 1, you prevent that block from looping, or firing more than once.

 

4. Can a area/trigger script have LOCAL variables?
Area scripts can only have global variables. Creature scripts can use either global or local variables.

 

5. LOCAL variables always cannot be shared among scripts?
This is completely true. If I SetGlobal("variable","LOCALS",1) in Anomen's script, I cannot check it in Jaheira's. If I used a global variable instead, I could.
Link to comment
4. Can a area/trigger script have LOCAL variables?
Area scripts can only have global variables. Creature scripts can use either global or local variables.

Don't forget area variables. :(

 

5. LOCAL variables always cannot be shared among scripts?
This is completely true. If I SetGlobal("variable","LOCALS",1) in Anomen's script, I cannot check it in Jaheira's. If I used a global variable instead, I could.

Just to be picky--they can be shared between scripts, but they're still limited to one creature. Every creature can have five scripts and a dialogue file, and those six resources can all check and use the same set of LOCALS variables.

 

But yes, you can not check them from creature to creature, as berelinde's example shows.

Link to comment
Aren't area variables global variables specific to that area? Like setting an area variable after an NPC talks to Crazy Celvan to keep it from happening again? It's only going to happen in the Docks, so setting an area variable works.

That's it, more or less. The technical difference is where they get saved--global variables get stored in baldur.gam, whereas area variables get stored in baldur.sav in the area files themselves.

 

One more nitpick: IIRC you can access area variables from any active area. So variables from a master area would still be active if you were in a sub area (i.e. Slums ar0400 vars are still available while inside the Copper Coronet).

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...