dt is a nil value?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
EportV
Prole
Posts: 3
Joined: Fri Jan 01, 2016 1:07 am

dt is a nil value?

Post by EportV »

im trying to make a player movement system, however it keeps telling me that dt is a nil value... help?


function player.move(dt)
local x, y = nil, nil
if love.keyboard.isDown("up") then
y = player.y - player.speed * dt
elseif love.keyboard.isDown("down") then
y = player.y + player.speed * dt
end

if love.keyboard.isDown("left") then
x = player.x - player.speed * dt
elseif love.keyboard.isDown("right") then
x = player.x + player.speed * dt
end

end
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: dt is a nil value?

Post by veethree »

Are you calling "player.move()" inside love.update? if so are you calling it with dt as the argument? If you're not calling it within love.update you can put "local dt = love.timer.getDelta()" at the top of player.move.
EportV
Prole
Posts: 3
Joined: Fri Jan 01, 2016 1:07 am

Re: dt is a nil value?

Post by EportV »

@veethree

wont work still :(
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

Re: dt is a nil value?

Post by Beelz »

Without knowing more, its hard to help you... Could you post a .love so we can take a look?

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest