Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

ZScript global variables: saved or not? (Need your input!)

6 replies · 1,562 views · Started 24 July 2007

This is the thread where this issue first came up.

http://www.armageddongames.net/forums//thread/98188/

The topic came up again recently.

http://www.armageddongames.net/forums//thread/98407/

So, my question is, does anyone know for sure what the original intention of global variables were? Should they persist (save) when a quest is saved/quit, or should they reset? Jman would be a good person to ask.

It's my personal opinion that they should persist, meaning this behavior is a bug. (Not a feature request.) However, my opinion is not the only one that matters. What say you?

I think that there should be some sort of method of persisting variables in save files. Be it global variables, or the Screen->D[] array, or a new Game->SaveVariable(name, val) method, or something.

I like the global variables idea, though.

Global variables in most programming languages (at least, all the ones I've heard of (that I can remember)) are saved all the way through a program. So by that line of reasoning, I don't see why they shouldn't save in ZC. :shrug:

...although I can understand the usefulness of one that resets upon loading a save. (Like, say, Link's life meter. Heh. 😛)

Maybe split them into 2 kinds of global variables? One type that saves, and one that doesn't? That'd solve all the arguments, I think...

Hypercrash wrote:...although I can understand the usefulness of one that resets upon loading a save. (Like, say, Link's life meter. Heh. 😛)

In this example, you'd use a global script. They execute when a game is started, be it initial or after a save. But I know what you mean.

From a script programming point of view, it's impossible to know when a player is going to save/quit, and in some of these instances, resetting a variable is going to break things. (A la dynamic HCP/HC.)

Although, I bet there would be instances where variables should in fact reset. For example, if you make a temporary change to one of Link's stats that should be in effect in only one room, then the player saves and quits. The changes might incorrectly permanently carry over.

I suppose there is a need for both flavors.

I did some further investigation with the code, and it seems that globals were always intended to be saved, and still are, but get reset because of a bug in the game script code. I've fixed this bug.

To be clear,

- game script 0 executes exactly once, when the quest is first started. ~Init gets placed in this slot by default.
- game script 1 executes every frame the game is playing.
- game script 2 executes every time gameplay in the quest restarts, whether it be due to F6, death, or starting the quest from scratch.

This'll be my last bug fix for a while; tomorrow I leave for San Diego for a week.

OHHHHH, is that what the Global scripts were for? Well, jeez, if we'd known that...

Thank you DD, this is a great day for ZScripters!