i tried a few ways to save my tables but when it comes to do it....
it fails i don't know why?
now tserial is it a good way to save tables? is that the right way or is there a super easier way??
can anyone point to me which direction to take if there is a better way and easy???
i am trying to make like a zelda game so ill need to save a lot of tables...
p.s how does Tserial work? i don't get wiki any examples?
save game with tserial?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: save game with tserial?
Saving and loading has two possible difficulties.
1) The technical one. You need to write some code that writes something to the hard drive and reads it later. There are two approaches for that. Either, save the data in Lua-language. Then writing it will be a bit difficult, but reading it is very simple, just a matter of one line. Or you save the data in a format that you make up yourself. That would probably a text-file, with your data included. In the first case, serialization is the way, to go. I do not have any experience with tserial, but that potentially does the trick.
2) The information management. Conceptually you have to think about, what data needs to be stored to fully recover the game state. Is it enough to only store one number (the level) or do you need to store all the character values, positions of enemies, etc..
1) The technical one. You need to write some code that writes something to the hard drive and reads it later. There are two approaches for that. Either, save the data in Lua-language. Then writing it will be a bit difficult, but reading it is very simple, just a matter of one line. Or you save the data in a format that you make up yourself. That would probably a text-file, with your data included. In the first case, serialization is the way, to go. I do not have any experience with tserial, but that potentially does the trick.
2) The information management. Conceptually you have to think about, what data needs to be stored to fully recover the game state. Is it enough to only store one number (the level) or do you need to store all the character values, positions of enemies, etc..
Check out my blog on gamedev
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: save game with tserial?
Tserial has a number of problems (I've gone into detail on this elsewhere on the forums) which is why I don't recommend it. Instead, you could use something like Ser. If you download it, and put ser.lua next to your main.lua, you can put this at the top of your main.lua (or where-ever you want to put your saving code):pielago wrote:now tserial is it a good way to save tables? is that the right way or is there a super easier way??
Code: Select all
local serialize = require 'ser'
Code: Select all
love.filesystem.write('nameofsavegame', serialize(gamedata))
Code: Select all
gamedata = love.filesystem.load('nameofsavegame')()
Code: Select all
love.filesystem.write('nameofsavegame', serialize({player, someothertable}))
Code: Select all
player, someothertable = unpack(love.filesystem.load('nameofsavegame')())
Help us help you: attach a .love.
Re: save game with tserial?
that's one of the tables to save from many so...
like this???
--and to load like this?
or am i super confuse?
Code: Select all
player={}
player.x=100
player.y=200
player.w=50
player.h=50
player.speed=300
player.life=5
Code: Select all
love.filesystem.write('scores', serialize(player))
Code: Select all
player = love.filesystem.load('score','player')()
Who is online
Users browsing this forum: No registered users and 3 guests