How static are globals?

Freeform discussion about anything related to modding Transcendence.
Post Reply
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

Code: Select all

	<Globals>
	(block Nil
		(setq gPirateBarXP 0)
		(setq gPirateStationXP 0)
		(setq gPirateBarRank 0)
		(setq gPirateStationRank 0)
		(setq gPirateStationFailure 0)		
	)
	</Globals>
If I set these globals change them in-game, save, start a new game, and continue to play, the globals seem to retain their values. Does this mean that if I do this when I am a flt. Captain, I can start a new game and still be a flt. Captain? Is this a bug, or a I missing something.

Under what circumstances are globals reset?
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

You should not rely on the value of any global across sessions. You should only store data by using the appropriate functions to store data in objects or static classes.

Today, globals are reset when you exit the program (but don't rely on that behavior).
User avatar
Betelgeuse
Fleet Officer
Fleet Officer
Posts: 1920
Joined: Sun Mar 05, 2006 6:31 am

then can we have globals that are saved across games? (I know you can put them on the player ship now but that will change in the future)
Crying is not a proper retort!
F50
Fleet Officer
Fleet Officer
Posts: 1004
Joined: Sat Mar 11, 2006 5:25 pm

george moromisato wrote:You should not rely on the value of any global across sessions. You should only store data by using the appropriate functions to store data in objects or static classes.
Indeed.
Today, globals are reset when you exit the program (but don't rely on that behavior).
If globals are only reset when you exit the program, this opens up some nasty bugs (as I have discovered in my Pirate mod). Early missions become a problem as an early death will always result in my re-starting the game without exiting. This will result in the rank from Korolov (I believe), among others, being saved. This means that you could start the game with harder missions than usual, this means less money from that source or, if you happen to be blacklisted (which is how I discovered this in my mod), part of the game being blocked (and no money from that source).
Post Reply