--the error
Error
Syntax error: libs/sav.lua:16: '=' expected near 'love'
Traceback
[love "callbacks.lua"]:228: in function 'handler'
[C]: at 0x7ffeecd331d0
[C]: in function 'require'
main.lua:3: in function 'load'
[love "callbacks.lua"]:136: in function <[love "callbacks.lua"]:135>
[C]: in function 'xpcall'
[C]: in function 'xpcall'
l = {}
function l.load(file)
if love.filesystem.getInfo(file) then
return(love.filesystem.read(file))
else
love.filesystem.newFile(file)
love.filesystem.write(file, 0)
return(love.filesystem.read(file))
end
end
function l.save(val, file)
if love.filesystem.getInfo(file) then
love.filesystem.write(file, val)
else
l.load
love.filesystem.write(file, val)
end
end
Hope you guys will help me !
Last edited by zalander on Tue Feb 28, 2023 2:37 am, edited 1 time in total.
You are missing () on previous line (before l.load), so Lua thinks, you want tonassign some value to l.load, and that’s why it wants =. In some languages, it is valid to call function like that, but in lua, you have ti call it in one of following ways:
func() -- normal call
func{} -- direct table parameter (you can give only first parameter this way)
func”” -- direct string parameter (you can give only first parameter this way)