Messages & Script Variables

Error message

Deprecated function: implode(): Passing glue string after array is deprecated. Swap the parameters in drupal_get_feeds() (line 394 of /var/www/pied-piper.ermarian.net/includes/common.inc).
AuthorTopic: Messages & Script Variables
Warrior
Member # 1505
Profile #0
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?

[ Friday, March 19, 2004 18:59: Message edited by: Newtfeet ]

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Triad Mage
Member # 7
Profile Homepage #1
I believe the first part is correct.

As for the variables, I think that they are temporary for the run of the script, and they can't be used in any other thing because of their limited scope, which is one reason to use SDFs for everything you want to carry important data.

--------------------
"At times discretion should be thrown aside, and with the foolish we should play the fool." - Menander
====
Drakefyre's Demesne - Happy Happy Joy Joy
Encyclopedia Ermariana - Trapped in the Closet
====
You can take my Mac when you pry my cold, dead fingers off the mouse!
Posts: 9436 | Registered: Wednesday, September 19 2001 07:00
Warrior
Member # 1505
Profile #2
So, I can only count on variables staying the same in a single state (and any other states I call in that state)?

--------------------
-Newtfeet
Posts: 151 | Registered: Saturday, July 13 2002 07:00
Triad Mage
Member # 7
Profile Homepage #3
Yes, AFAIK.

--------------------
"At times discretion should be thrown aside, and with the foolish we should play the fool." - Menander
====
Drakefyre's Demesne - Happy Happy Joy Joy
Encyclopedia Ermariana - Trapped in the Closet
====
You can take my Mac when you pry my cold, dead fingers off the mouse!
Posts: 9436 | Registered: Wednesday, September 19 2001 07:00
Board Administrator
Member # 1
Profile Homepage #4
"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.

--------------------
Official Board Admin
spidweb@spiderwebsoftware.com
Posts: 960 | Registered: Tuesday, September 18 2001 07:00