[SOLVED] Help with saving level data

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
Schwender.exe
Prole
Posts: 25
Joined: Mon Oct 16, 2017 6:07 pm
Location: the moon
Contact:

[SOLVED] Help with saving level data

Post 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
Last edited by Schwender.exe on Mon Oct 16, 2017 9:36 pm, edited 1 time in total.
hamberge
Prole
Posts: 25
Joined: Wed Aug 16, 2017 2:55 pm

Re: Help with saving level data

Post 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.
User avatar
Schwender.exe
Prole
Posts: 25
Joined: Mon Oct 16, 2017 6:07 pm
Location: the moon
Contact:

Re: Help with saving level data

Post 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 :/
Fuzzlix
Citizen
Posts: 60
Joined: Thu Oct 13, 2016 5:36 pm

Re: Help with saving level data

Post 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:
User avatar
Schwender.exe
Prole
Posts: 25
Joined: Mon Oct 16, 2017 6:07 pm
Location: the moon
Contact:

Re: Help with saving level data

Post 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:
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Help with saving level data

Post 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".
User avatar
Schwender.exe
Prole
Posts: 25
Joined: Mon Oct 16, 2017 6:07 pm
Location: the moon
Contact:

Re: Help with saving level data

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

Who is online

Users browsing this forum: Bing [Bot] and 3 guests