Help Using knife.serialize
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- CanadianGamer
- Party member
- Posts: 132
- Joined: Tue Jun 30, 2015 1:23 pm
- Location: Canada
- Contact:
Help Using knife.serialize
I am trying to use a library called knife.serialize but I've never used a library before can anyone tell me how to make it work
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
Re: Help Using knife.serialize
Dowload serialize.lua and put it in somewhere your project.
If you put it in a folder called "knife" you would include it like this:
Let's say you want to serialize a table named "data"
Now the variable "serializedData" contains a string that can be saved to a file...
...and later the file can be deserialized with dofile.
Now "deserializedData" contains a table equivalent to the original "data" table.
If you put it in a folder called "knife" you would include it like this:
Code: Select all
local Serialize = require 'knife.serialize'
Code: Select all
local serializedData = Serialize(data)
Code: Select all
love.filesystem.write('savegame.lua', serializedData)
Code: Select all
local deserializedData = dofile('savegame.lua')
Re: Help Using knife.serialize
Never use "dofile" in LÖVE. Love.filesystem.load works better.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Help Using knife.serialize
Thanks, still not used to the way Love wants to interact with the filesystem. Dofile will break if you don't know the full path to the file, so the last code block should be something like this under Love:Nixola wrote:Never use "dofile" in LÖVE. Love.filesystem.load works better.
Code: Select all
local deserializedData = love.filesystem.load('savegame.lua')()
- CanadianGamer
- Party member
- Posts: 132
- Joined: Tue Jun 30, 2015 1:23 pm
- Location: Canada
- Contact:
Re: Help Using knife.serialize
Thank You for your help
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
- CanadianGamer
- Party member
- Posts: 132
- Joined: Tue Jun 30, 2015 1:23 pm
- Location: Canada
- Contact:
Re: Help Using knife.serialize
Okay it is still not working I have it saving table settingsTable:
in settings.lua by doing this:
but settings.lua is still blank
Code: Select all
settingsTable = {SoundFxSetting = true, MusicSetting = true}
Code: Select all
serializedSettingsData = Serialize(settingsTable)
love.filesystem.write('settings.lua', serializedSettingsData)
My serious itch.io page:
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
https://pentamonium-studios.itch.io/
My less serious itch.io page:
http://canadiangamer.itch.io
Re: Help Using knife.serialize
The code looks fine, it should work.
Love might not be saving the file where you expect, take a look at love.filesystem and love.filesystem.setIdentity to get an idea of how this works. You should be able to print(love.filesystem.getSaveDirectory()) to see where it's actually being saved.
If that doesn't solve it, upload a .love and I'll have a look (or someone else will).
Love might not be saving the file where you expect, take a look at love.filesystem and love.filesystem.setIdentity to get an idea of how this works. You should be able to print(love.filesystem.getSaveDirectory()) to see where it's actually being saved.
If that doesn't solve it, upload a .love and I'll have a look (or someone else will).
Who is online
Users browsing this forum: Bing [Bot] and 90 guests