View topic - Whats the first thing called by a loading game?



All times are UTC + 1 hour


Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: 03 Apr 2012, 19:16 
User avatar

Joined: 20 Aug 2009, 19:49
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?


Top
 Offline Profile  
 
PostPosted: 06 Apr 2012, 09:33 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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.
Quote:
a game variable (same value for everyone but random per game session)
Game.gameID
http://springrts.com/wiki/Lua_ConstGame

Quote:
If possible i would even have loading screens based on that value.
Not possible, loadscreens are chosen by engine atm.


Top
 Offline Profile  
 
PostPosted: 06 Apr 2012, 13:45 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Quote:
which defines order in which wupgets are EXECUTED.


Fixed.

Also the Game table isn't accessible at defs loading stage


Top
 Offline Profile  
 
PostPosted: 06 Apr 2012, 13:57 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
Quote:
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.


Top
 Offline Profile  
 
PostPosted: 06 Apr 2012, 20:27 
User avatar

Joined: 20 Aug 2009, 19:49
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)


Top
 Offline Profile  
 
PostPosted: 07 Apr 2012, 01:46 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
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)


Top
 Offline Profile  
 
PostPosted: 07 Apr 2012, 02:17 
Moderator
User avatar

Joined: 26 Oct 2007, 15:21
Isnt this what the layer tag is for in the gadget.getinfo?


Top
 Offline Profile  
 
PostPosted: 07 Apr 2012, 11:15 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Quote:
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.


Top
 Offline Profile  
 
PostPosted: 09 Apr 2012, 06:53 
Cursed Zero-K Developer
User avatar

Joined: 07 Nov 2007, 21:48
Location: Horse
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.


Top
 Offline Profile  
 
PostPosted: 09 Apr 2012, 10:25 
User avatar

Joined: 20 Aug 2009, 19:49
Image

Everything (excluding unitdefs post) working.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.