Whats the first thing called by a loading game?

Whats the first thing called by a loading game?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Whats the first thing called by a loading game?

Post by Erik »

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?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Whats the first thing called by a loading game?

Post by knorke »

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.
a game variable (same value for everyone but random per game session)
Game.gameID
http://springrts.com/wiki/Lua_ConstGame
If possible i would even have loading screens based on that value.
Not possible, loadscreens are chosen by engine atm.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Whats the first thing called by a loading game?

Post by FLOZi »

which defines order in which wupgets are EXECUTED.
Fixed.

Also the Game table isn't accessible at defs loading stage
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Whats the first thing called by a loading game?

Post by knorke »

Also the Game table isn't accessible at defs loading stage
yea, i just remebered...

Well, what do you want to do? There might be another way.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Whats the first thing called by a loading game?

Post by Erik »

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)
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Whats the first thing called by a loading game?

Post by knorke »

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)
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

Re: Whats the first thing called by a loading game?

Post by Beherith »

Isnt this what the layer tag is for in the gadget.getinfo?
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: Whats the first thing called by a loading game?

Post by FLOZi »

except for the unitdefs themselves.
This is precisely how to do it. Stick a value in a junk unitdef during loading and it will be accessible everywhere.

Beherith: Layer controls execution order, not loading order.
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Whats the first thing called by a loading game?

Post by CarRepairer »

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)
1) Randomize the unit stats in unitdefspost.
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.
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Whats the first thing called by a loading game?

Post by Erik »

Image

Everything (excluding unitdefs post) working.
Post Reply

Return to “Game Development”