I would want to ensure creating a game variable (same value for everyone but random per game session) before gadgets and unitdefs(post) load so i can use it there and rely on it being initialized already.
If possible i would even have loading screens based on that value.
Any suggestions?
Whats the first thing called by a loading game?
Moderator: Moderators
Re: Whats the first thing called by a loading game?
not sure what you mean..
in function gadget:GetInfo() you have the layer= <some number> thing, which defines order in which wupgets are loaded.
So you can one have load first, then the others all after that one.
http://springrts.com/wiki/Lua_ConstGame
in function gadget:GetInfo() you have the layer= <some number> thing, which defines order in which wupgets are loaded.
So you can one have load first, then the others all after that one.
Game.gameIDa game variable (same value for everyone but random per game session)
http://springrts.com/wiki/Lua_ConstGame
Not possible, loadscreens are chosen by engine atm.If possible i would even have loading screens based on that value.
Re: Whats the first thing called by a loading game?
Fixed.which defines order in which wupgets are EXECUTED.
Also the Game table isn't accessible at defs loading stage
Re: Whats the first thing called by a loading game?
yea, i just remebered...Also the Game table isn't accessible at defs loading stage
Well, what do you want to do? There might be another way.
Re: Whats the first thing called by a loading game?
I want to have a random (but same for everyone, also in replays) variable(like a special game mode) and based on that change stuff like
-unit stats(this game all tank have double HP, or now you can also build experimental unit xyz which is added to this units build list)
-enable certain gadgets(i.e. alternative victory condition)
-change the spawned units at game start.(like start with not only a headquarter but also some tanks this time)
ideally I would like to show the currently active "special feature/game mode" while the game loads or in a popup window at game start (like zk does for commander selection)
-unit stats(this game all tank have double HP, or now you can also build experimental unit xyz which is added to this units build list)
-enable certain gadgets(i.e. alternative victory condition)
-change the spawned units at game start.(like start with not only a headquarter but also some tanks this time)
ideally I would like to show the currently active "special feature/game mode" while the game loads or in a popup window at game start (like zk does for commander selection)
Re: Whats the first thing called by a loading game?
math.random() will do fine in synced part. (not sure if it needs to be seeded somehow)
hm.
it comes down to two things:
1) stuff you can do with normal gadgets:
eg en/disableing certain gadgets or spawning different startunits.
To some extend you can change attributes of units, eg there is Spring.SetUnitMaxHealth (needs some scripting since it is per unitID, but nothing impossible hard) so some things do not _post.
2) stuff you can only do in bla_post.lua:
eg changing the movement class of a unit.
I think there is no way to pass stuff from unitdef_post to ingame lua, except for the unitdefs themselves.
But imo forget about doing much dynamic stuff in _post and use gadgets for everything.
For the things listed you do not need _post, though editing buildlist is a bit tricky. (can not really edit the buildlist but only hide the buttons and block the unit creation)
hm.
it comes down to two things:
1) stuff you can do with normal gadgets:
eg en/disableing certain gadgets or spawning different startunits.
To some extend you can change attributes of units, eg there is Spring.SetUnitMaxHealth (needs some scripting since it is per unitID, but nothing impossible hard) so some things do not _post.
2) stuff you can only do in bla_post.lua:
eg changing the movement class of a unit.
I think there is no way to pass stuff from unitdef_post to ingame lua, except for the unitdefs themselves.
But imo forget about doing much dynamic stuff in _post and use gadgets for everything.
For the things listed you do not need _post, though editing buildlist is a bit tricky. (can not really edit the buildlist but only hide the buttons and block the unit creation)
Re: Whats the first thing called by a loading game?
Isnt this what the layer tag is for in the gadget.getinfo?
Re: Whats the first thing called by a loading game?
This is precisely how to do it. Stick a value in a junk unitdef during loading and it will be accessible everywhere.except for the unitdefs themselves.
Beherith: Layer controls execution order, not loading order.
- CarRepairer
- Cursed Zero-K Developer
- Posts: 3359
- Joined: 07 Nov 2007, 21:48
Re: Whats the first thing called by a loading game?
1) Randomize the unit stats in unitdefspost.Erik wrote:I want to have a random (but same for everyone, also in replays) variable(like a special game mode) and based on that change stuff like
-unit stats(this game all tank have double HP, or now you can also build experimental unit xyz which is added to this units build list)
-enable certain gadgets(i.e. alternative victory condition)
-change the spawned units at game start.(like start with not only a headquarter but also some tanks this time)
ideally I would like to show the currently active "special feature/game mode" while the game loads or in a popup window at game start (like zk does for commander selection)
2) Make a central gadget with low layer that controls victory conditions. Use setgamrulesparam in it and other gadgets will function by checking getgamerulesparam.
3) This gadet will also check unitdefs to see what happened in step 1.
4) It can spawn start units as you please.
5) Make a widget that reads getgamerulesparam and displays a window of information.
Re: Whats the first thing called by a loading game?
Everything (excluding unitdefs post) working.