Page 1 of 1
dt is a table value?
Posted: Sat Nov 12, 2016 7:47 pm
by Doctory
hello everyone,
im having a problem when trying to use dt to preform an arithmetic with it, but love throws an error on me saying its a table function:
hope anyone here is able to fix it. thanks in advance. .love is attached.
Re: dt is a table value?
Posted: Sat Nov 12, 2016 7:59 pm
by pgimeno
You're using dot notation for defining the update function, but calling it with colon notation.
When calling a function, using a colon is equivalent to calling it with the table as the first argument. For example:
is equivalent to:
So, you're passing the
player table as the first parameter, because you use colon notation when you do this:
Code: Select all
states.states[states.currentState]:update(dt)
The solution is simple: just use a colon in the definition too, like this:
That's equivalent to:
so you can use either, though I'd say the former is preferred in this case.
Edit: Note that it will err again because you have the same issue in src/states/game.lua - just replace function game.update(dt) and player.update(dt) with function game:update(dt) and player:update(dt).
Re: dt is a table value?
Posted: Sat Nov 12, 2016 8:10 pm
by Doctory
i cant even use the library i made properly, thanks for the help!