storing single save data for continual use query

Freeform discussion about anything related to modding Transcendence.
Post Reply
Militia Captain
Militia Captain
Posts: 860
Joined: Tue Nov 05, 2013 9:56 am

In a couple of mods I have lists of info which are referred to continually but only need to be set once.

This is one such example from a VOTG GodShip mod I'm working on.

Code: Select all

	(eq rank -1)
		(block Nil
			(setq currentRank "Outcast")
			(scrEnableAction gScreen 'actionRemOutcast Nil)
			(setq remoraStats "Level -1: XP 0: color none")

	(eq rank Nil)
		(block Nil
			(setq currentRank "No one")
			(scrEnableAction gScreen 'actionRemNoone Nil)
			(setq remoraStats "Level Nil: XP 0: color gray")

	(eq rank 1)
		(block Nil
			(setq currentRank "Alien")
			(scrEnableAction gScreen 'actionRemAlien Nil)
			(setq remoraStats "Level 1: XP 300: color brown")

	(eq rank 2)
		(block Nil
			(setq currentRank "Newcomer")
			(scrEnableAction gScreen 'actionRemNewcomer Nil)
			(setq remoraStats "Level 2: XP 600: color yellow")
This happens in <OnPaneInit> for use in the screen description but I think it would be better to save the rank, level, XP, and color data separately and refer to it from there.

But I'm not sure of the best way to do this. Up to now I have done this sort of thing in <OnScreenInit> but that recreates the data again and again on every screen entry unneccesarily as the data never changes. I have sometimes used <OnGlobalPlayerEnteredSystem> and added a qualifier to stop the code rerunning anywhere except at game start in the starting system but still feel this isn't the best way to do this sort of data storage.
I am thinking a struct would be better but am not sure where to put it. <OnGlobalUniverseCreated> is one option maybe? But possibly somewhere in the game would be better so that loading time isn't increased (not that it would increase much).

Anyone got any ideas?
Last edited by relanat on Wed Jun 19, 2019 5:48 am, edited 1 time in total.
Stupid code. Do what I want, not what I typed in!
User avatar
Fleet Officer
Fleet Officer
Posts: 1162
Joined: Thu Aug 29, 2013 5:18 am
Location: On the other side of the screen.

 Putting it in <OnScreenInit> isn’t a terrible thing, per se — the amount of time it adds doesn’t even deserve to be called negligible — but for a one-and-done snippet of code you just need run when the playership is created, <OnGlobalUniverseCreated> is probably going to be your best option. It’s where I put most of my starting playership-specific code.

Mod prefixes: 0xA010 (registered) and 0xDCC8 (miscellaneous)

My mods on Xelerus: Click here!

Of all the things I’ve lost in life, I miss my mind the least. (I’m having a lot more fun without it!)
Militia Captain
Militia Captain
Posts: 562
Joined: Tue Mar 05, 2013 8:26 am

If there's a limited number of fixed values for the data, you could also store it in a list or struct in a type's StaticData.
Post Reply