Global Utility Library

The Global Utility Library is a set of useful functions that are in the global space.

WaitSeconds(seconds)
Waits a number of seconds. Can only be used inside of a coroutine.

CreateClass(name of class, class table)
Creates a class in the global space. See Scripting a Class for more information on how this is used.

math.clamp(value, lower bound, upper bound)
Clamps a value to the bounds specified. Returns the new number.

math.map(value, lower range 1, upper range 1, lower range 2, upper range 2)
Maps a value from one range to another. Example: --Value between 0 and 1 local percent = 0.5 print(math.map(percent, 0, 1, 100, 200)) --Output: 150

math.randomf(lower, upper)
Returns a random float between lower and upper.

OverTime(Total time, Callback function, Is function a coroutine?)
This function takes a callback function and will run it over a period of time. The function can take up to three arguments: current percentage, current Time, and total Time.

Example: function Coroutine OverTime(1.0,   function(percent)     print("I am " .. 100 * percent .. " percent done!")  end) end Output over 1 second: I am 0 percent done! I am 1.6666881740093 percent done! I am 3.3333763480186 percent done! ... I am 95.002642460167 percent done! I am 96.669330634177 percent done! I am 98.336018808186 percent done! I am 100 percent done!