leveltimer.lua

From Moondust Wiki
Revision as of 13:31, 14 September 2017 by Yingchun Soul (talk | contribs)
Jump to navigation Jump to search



The latest release can be found here. The source code can be found here.

This one is deprecated due to clock.lua was released

Installation

After downloading the .zip, place the contents of the zip (save for usage.txt) into your LuaScriptsLib directory. Inside of your LuaScriptsLib folder, you should now have a leveltimer folder and leveltimer.lua.

How to Use

The script is meant to be used on a per level basis, just like each level in Super Mario World has its own time limit. However, it CAN be used on a global basis if placed in a lunaworld.lua.

In your lunadll.lua file, start with the following import:

local leveltimer = API.load("leveltimer")

Then, override the onStart() function of the level and set your variables.

function onStart()
     leveltimer.setSecondsLeft(300)
     leveltimer.setTimerState(true)
end

This sets the amount of time in your level, 300, and sets the timer to be enabled.

Methods Reference

Name Returns Notes
getSecondsLeft() int Gets the amount of seconds left in the level.
setSecondsLeft(to_set) nil Sets the amount of time left in the level, as an int.
setTimerState(b_tf) nil Sets the timer's state (meaning whether or not it'll even be shown) to the boolean's value.

Media

YouTube Video