## A big issue with love.update(dt)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Pospos
Citizen
Posts: 70
Joined: Sun Jun 18, 2017 11:10 am

### A big issue with love.update(dt)

Edits: can't and right arrow key.

i have a big isue with update(dt), i can't(sorry for the fault) make my character move even if i press the right arrow (come on, that one was clear though)key.
I made a test to see if i can increment a value.

var = 10
rate = 3
function love.update(dt)
if love.keyboard.isDown("a") then
end
if love.keyboard.isDown("s") then
var = var + 1
end
end
function love.draw(...)
love.graphics.print(var,100,100)
end

it doesn't work. so i think i has something to do with the engine.
I've tried to download another version, but it still the same.
Last edited by Pospos on Mon Jun 19, 2017 7:47 pm, edited 1 time in total.
ⵜⴰⵎⴰⵣⵉⵖⵜ(https://en.wikipedia.org/wiki/Berbers)

raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

### Re: A big issue with love.update(dt)

Try using scancodes instead of regional keyboard characters (you get this by default).

Pospos
Citizen
Posts: 70
Joined: Sun Jun 18, 2017 11:10 am

### Re: A big issue with love.update(dt)

it doesn't work.
ⵜⴰⵎⴰⵣⵉⵖⵜ(https://en.wikipedia.org/wiki/Berbers)

Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm

### Re: A big issue with love.update(dt)

Saying "it doesn't work" doesn't tell us a whole lot about what you need help with. I ran your code, and it does exactly what you told it to do, do you mind being more specific in what you want it to do?

Last edited by Sir_Silver on Sun Jun 18, 2017 8:46 pm, edited 1 time in total.

erasio
Party member
Posts: 118
Joined: Wed Mar 15, 2017 8:52 am
Location: Germany

### Re: A big issue with love.update(dt)

For example: Have you tried comparing "keypressed" key value and scancode to what you currently use? Whether or not it is equal to what you expect it to be.

Besides that. I saw no problem with the code you posted either. It was counting up by 1 per frame when "s" is pressed.

Pospos
Citizen
Posts: 70
Joined: Sun Jun 18, 2017 11:10 am

### Re: A big issue with love.update(dt)

Yeah, i've tried all these, but the games prints the value on screen, but doesnt increment it.
ⵜⴰⵎⴰⵣⵉⵖⵜ(https://en.wikipedia.org/wiki/Berbers)

zorg
Party member
Posts: 2801
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: A big issue with love.update(dt)

Well then, i think it's time you gave us the whole file you were trying to run!
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Pospos
Citizen
Posts: 70
Joined: Sun Jun 18, 2017 11:10 am

### Re: A big issue with love.update(dt)

that's the whole file.
it's just a content.love with this main lua on it.
ⵜⴰⵎⴰⵣⵉⵖⵜ(https://en.wikipedia.org/wiki/Berbers)

zorg
Party member
Posts: 2801
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: A big issue with love.update(dt)

Pospos wrote:
Mon Jun 19, 2017 7:29 pm
that's the whole file.
it's just a content.love with this main lua on it.
Okay, then let's decrypt your question.

By your own admission, this is your whole main.lua, and you use nothing else:

Code: Select all

var = 10
rate = 3
function love.update(dt)
if love.keyboard.isDown("a") then
end
if love.keyboard.isDown("s") then
var = var + 1
end
end
function love.draw(...)
love.graphics.print(var,100,100)
end

The first test doesn't do squat so we can remove it, you don't use the rate variable either, so after a bit of a cleanup, we get this:

Code: Select all

var = 10

function love.update(dt)
if love.keyboard.isDown("s") then
var = var + 1
end
end

function love.draw(...)
love.graphics.print(var,100,100)
end

Now, if you use an AZERTY or DVORAK or generally not a QWERTZ/QWERTY keyboard, you should swap the love.keyboard.isDown function with love.keyboard.isScancodeDown; otherwise it can stay.

In any case, the above code will increment your variable named var with 1 as long as you hold down the "s" key.
It will increment it more than once, of course, since the update function gets called many times each second, along with the draw function.
Pospos wrote:
Sun Jun 18, 2017 11:17 am
i have a big isue with update(dt), i can make my character move even if i press the right key.
By "right key", you mean the "correct" key, or the "right arrow" key?
And do you mean you can't make your character move? Because if you can, then that would imply you not having a problem...
And if you can't, and you expect the right arrow to work when you're not testing for it... then i sadly can't help you further.

After you read all this, feel free to alter your question so that we may give you a better answer.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

Pospos
Citizen
Posts: 70
Joined: Sun Jun 18, 2017 11:10 am