Module core

Global utility and debugging functions

Global functions

LOTJ.broadcast (source, message) make a public broadcast
LOTJ.councilnet (source, message) send a message to the RPC channel
LOTJ.date () get the current date
LOTJ.debug (msg) send a message to the debug channel
LOTJ.error (error) produces an error, causing the current lua program to crash
LOTJ.getEra () get the current era number.
LOTJ.getGlobalVar (varName, default) get a global variable by name
LOTJ.getGlobalVarTimer (varName) get a global variable by name
LOTJ.immchat (source, message) send a message to immchat
LOTJ.isColor (number, color) checks if 256 color int value is mapped to a base color value
LOTJ.keywordCheck (args, keywords) check if the given arguments match a list of keywords
LOTJ.log (msg) send a message to the log channel
LOTJ.newThread (callback) create a new background coroutine
LOTJ.onBoot (callback) callback when the mud boots up or copyover recovers (once the script is loaded)
LOTJ.onReady (callback) callback when the mud boots up or copyover recovers -- and/or when the script is loaded/reloaded
LOTJ.setDateTime (the) takes a natural language date/time and returns an int value
LOTJ.setGlobalVar (varName, value, ttl) set a global variable
LOTJ.sleep (number) sleep a coroutine for at least x milliseconds
LOTJ.stripColor (orig) remove all color codes from a string
LOTJ.time () get the current time
LOTJ.writeToLog (keyword, content, level, ttl) write to persistent logs (the logs/showlog system)


Global functions

LOTJ.broadcast (source, message)
make a public broadcast

Parameters:

  • source string The source of the broadcast, like GNN or Invisible Market
  • message string The text of the broadcast

Usage:

    LOTJ.broadcast("GNN", "Breaking news! Ewoks have stormed the capitol building on Corellia!")
LOTJ.councilnet (source, message)
send a message to the RPC channel

Parameters:

  • source string The source of the message, like Nield or The Galactic Empire
  • message string The text of the message

Usage:

    LOTJ.councilnet("Nield", "Oopsy daisy. I think I need a restore.")
LOTJ.date ()
get the current date
LOTJ.debug (msg)
send a message to the debug channel

Parameters:

  • msg string the text to debug. Use chan +debug filter *keyword* to view, where keyword is a unique word included in your message.
LOTJ.error (error)
produces an error, causing the current lua program to crash

Parameters:

  • error string the text to include as the error message
LOTJ.getEra ()
get the current era number.

Returns:

    integer the current era number.
LOTJ.getGlobalVar (varName, default)
get a global variable by name

Parameters:

  • varName string the name of the variable to get
  • default an optional default value (string, number, or boolean) to return if the variable is unset

Returns:

    the value, or the default or nil if it's not set. Can be a bool, number, or string.
LOTJ.getGlobalVarTimer (varName)
get a global variable by name

Parameters:

  • varName string the name of the variable whose timer to get

Returns:

    the integer value of seconds remaining in the timer, or 0 if it's expired, or nil if the variable is not set.
LOTJ.immchat (source, message)
send a message to immchat

Parameters:

  • source string The source of the message, like Nield or The Galactic Empire
  • message string The text of the message

Usage:

    LOTJ.immchat("Nield", "How much wood could a wood chuck chuck if the wood chuck had 110 force levels?")
LOTJ.isColor (number, color)
checks if 256 color int value is mapped to a base color value

Parameters:

  • number integer the color value
  • color string the color name

Returns:

    boolean true if the color value is part of the base color, false otherwise
LOTJ.keywordCheck (args, keywords)
check if the given arguments match a list of keywords

Parameters:

  • args string the names to search for
  • keywords string the keywords to look in, for example the name field on an object or character

Returns:

    boolean true if the args are found in the keywords, false otherwise

Usage:

    if LOTJ.keywordCheck("imperial stormtrooper", otherCh:getName()) then
      LOTJ.log("otherCh matched imperial stormtrooper")
    end
LOTJ.log (msg)
send a message to the log channel

Parameters:

  • msg string the text to log
LOTJ.newThread (callback)
create a new background coroutine

Parameters:

  • callback function the function to call
LOTJ.onBoot (callback)
callback when the mud boots up or copyover recovers (once the script is loaded)

Parameters:

  • callback function the function to call
LOTJ.onReady (callback)
callback when the mud boots up or copyover recovers -- and/or when the script is loaded/reloaded

Parameters:

  • callback function the function to call
LOTJ.setDateTime (the)
takes a natural language date/time and returns an int value

Parameters:

  • the string date/time

Returns:

    integer the time value (compatible with C-side functions)
LOTJ.setGlobalVar (varName, value, ttl)
set a global variable

Parameters:

  • varName string the name of the variable to set. It must include a namespace, preferably the name of the area setting it, like "wroona.myVar"
  • value the value, a string, number, or boolean. Pass in nil here to remove a variable.
  • ttl number the number of seconds to keep the variable, in seconds. (optional, if not specified it's kept indefinitely)
LOTJ.sleep (number)
sleep a coroutine for at least x milliseconds

Parameters:

  • number int of ms to sleep for
LOTJ.stripColor (orig)
remove all color codes from a string

Parameters:

  • orig string the original text, with color codes

Returns:

    string the string with all color codes removed
LOTJ.time ()
get the current time
LOTJ.writeToLog (keyword, content, level, ttl)
write to persistent logs (the logs/showlog system)

Parameters:

  • keyword string the name of the keyword to log to
  • content string the content to write to the log
  • level number the minimum level to view the log (typically 103)
  • ttl number (optional) the number of hours before the log becomes obsolete (defaults to 336)

Usage:

    LOTJ.writeToLog("hypermatter", "Spawned a new hypermatter ship!", 103)
generated by LDoc 1.5.0 Last updated 2024-10-22 16:05:00