Is it possible to make a wait in Luna.Lua?

This is the place for discussion and support for LunaLua and related modifications and libraries.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on topic/appropriate?
-Are you posting in the right forum/following the forum rules?
BananaCat
Swooper
Swooper
Posts: 50
Joined: Fri Dec 30, 2016 6:20 pm

Is it possible to make a wait in Luna.Lua?

Postby BananaCat » Tue Feb 07, 2017 2:54 pm

There used to be a wait function in Lua, but I cant seen to find it, is it just regular wait(3)? Or.... :!:

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9722
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Is it possible to make a wait in Luna.Lua?

Postby Emral » Tue Feb 07, 2017 4:27 pm


Hoeloe
Foo
Foo
Posts: 1463
Joined: Sat Oct 03, 2015 6:18 pm
Flair: The Codehaus Girl
Pronouns: she/her

Re: Is it possible to make a wait in Luna.Lua?

Postby Hoeloe » Tue Feb 07, 2017 4:28 pm

BananaCat wrote:There used to be a wait function in Lua, but I cant seen to find it, is it just regular wait(3)? Or.... :!:
You're probably thinking of Teascript-vb used by 38A. That is NOT Lua and has no relevance at all.

You can use the eventu library to make waits, though it's fairly advanced and I wouldn't recommend it to beginners.

Instead, you can construct a counter like this:

Code: Select all

local timerStart;

function onStart()
	timerStart = lunatime.tick(); --start the timer
end

function onTick()
	if(timerStart ~= nil and lunatime.tick() > timerStart+lunatime.toTicks(3)) then
		--timer is finished
		timerStart = nil;
	end
end
It's a little longer, but there's a lot more flexibility there. This is just one way to make a timer, there are a number of different possible ways.


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 5 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari