Custom Save Format

I’d like to come up with a save format that can be easily loaded into Lua and doesn’t completely break between updates. The eventual aim would be to replace the current save system with this new better system.

Anyone got any ideas?

Should it use Keyvalues? Or should create a Lua file that creates a table or something?

This is a request for input.

What exactly do you mean by save? Like game saves, or a replacement for text files in the data folder??

Will be nice if there will be option to save multiplayer games (by server owner) so they can be loaded on server start.

I think it should take a snap shot of the current lua state and save it like that, then pcall it to make sure that if some functions are gone, it won’t brake that much?

It could just be a file with the data saved via glon or something.

glon is heavy on bytes though

I’m cool with saving it as a VMF.

@ningalio



require( "glon" )
t = {
  "asfd",
  Subtable = { 
     52, 342, "hi", Vector( 1, 1, 1 )
  },
  {
     33, 124, Angle( 0 ), "keys keys keys"
  }
}

file.Write( "glon.txt", glon.encode( t ) )
file.Write( "kv.txt", TableToKeyValues( t ) )


Which method results in the larger file?

fine, we’ll use glon :3:

only jumping on the :bandwagon:

Define save, the curret map state including props / sents / etc or the lua state?

How does the current save work (since it breaks betwheen updates)?

Garry i hope you can make it like Advance Duplicator, A save files that can be uploaded to any server.
Its pretty good.

A binary format would probbably do best, sadly lua cant write binary propperly and cant read it propperly either

glon doesn’t pack floating-point numbers (e.g. all numbers in lua) or anything else that uses them. it’s useless if you’re looking for small size and speed.

KeyValues would have some problems (No uppercase keyvalues). Glon also, would have some problems. There’s no 100% certain way of saving everything perfectly, but saving data on every entity in the map, with data of the map itself and storing it is the best sort of structure.

I’d personally use keyvalues.

What kind of data does the save system generate? A bunch of nested assoc. arrays/dictionaries?

Is this topic a question about what data to save or how to save the resulting data? :S

In source, each entitie tells the engine what to save, perhaps we could use that too, like in the duplicator.Register function.

A whole lua state save would be awsome, but hard

garry wants this new save feature to save entity states too - so i’d guess it’s more similar to the advanced duplicator, except it saves the whole map.

Again, doesn’t the VMF format sound like a better idea? People could literally build parts of their map in GMod and load it into Hammer. I’m sure that would attract quite a few people.

And how do you intend on storing entity data, like where the player is, what weapons (including sweps) they have, and any custom data (like the player health, armor, movetype, all stuff like that). I can’t see it being a very good format. If there was some way to tell hammer to ignore a certain part of the vmf when loading you could hax the data into that, I guess.