Skip to content

General Utilities

ZSolarDev edited this page Jan 25, 2025 · 2 revisions


LunarLogger

A logger class. The output for log('heheheha'); would be: LOG: (funny.class.path.FunnyClass) heheheheha

The output for info('heheheha'); would be: INFO: (funny.class.path.FunnyClass) heheheheha

You get the gist. (the logs are in color, too!)

for convinience, I would make an import.hx and just do "import lunarlib.LGUtils.LunarLogger.*" so that it imports all of the funcitons of the LunarLogger class. This is so that when you want to use log, you can just use it like trace() without any LunarLib.log or anything, just log.

Functions:

  • log(msg:Dynamic): Logs a message to the console in white.
  • info(msg:Dynamic): Logs a message to the console in light grey.
  • warning(msg:Dynamic): Logs a message to the console in yellow.
  • debug(msg:Dynamic): Logs a message to the console in cyan.
  • error(msg:Dynamic): Logs a message to the console in red.
  • fatalError(msg:Dynamic): Logs a message to the console that looks like: FATAL ERROR: (the "FATAL ERROR:" has a red background, and the error itself is red.)


LunarTimer

A timer class with a loop/stopwatch system.

Variables:

  • time:Float: The time on the timer/stopwatch in seconds.
  • loopsLeft:Int: The loops left on the timer.
  • running:Bool: If the timer/stopwatch is running.
  • stopped:Bool: If the timer/stopwatch is stopped.
  • paused:Bool: If the timer/stopwatch is paused.
  • timerCompleted:() -> Void: The callback called when this timer is completed.
  • loopCompleted:(loopID:Int) -> Void: The callback called when a loop is completed; the loops remaining is passed through for convinience.

Functions:

  • pause(): Pauses the timer.
  • unpause(): Unpauses the timer.
  • stop(): stopps the timer.
  • startTimer(dt:Float, ?durationSecs:Float = 1, ?loopsLeft:Int = 0): starts the timer.
  • startStopwatch(): starts the stopwatch.


LunarGeneralUtiities(LGUtils)

Not much currently.

Variables:

  • infoLogs:Bool: if true, info logs will show in the console.
  • warningLogs:Bool: if true, warning logs will show in the console.
  • errorLogs:Bool: if true, error logs will show in the console.

Functions:

  • copyClass(): Returns the copied instance of an instance.

Welcome, Welcome. Read up, and have a good day!

Clone this wiki locally