I am trying to generate a random number, every random seconds (the final purpose would be to change the color of a block from time to time, randomly).
For that, I am using the Hump library (http://vrld.github.io/hump/#hump.timer).
Here is my code at the moment, I am true beginner in LUA/Love2d coding. It generates a number, and displays it every seconds, instead of every random seconds... (but the random seconds is also generated). I don't really understand why it is not working.
Code: Select all
local Timer = require "timer"
function love.load()
text="t"
number2=1
end
local f = function()
math.randomseed(os.time())
number = math.random( 2,10 )
text="in " .. number2 .. " seconds (random)... random number =" .. number
return true
end
function love.update(dt)
number2 = math.random( 2,4 )
Timer.update(number2)
Timer.addPeriodic(number2, f)
end
function love.draw()
love.graphics.print( text, 330, 300 )
end
Thanks for any help !