Code: Select all
print("light on")
--need small code to make it stay "light on" for example 5sec.
os.execute("clear")
print("light off")
Code: Select all
print("light on")
--need small code to make it stay "light on" for example 5sec.
os.execute("clear")
print("light off")
Code: Select all
local function startTimer()
time = 0
countTime = true
color = { 255, 255, 255 }
end
local function endTimer()
countTime = false
color = { 0, 0, 0 }
end
function love.load()
color = { 0, 0, 0 } -- The color to set the screen to.
countTime = false
time = 0
maxTime = 5
end
function love.update( dt )
if countTime then
time = time + dt
if time >= maxTime then
endTimer()
end
end
end
function love.draw()
love.graphics.setColor( color )
love.graphics.rectangle( 'fill', 0, 0, 800, 600 )
end
function love.keyreleased( key )
if not countTime then startTimer() end
end
Code: Select all
function love.load()
light_on = love.graphics.newImage("light_on.png")
light_off = love.graphics.newImage("light_off.png")
set = light_off
sleep = 0
switch = true
end
function love.update(dt)
if switch then
while sleep < 5 do
sleep = sleep + dt
set = light_on
end
switch = false
set = light_off
end
end
function love.draw()
love.graphics.draw(set,0,0)
end
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests