[GS] Storing / Retrieving data in lua

__jack__

Warlord
Joined
Dec 29, 2009
Messages
141
Hi,

probably one for @LeeS or @Gedemon

I need to call a number at the LoadScreen.lua stage.
The hard part is that this number is generated in game (UI side lua).
I tried to use GameConfiguration.SetValue() then GameConfiguration.GetValue() but they are erased.
Is there any container I can write / read into?

(objective: seed conservation over Network.RestartGame() in multiplayer context)
 
I would have expected GameConfiguration to keep a value on restart.

Try with ExposedMembers, I've used it at some point with YnAMP to get a function from the worldbuilder mode then go back to main menu and access it in game.

And so I'm also cleaning all the custom stuff I set to ExposedMembers when quitting a game (to main menu, restart or reload) to prevent issues with variable already set with the previous values.

Code:
ExposedMembers.MyValue = something
 
Code:
Game:GetProperty(PropertyTextName)
Game:SetProperty(PropertyTextName, PropertyValue)
See the lua for the Red Death Scenario

I have used it quite a bit in other mods - I will try stuff from the UI into Gameplay to then write it to SetProperty and then see if I can call it after a restart.
 
@LeeS @Gedemon

So it turn's out you can't solve this with Game:GetProperty() => this object is destroy when the game stops.

However you can use the GameConfiguration BUT you need to use Network.BroadcastGame() for them to get saved back to the frontend (otherwise it gets killed by SetupParametters)

The whole Network.RestartGame() is quite interesting as the game is coming back to Loadscreen.lua so by having a custom Loadscreen.lua you can manipulate the seed/other parametters pre-map/game generation without going into the lobby.

Unfortunately I haven't been able to make my other objective (loading a MP game without relobbying) succesfully: Network.Loadgame() can be used to launch a new MP game but unfortunately the other players in the MP game would not be able to follow into the new Session ID so that new MP game is only launched with AI...
 
well that's a booger. but then I've never tried to do anything specific for MP games.

but if you're starting what is essentially a new game every time there's a Network.RestartGame() dispatched then it makes sense because the data you applied to the Game and GameConfiguration objects no longer apply to the new game, they apply only to the previous game which was executing.

How does the pre-saved "Load Configuration" work in terms of MP? In Single Player you can save your game setup as a "configuration" and then reload it as often as desired, and one of the things that gets saved is the map seed value so that when you do this you tend to get the same map every time you start a new Single Player game with a previous "configuration" loaded as part of the setup process.
 
How does the pre-saved "Load Configuration" work in terms of MP? In Single Player you can save your game setup as a "configuration" and then reload it as often as desired, and one of the things that gets saved is the map seed value so that when you do this you tend to get the same map every time you start a new Single Player game with a previous "configuration" loaded as part of the setup process.

It is the weird part - some are kept (e.g. map size, number of slots) some are not (e.g. seeds)
 
Back
Top Bottom