Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a save game feature in love2d?

Tags:

lua

love2d

I am new to game development but I need to know if it is possible to create a save game feature in love2d with lua.

like image 658
noneya231 Avatar asked Oct 24 '25 19:10

noneya231


1 Answers

Sure. You can use a variety of libraries available. My current recommendation is Ser Binser (Ser has been deprecated). This process is called "table serialization." Then, you can do something like this to effectively create a "save."

local ser = require 'Path.to.ser'
local save 

function love.load()
    if love.filesystem.exists( 'Save.lua' ) then
        save = love.filesystem.load( 'Save.lua' )
    else
        save = {} -- Put settings in here.
    end
end
-- etc. etc.
function love.quit()
   love.filesystem.write( 'Save.lua', save )
end
like image 90
DavisDude Avatar answered Oct 27 '25 02:10

DavisDude