File Other.lua

Functions

SavedVariables () TODO Table SavedVariables.
SavedVariables:Add (tbl) TODO SavedVariables:Add(tbl)
_comp (a, b) TODO _comp(a, b)
atcp () Mudlet's support for ATCP.
getOS () Determine operating system.
io.exists (fileOfFolderName) Checks to see if a given file or folder exists.
loadVars () This function should be primarily used by Mudlet.
openURL (url) Opens the default OS browser for the given URL.
phpTable (...) TODO phpTable(...) - abuse to: http://richard.warburton.it
remember (varName) This function flags a variable to be saved by Mudlet's variable persistence system.
saveVars () This function should primarily be used by Mudlet.
sendAll (..., echoTheValue) Sends a list of commands to the MUD.
speedwalk (dirString, backwards, delay) TODO speedwalk(dirString, backwards, delay)
speedwalktimer () TODO speedwalktimer()
table.load (sfile, loadinto) Restores a Lua table from a data file that has been saved with table.save().
table.pickle (t, file, tables, lookup) TODO table.pickle( t, file, tables, lookup )
table.save (sfile, t) The below functions (table.save, table.load) can be used to save individual Lua tables to disc and load them again at a later time e.g.
table.unpickle (t, tables, tcopy, pickled) TODO table.unpickle( t, tables, tcopy, pickled )
walkdelay () TODO Variable walkdelay.
walklist () TODO Table walklist.
xor (a, b) Implementation of boolean exclusive or.


Functions

SavedVariables ()
TODO Table SavedVariables.
SavedVariables:Add (tbl)
TODO SavedVariables:Add(tbl)
Parameters
  • tbl:
_comp (a, b)
TODO _comp(a, b)
Parameters
  • a:
  • b:
atcp ()
Mudlet's support for ATCP. This is primarily available on IRE-based MUDs, but Mudlets impelementation is generic enough such that any it should work on others.

The latest ATCP data is stored in the atcp table. Whenever new data arrives, the previous is overwritten. An event is also raised for each ATCP message that arrives. To find out the available messages available in the atcp table and the event names, you can use display(atcp).

Note that while the typical message comes in the format of Module.Submodule, ie Char.Vitals or Room.Exits, in Mudlet the dot is removed - so it becomes CharVitals and RoomExits. Here's an example:
    room_number = tonumber(atcp.RoomNum)
    echo(room_number)
 
Triggering on ATCP events:
If you'd like to trigger on ATCP messages, then you need to create scripts to attach handlers to the ATCP messages. The ATCP handler names follow the same format as the atcp table - RoomNum, RoomExits, CharVitals and so on.

While the concept of handlers for events is to be explained elsewhere in the manual, the quick rundown is this - place the event name you'd like your script to listen to into the Add User Defined Event Handler: field and press the + button to register it. Next, because scripts in Mudlet can have multiple functions, you need to tell Mudlet which function should it call for you when your handler receives a message. You do that by setting the Script name: to the function name in the script you'd like to be called.

For example, if you'd like to listen to the RoomExits event and have it call the process_exits() function - register RoomExits as the event handler, make the script name be process_exits, and use this in the script:
    function process_exits(event, args)
        echo("Called event: " .. event .. "\nWith args: " .. args)
    end
 
Feel free to experiment with this to achieve the desired results. A ATCP demo package is also available on the forums for using event handlers and parsing its messages into Lua datastructures.

Release: Mudlet 1.0.6
See also:
getOS ()
Determine operating system.
Usage:
  •     if "linux" == getOS() then
     	     echo("We are using GNU/Linux!")
        end
     
Return value:
  • "linux", "mac" or "windows" string
io.exists (fileOfFolderName)
Checks to see if a given file or folder exists. If it exists, it'll return the Lua true boolean value, otherwise false.
Parameters
  • fileOfFolderName:
Usage:
  •     if io.exists("/home/user/Desktop") then
           echo("This folder exists!")
        else
           echo("This folder doesn't exist.")
        end
     
        if io.exists("/home/user/Desktop/file.txt") then
           echo("This file exists!")
        else
           echo("This file doesn't exist.")
        end
     
Return value:
  • true or false
loadVars ()
This function should be primarily used by Mudlet. It loads saved settings in from the Mudlet home directory and unpacks them into the global namespace.
See also:
openURL (url)
Opens the default OS browser for the given URL.
Parameters
  • url:
Usage:
  • Either command will open Mudlet home page.
        openUrl("www.mudlet.org")
        openUrl("http://www.mudlet.org/")
     
phpTable (...)
TODO phpTable(...) - abuse to: http://richard.warburton.it
Parameters
  • ...:
remember (varName)
This function flags a variable to be saved by Mudlet's variable persistence system. Variables are automatically unpacked into the global namespace when the profile is loaded. They are saved to "SavedVariables.lua" when the profile is closed or saved.
Parameters
  • varName:
Usage:
  • remember("varName")
See also:
saveVars ()
This function should primarily be used by Mudlet. It saves the contents of _saveTable into a file for persistence.
See also:
sendAll (..., echoTheValue)
Sends a list of commands to the MUD. You can use this to send some things at once instead of having to use multiple send() commands one after another.
Parameters
  • ...: list of commands
  • echoTheValue: optional boolean flag (default value is true) which determine if value should be echoed back on client.
Usage
  • Use sendAll instead of multiple send commands.
        sendAll("stand", "wield shield", "say ha!")
     
    Instead of calling:
        send ("stand")
        send ("wield shield")
        send ("say ha!")
     
  • Use sendAll and do not echo sent commnad on the main window.
        sendAll("stand", "wield shield", "say ha!", false)
     
See also:
speedwalk (dirString, backwards, delay)
TODO speedwalk(dirString, backwards, delay)
Parameters
  • dirString:
  • backwards:
  • delay:
speedwalktimer ()
TODO speedwalktimer()
table.load (sfile, loadinto)
Restores a Lua table from a data file that has been saved with table.save().
Parameters
  • sfile:
  • loadinto:
Usage
  • Loads a serialized file into the globals table (only Mudlet should use this).
        table.load(file)
     
  • Loads a serialized file into the given table.
        table.load(file, table)
     
See also:
table.pickle (t, file, tables, lookup)
TODO table.pickle( t, file, tables, lookup )
Parameters
  • t:
  • file:
  • tables:
  • lookup:
table.save (sfile, t)
The below functions (table.save, table.load) can be used to save individual Lua tables to disc and load them again at a later time e.g. make a database, collect statistical information etc. These functions are also used by Mudlet to load & save the entire Lua session variables.

Original code written by CHILLCODEā„¢ on https://board.ptokax.ch, distributed under the same terms as Lua itself.

Notes:
Userdata and indices of these are not saved
Functions are saved via string.dump, so make sure it has no upvalues
References are saved

Parameters
  • sfile:
  • t:
Usage
  • Saves the globals table (minus some lua enviroment stuffs) into a file (only Mudlet should use this).
        table.save(file)
     
  • Saves the given table into the given file.
        table.save(file, table)
     
See also:
table.unpickle (t, tables, tcopy, pickled)
TODO table.unpickle( t, tables, tcopy, pickled )
Parameters
  • t:
  • tables:
  • tcopy:
  • pickled:
walkdelay ()
TODO Variable walkdelay.
walklist ()
TODO Table walklist.
xor (a, b)
Implementation of boolean exclusive or.
Parameters
  • a:
  • b:
Usage:
  • All following will return false.
        xor(false, false)
        xor(true, true)
     
Return value:
  • true or false

Valid XHTML 1.0!