Module Globals

Pre-defined globals.

Note: this is not a real module. All names described here are defined in the global clua namespace.

Functions

dofile (filename) Load and execute the named luafile, returning the result.
loadfile (filename) Load the named lua file as a chunk.
pmatch (pat, s) Match a string with a pattern.
require (filename) Load and execute the named lua file.

Tables

options Named lua options.

Local Functions

c_macro (fn) Crawl macro framework for Lua.


Functions

dofile (filename)
Load and execute the named luafile, returning the result. Differs from require in that the file is run for a result. Errors come back on the lua stack and can be handled by the caller.

Parameters:

  • filename string

Returns:

    whatever is left on the lua stack by filename
loadfile (filename)
Load the named lua file as a chunk.

Parameters:

  • filename string

Returns:

    function chunk or nil,error
pmatch (pat, s)
Match a string with a pattern.

Parameters:

  • pat string the pattern
  • s string

Returns:

    boolean
require (filename)
Load and execute the named lua file. Differs from dofile in that the file is run for its side effects. If the execution has an error we raise that error and exit.

Parameters:

  • filename string

Returns:

    boolean or nil

Tables

options
Named lua options. To set options with the same processing as .crawlrc or init.txt, use crawl.setopt.

This table provides access to the following crawl options: autoswitch, easy_armour, easy_unequip, note_skill_max, clear_messages, blink_brightens_background, bold_brightens_foreground, best_effort_brighten_background, best_effort_brighten_foreground, allow_extended_colours, pickup_thrown, easy_exit_menu, dos_use_background_intensity, autopickup_on; documented in docs/options_guide.txt.

It can also be used for global configuration of clua extensions.

Local Functions

c_macro (fn)
Crawl macro framework for Lua. Macros are called as Lua coroutines. If the macro yields false, the coroutine is discarded (assuming an error). If the macro yields true, Crawl will start a macro delay for the macro and call the coroutine again next turn. If the macro just returns, the coroutine is assumed to be done.

Why coroutines: Macros may need to perform actions that take multiple turns, which requires control to return to Crawl to perform world updates between actions. Coroutines are the simplest way to pass control back and forth without losing the macro's state.

This is the internal crawl hook for executing a macro. If you would like to start one from clua use crawl.runmacro.

Parameters:

  • fn macro name
generated by LDoc 1.4.6 Last updated 2021-01-09 22:46:05