Page 1 of 1

[SOLVED] Help with saving level data

Posted: Mon Oct 16, 2017 6:33 pm
by Schwender.exe
o/ hello all! so I've been creating a level editor for a game I'm making, I have most of it finished except for saving/loading and I have no clue on how to do this, I store the tiles/objects/entities in separate tables (all tiles in tiles table, etc.) I have no experience in saving data at all. so, any suggestions/ideas/help?

code:

Code: Select all

Tiles = {} -- all tiles
Entities = {} -- all living things (excluding player)
Objects = {} -- all props
-- -- --
-- later on in code --
function spawn_tile(x,y,t,id)
  if get_tile(x,y) == true then remove_tile(x,y) end -- removes any tiles with the same x/y
  local tile = {}
  tile.x = x
  tile.y = y
  tile.t = t -- tile
  tile.id = id -- subtile
  tile.tex = _G["t_"..t.."_"..id]
  table.insert(Tiles,tile)
end
-- I have similar setups for Objects and Entities, all just have different variables

Re: Help with saving level data

Posted: Mon Oct 16, 2017 8:05 pm
by hamberge
look up a serialization library such as:

https://love2d.org/wiki/Tserial

It'll convert your day into a string which you can write to a file and will convert a string back to a table for loading from a file.

Re: Help with saving level data

Posted: Mon Oct 16, 2017 8:14 pm
by Schwender.exe
hamberge wrote: Mon Oct 16, 2017 8:05 pm look up a serialization library such as:

https://love2d.org/wiki/Tserial

It'll convert your day into a string which you can write to a file and will convert a string back to a table for loading from a file.
ah ok, the download seems to be down though :/

Re: Help with saving level data

Posted: Mon Oct 16, 2017 8:51 pm
by Fuzzlix
Schwender.exe wrote: Mon Oct 16, 2017 8:14 pm
hamberge wrote: Mon Oct 16, 2017 8:05 pm look up a serialization library such as:

https://love2d.org/wiki/Tserial

It'll convert your day into a string which you can write to a file and will convert a string back to a table for loading from a file.
ah ok, the download seems to be down though :/
Wayback machine still has it :cool:

Re: Help with saving level data

Posted: Mon Oct 16, 2017 9:09 pm
by Schwender.exe
Fuzzlix wrote: Mon Oct 16, 2017 8:51 pm
Schwender.exe wrote: Mon Oct 16, 2017 8:14 pm
hamberge wrote: Mon Oct 16, 2017 8:05 pm look up a serialization library such as:

https://love2d.org/wiki/Tserial

It'll convert your day into a string which you can write to a file and will convert a string back to a table for loading from a file.
ah ok, the download seems to be down though :/
Wayback machine still has it :cool:
ah ok, thanks :awesome:

Re: Help with saving level data

Posted: Mon Oct 16, 2017 9:15 pm
by grump
Don't use outdated libraries from abandoned amateur projects, especially if you're a newbie. It's a recipe for disaster and very few people will be able to help fix shit once it starts hitting the fan. Keep looking for better alternatives. Here's a starting point, and here's another one. The keyword you're looking for is "serialization".

Re: Help with saving level data

Posted: Mon Oct 16, 2017 9:35 pm
by Schwender.exe
grump wrote: Mon Oct 16, 2017 9:15 pm Don't use outdated libraries from abandoned amateur projects, especially if you're a newbie. It's a recipe for disaster and very few people will be able to help fix shit once it starts hitting the fan. Keep looking for better alternatives. Here's a starting point, and here's another one. The keyword you're looking for is "serialization".
thanks! I'll look into those, but I tried out Tserial and it seems to work! saving and loading levels works, but if it starts to crap out I'll try something else :P