Page 1 of 7

SaveGame v. 0.6

Posted: 22 Jan 2010, 21:01
by Argh
Image

What does this do? It allows people to save and load their game states.

Alpha Code. Definitely a "work in progress", but it works well enough to test.

Include in your projects to test via include (it's a "mod"), or manually add the code to your project (not recommended until we're all reasonably certain it's bug-free, and it still will want the SAVEGAME.sdd folder to write to, unless we all decide we'd like something else).

Must have Spring 0.81+ installed to test this.

Records Unit, Feature, Resource, Map states. Now records all Unit Command states, including such things as Guard.

Will record GG in its entirety to record gamestate data for Lua game designs and Lua AIs. Has a fairly pretty UI; supports 10 savegame states, will tell you details about savegames you've saved.

Oh, and.... HIT the "~ / `" key to activate, for now (sorry for not posting that right away, and yeah that's all open to discussion).

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 21:08
by Gota
You need to start a game to load other games?
Is this applicable to multiplayer sessions?

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 21:11
by very_bad_soldier
You did that window really well, sir. Looks AAA no doubt.

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 21:14
by Argh
Meh, it's just something so that it's not ugly. Anybody could reskin it very easily, btw, it's fairly flexible.
You need to start a game to load other games?
Well, kinda. For P.U.R.E., I intend to ship it with all 10 savegames filled, let people use this feature directly from AppLauncher and from the Linux frontend (another project).
Is this applicable to multiplayer sessions?
That's a really interesting question. If multiplayer games use a host IP, etc., and everybody uses the EXACT SAME savegame... IDK, it might be possible that that startscript will result in everybody being back in the same game state. That's not a question I can answer though, IDK how that part of sync works. In theory, everybody'd log back in to the host, the script would roll, and everybody would have the same game-state...

So, maybe include the module with a special build of SA, test it out. Mainly I think that, once we're sure it's as un-buggy as it's going to get, I'll try and convince Lobby folks to support the format. But we'll see about all of that when it's all working as well as it can.

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 21:22
by Gota
Suggestion:restart.
As i was thinking about making some single player missions i quickly realized restart would be very important.

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 21:24
by Argh
It uses restart, lol.

Download it, install it, try it out.

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 21:51
by zwzsg
Gota wrote:Suggestion:restart.
As i was thinking about making some single player missions i quickly realized restart would be very important.
I have a restart button in my system! :P



Argh: Gota does not mean "Use Spring.Restart to load a game"
He means "make a button that start over a game with the same initial conditions"
Or so I understood.

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 21:56
by AF
omg your fighting against posting screenshots of worldbuilder yet you took one anyway to show off the savegame gadgets and then continued to fight?!

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 22:01
by Argh
He means "make a button that start over a game with the same initial conditions"
Hit "save" at whatever point you want... hit "load" to restart. Just like any commercial product.

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 22:02
by Gota
commercial products have a dedicated restart button per mission.

Re: SaveGame v. 0.1

Posted: 22 Jan 2010, 22:05
by Argh
Yeah, but it usually reloads the entire game state, which is what this does.

I could make a generic "restart" that would auto-save with just the start-script and a blank savegame, I suppose, to take the place of slot 10, use a special button, etc.

But it would still have to restart the engine; I don't want to have poor end-users waiting to restore the map, when it's faster to just reload, and that wouldn't be kosher with GameFrame() dependent states in missions, etc.

I'm not going to build you a generic mission frontend- if you want one, zwswg's is pretty good and very easy to install.

Anyhow, doing a restart feature's straightforward; I'll get that done and post a new version... after you've downloaded and tested it.

Here's a little incentive; it took longer to make the bitmap than to make the code.

Image

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 01:59
by SpliFF
What's with the arbitrary 3 levels of GG? If you don't restore it in its entirety I don't see how the data can do anything but crash gadgets.

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 02:47
by Argh
Absolutely, if they go deeper than the following example:

GG.foo = {bar = {foobar = 'barfoo'}}

I haven't seen much of anything designed to go further down than that, so I figured it was reasonably safe.

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 03:58
by aegis
arbitrary three levels because it's hardcoded nested loops?

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 04:01
by Argh
Yup. Got a better way?

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 04:03
by aegis
yep.

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 04:06
by Argh
...and?

I tried a few things, but because of the way that the data has to get written back... honestly, I figured I'd just add another recursion by hand or two, if there was a real need.

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 04:07
by aegis
I'm thinking. sample code in a sec.

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 04:10
by Argh
NP, I appreciate the help- I thought it would be super-trivial, but got stumped when faced with output :P

Re: SaveGame v. 0.1

Posted: 23 Jan 2010, 04:13
by aegis

Code: Select all

local function dumpTable(tab)
	if type(tab) == 'table' then
		local tmp = {}
		for a, b in pairs(tab) do
			table.insert(tmp, a .. '=' .. dumpTable(b))
		end
		return '{' .. table.concat(tmp, ',') .. '}'
	else
		return tab
	end
end

Spring.Echo(dumpTable(GG))
see if this works, haven't tested it <_<