Jump to content

Messages & Script Variables


Newtfeet

Recommended Posts

When a creature/terrain script recieves a message, this is what happens, right?

 

The creature/terrain script receiving the message is called as usual in the normal sequence (with my_current_message = -1), then:

 

The same script is called (at the same state), only my_current_message is now the value of the message.

 

In other words, if my_current_message <> 0, I can be sure this is the second time this script has been called this turn (unless the script is on a 8-turn cycle).

 

Is that correct? Also, how do short variables in a script act? Do their values persist through one run of the script, until the script is reloaded, through the entire scenario, or what? What can I expect when using them?

Link to comment
Share on other sites

"In other words, if my_current_message <> 0, I can be sure this is the second time this script has been called this turn (unless the script is on a 8-turn cycle)."

 

Not necessarily. There are a number of things that can cause a script to be called in a turn. A ritual of sanctification, or someone walking on it, or its blocking someone's movement can cause it to be called. Also, in a combat turn, scripts are called every time someone moves (so if someone moves 5 spaces, the terrain scripts are called 5 times).

 

Your scripts need to be robust enough to work properly no matter how many times in a turn they are called.

 

"So, I can only count on variables staying the same in a single state (and any other states I call in that state)?"

 

A variable in a script is only visible in that script, but anywhere in that script. (So it can be accessed in multiple states.)

 

When the script is unloaded (for example, a town script when you leave that town), that variable's value is forgotten.

 

Any value you want the game to remember should be stored in a Stuff Done Flag.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...