Code: Select all
local serialize = require 'ser'
--saving code
love.filesystem.write('nameofsavegame', serialize(sometable))
--loading code
sometable = love.filesystem.load('nameofsavegame')()
Code: Select all
local serialize = require 'ser'
--saving code
love.filesystem.write('nameofsavegame', serialize(sometable))
--loading code
sometable = love.filesystem.load('nameofsavegame')()
Code: Select all
--saving code
love.filesystem.write('nameofsavegame', serialize({player, map, enemies})
--loading code
player, map, enemies = unpack(love.filesystem.load('nameofsavegame')())
Code: Select all
--load filesystem
if love.filesystem.exists("player") then
p = setmetatable(love.filesystem.load('player')(), getmetatable(p))
end
Code: Select all
function love.keypressed(key)
if key == 's' then
--write data
love.filesystem.write('player', serialize(p))
end
end
Code: Select all
function love.keypressed(key)
if key == 's' then
--write data
love.filesystem.write('player', serialize(p,m,s,t))--many metatables
end
end
Code: Select all
--writing
love.filesystem.write('player', serialize({p,m,s,t}))--note the curly braces
Code: Select all
--loading
p, m, s, t = unpack(love.filesystem.load('player')())
setmetatable(p, {__index = Player})
setmetatable(m, {__index = Map})-- I don't know what these are
setmetatable(s, {__index = Something}) -- it might be good to use more descriptive variable names
setmetatable(t, {__index = Tsomething}) -- so that other people or future you can understand what they're for
Code: Select all
love.filesystem.write('player', serialize({p,m,s,t}))--note the curly braces
Code: Select all
--loading
p, m, s, t = unpack(love.filesystem.load('player')())
setmetatable(p, {__index = Player})
setmetatable(m, {__index = Map})-- I don't know what these are
setmetatable(s, {__index = Something}) -- it might be good to use more descriptive variable names
setmetatable(t, {__index = Tsomething}) -- so that other people or future you can understand what they're for
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 2 guests