love.event.wait freezing game window

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Neox Hopper
Prole
Posts: 8
Joined: Mon Dec 31, 2018 8:20 am

Re: love.event.wait freezing game window

I tried using this script:

Code: Select all

 local Timer = require("hump.timer")
local Potato2 = ""
function love.keypressed(key)
if key == 'a' then
Timer.after(1, function() Potato2 = ("potato2.png") end)
end
end
function love.update(dt)
Timer.update(dt)
end
function love.draw()
love.graphics.draw(Potato2)
end

But it gave me this error message:

Code: Select all

Error
main.lua:13: bad argument #1 to 'draw' (Drawable expected, got string)

Traceback

[C]: in function 'draw'
main.lua:13: in function 'draw'
[C]: in function 'xpcall'

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

Re: love.event.wait freezing game window

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.

BobTheBuilder
Prole
Posts: 4
Joined: Wed Jan 02, 2019 10:03 am

Re: love.event.wait freezing game window

I used this script and it worked:

Code: Select all

 local Timer = require("hump.timer")
right = love.graphics.newImage("potatoes/right.png")
right2 = love.graphics.newImage("potatoes/right2.png")
left = love.graphics.newImage("potatoes/left.png")
left2 = love.graphics.newImage("potatoes/left2.png")
potato = right
x = 50
y = 50
speed = 300
function love.keypressed(key)
if key == 'd' then
Timer.after(1, function() potato = right2 end)
end
end
function love.update(dt)
Timer.update(dt)
end

function love.draw()
love.graphics.draw(potato)
end  
However I still can't figure out how to make the image move (I keep getting errors about being unable to use arithmetic and global values).
Last edited by BobTheBuilder on Fri Jan 04, 2019 12:22 pm, edited 1 time in total.

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

Re: love.event.wait freezing game window

BobTheBuilder wrote:
Fri Jan 04, 2019 11:11 am
However I still can't figure out how to make the image move (I keep getting errors about being unable to use arithmetic in global values).
I'm 100%sure that's not what the error message says though; it may be complaining that a value is nil or something else that you can't indeed perform arithmetic with; you'd need to show code and the actual error message with the line number to make life easier for all of us... up to a point; that said, i'll leave it up to you whether you want to hijack this thread for the duration of this, or if you'll open a new thread for it.
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.

Who is online

Users browsing this forum: Bing [Bot] and 3 guests