Apparently it does not access dt as value but as table, the error message is
"luas/state_gam.lua:12 attempt to perform arithmetic on local 'dt' (a table value)"
I reduced the code to a minimum to reproduce it. The following is from my "MiniExampleOld.love", the content of the main.lua does nothing other than run a custom update 40 times per second and show a black screen, but it works:
old main.lua
Code: Select all
function love.load()
dUpd = 0.0
tUpd = 0.0125
end
function love.update(dt)
dUpd = dUpd + dt
if dUpd > tUpd then
dUpd= dUpd-tUpd
doGamUpdates()
end
end
function love.draw()
--insert code
end
function doGamUpdates()
--insert code
end
main.lua
Code: Select all
--requires
gamestate = require "libs/gamestate" --represent current gamestate
--class = require "libs/class"
--luas requires
require "luas/state_gam"
gamestate.switch(gam)
gamestate.init()
function love.load()
end
function love.update(dt)
gamestate.update(dt)
end
function love.draw()
gamestate.draw()
end
Code: Select all
gam = {} -- previously: Gamestate.new()
function gam.init()
dUpd = 0.0
tUpd = 0.0125
end
function gam.update(dt)
dUpd = dUpd + dt --This line will throw the error
if dUpd > tUpd then
dUpd= dUpd-tUpd
doGamUpdates()
end
end
function gam.draw()
--insert code
end
function doGamUpdates()
--insert code
end