SaveGame v. 0.6

SaveGame v. 0.6

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

SaveGame v. 0.6

Post 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).
Attachments
SAVEGAMES.sdd.zip
(464.65 KiB) Downloaded 69 times
screen00001.jpg
(376.16 KiB) Downloaded 3 times
Last edited by Argh on 28 Jan 2010, 15:18, edited 8 times in total.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: SaveGame v. 0.1

Post by Gota »

You need to start a game to load other games?
Is this applicable to multiplayer sessions?
User avatar
very_bad_soldier
Posts: 1390
Joined: 20 Feb 2007, 01:10

Re: SaveGame v. 0.1

Post by very_bad_soldier »

You did that window really well, sir. Looks AAA no doubt.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post 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.
Last edited by Argh on 22 Jan 2010, 21:23, edited 1 time in total.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: SaveGame v. 0.1

Post by Gota »

Suggestion:restart.
As i was thinking about making some single player missions i quickly realized restart would be very important.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post by Argh »

It uses restart, lol.

Download it, install it, try it out.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7032
Joined: 16 Nov 2004, 13:08

Re: SaveGame v. 0.1

Post 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.
User avatar
AF
AI Developer
Posts: 20686
Joined: 14 Sep 2004, 11:32

Re: SaveGame v. 0.1

Post 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?!
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post 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.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: SaveGame v. 0.1

Post by Gota »

commercial products have a dedicated restart button per mission.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post 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
Attachments
screen00001.jpg
(376.16 KiB) Downloaded 3 times
User avatar
SpliFF
Posts: 1224
Joined: 28 Jul 2008, 06:51

Re: SaveGame v. 0.1

Post 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.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post 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.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: SaveGame v. 0.1

Post by aegis »

arbitrary three levels because it's hardcoded nested loops?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post by Argh »

Yup. Got a better way?
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: SaveGame v. 0.1

Post by aegis »

yep.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post 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.
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: SaveGame v. 0.1

Post by aegis »

I'm thinking. sample code in a sec.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: SaveGame v. 0.1

Post by Argh »

NP, I appreciate the help- I thought it would be super-trivial, but got stumped when faced with output :P
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: SaveGame v. 0.1

Post 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 <_<
Post Reply

Return to “Lua Scripts”

cron