Page 2 of 2

Re: love.event.wait freezing game window

Posted: Fri Jan 04, 2019 1:57 am
by Neox Hopper
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'

Re: love.event.wait freezing game window

Posted: Fri Jan 04, 2019 4:52 am
by zorg

Re: love.event.wait freezing game window

Posted: Fri Jan 04, 2019 11:11 am
by BobTheBuilder
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 :P (I keep getting errors about being unable to use arithmetic and global values).

Re: love.event.wait freezing game window

Posted: Fri Jan 04, 2019 11:14 am
by zorg
BobTheBuilder wrote: Fri Jan 04, 2019 11:11 am However I still can't figure out how to make the image move :P (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.