Log In  

Well I am new to lua and pico-8

In javascript, it is possible to force run inner function after some seconds with setTimeout();

setTimeout(function(){},5000);

and I am looking for something similar method or function in lua or pico-8

this is my code

function define_level()
    local level = 'level'..levels;
    show_level(level);
end
function show_level(level)
    print(level,54,64,8);
end

levels is number.

I want to hide or remove text which is printed with print(level, 54,64,8);
after some seconds.

Any tips?

P#50729 2018-03-23 08:23 ( Edited 2018-03-24 17:20)

timer_limit=60
my_timer=0
if my_timer<timer_limit then
my_timer+=1
print(level,54,64,8)
end

P#50730 2018-03-23 08:32 ( Edited 2018-03-23 12:32)

arashi256// I understand what you are trying with if loop but removing text didn't work to me

P#50732 2018-03-23 08:54 ( Edited 2018-03-23 12:54)

arashi256// maybe if loop runs just once..?

P#50733 2018-03-23 08:58 ( Edited 2018-03-23 12:58)

It's not a loop, it's an if statement. Perhaps this will be clearer..

-- init section
timer_limit=60
my_timer=0
-- Then, in your game loop...
if my_timer<timer_limit then
my_timer+=1
print(level,54,64,8)
end
P#50749 2018-03-23 17:28 ( Edited 2018-03-23 21:28)

You need to clear the screen in your _draw function ((if you have one. If not, look at the samples/doc)

P#50764 2018-03-24 13:20 ( Edited 2018-03-24 17:20)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-28 09:17:40 | 0.007s | Q:13