File Other.lua

-- Other -- --

Functions

SavedVariables:Add (tbl) SavedVariables:Add(tbl)
_comp (a, b) _comp(a, b)
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 (...) 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 (...) Sends a list of commands to the MUD.
speedwalk (dirString, backwards, delay) speedwalk(dirString, backwards, delay)
speedwalktimer () speedwalktimer()
table.load (sfile, loadinto) table.load( sfile, loadinto )
table.pickle (t, file, tables, lookup) table.pickle( t, file, tables, lookup )
table.save (sfile, t) Save & Load Variables
The below functions 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) table.unpickle( t, tables, tcopy, pickled )
xor (a, b) xor(a, b)


Functions

SavedVariables:Add (tbl)
SavedVariables:Add(tbl)

Parameters

  • tbl:
_comp (a, b)
_comp(a, b)

Parameters

  • a:
  • b:
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

  • openUrl("www.mudlet.org")
  • openUrl("http://www.mudlet.org/")
phpTable (...)
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 (...)
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

  • ...:

Usage:

  • Use sendAll instead of multiple send commnads.
        sendAll("stand", "wield shield", "say ha!")
        
        -- instead of:
        send ("stand")
        send ("wield shield")
        send ("say ha!")
     
speedwalk (dirString, backwards, delay)
speedwalk(dirString, backwards, delay)

Parameters

  • dirString:
  • backwards:
  • delay:
speedwalktimer ()
speedwalktimer()
table.load (sfile, loadinto)
table.load( sfile, loadinto )

Parameters

  • sfile:
  • loadinto:

See also:

table.pickle (t, file, tables, lookup)
table.pickle( t, file, tables, lookup )

Parameters

  • t:
  • file:
  • tables:
  • lookup:
table.save (sfile, t)
Save & Load Variables
The below functions 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

table.load(file) - loads a serialized file into the globals table (only Mudlet should use this)
table.load(file, table) - loads a serialized file into the given table
table.save(file) - saves the globals table (minus some lua enviroment stuffs) into a file (only Mudlet should use this)
table.save(file, table) - saves the given table into the given file

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:
table.unpickle (t, tables, tcopy, pickled)
table.unpickle( t, tables, tcopy, pickled )

Parameters

  • t:
  • tables:
  • tcopy:
  • pickled:
xor (a, b)
xor(a, b)

Parameters

  • a:
  • b:

Valid XHTML 1.0!