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. |
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
orinit.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 indocs/options_guide.txt
.It can also be used for global configuration of clua extensions.
Module
Hooks
Entry points crawl uses for calling into lua.
Crawl contacts clua through hooks. Hooks can be interacted with either by altering a hook table, defining certain functions, or the interface functions described here.
Note: This is not a real module. All names described here are in the global clua namespace.
Functions
add_autopickup_func (func) | Add an autopickup function. |
auto_experience () | Automatically distribute or accept potion of experience distributions. |
c_answer_prompt () | Answer a prompt. |
c_assign_invletter (the) | What letter should this item get? |
c_choose_acquirement () | Acquirement scroll hook. |
c_choose_coglin_gizmo () | Coglin gizmo hook. |
c_choose_okawaru_armour () | Okawaru armour acquirement hook. |
c_choose_okawaru_weapon () | Okawaru weapon acquirement hook. |
c_message (text, channel) | Receive a message from the message window. |
c_trap_is_safe (trapname) | Is this trap safe? |
ch_mon_is_safe (monster, is_safe, moving, dist) | Is this monster safe? |
ch_start_running (kind) | Pre runrest hook. |
ch_stop_running (kind) | Post runrest hook. |
ch_target_monster (x, y) | Do we want to target this monster? |
ch_target_monster_expl (x, y) | Do we want to target this monster for an explosion? |
ch_target_shadow_step (x, y) | Do we want to try to shadow step here? |
choose_stat_gain () | Choose a stat. |
clear_autopickup_funcs () | Clear the autopickup function table. |
opt_boolean (optname, default) | Define a boolean option. |
ready () | Start of turn hook. |
skill_training_needed () | Select skills for training. |
Tables
c_persist | Persistent data store. |
chk_interrupt_activity | Activity interrupt table. |
chk_interrupt_macro | Macro interrupt table. |
chk_lua_option | Lua option extension table Add lua processed options to options.txt. |
chk_lua_save | Save hooks. |
Fields
chk_ability_choice | Ability choice. |
chk_spell_choice | Spell choice. |
Functions
- add_autopickup_func (func)
-
Add an autopickup function.
Autopickup functions are passed an items.Item and an object name, and are
expected to return true for "yes pickup", false for "no do not". Any other
return means "no opinion".
Parameters:
- func autopickup function
- auto_experience ()
-
Automatically distribute or accept potion of experience distributions.
Called when presented with the skill menu after quaffing a potion of experience. Can use the skilling functions in you to change training.
Returns:
-
boolean
true for accept false to prompt user
- c_answer_prompt ()
-
Answer a prompt.
This hook can be defined to answer a yesno prompt automatically.
Returns:
-
boolean|nil true for yes, false for no, nil for pass
- c_assign_invletter (the)
-
What letter should this item get?
This hook can be re-defined to provide detailed customization. It will be ignored if it fails to return a free slot.
Parameters:
- the items.Item item being put into inventory
Returns:
-
int
free slot index to put the item in
See also:
- c_choose_acquirement ()
-
Acquirement scroll hook.
This hook can be defined to execute lua when an acquirement scroll is read.
The hook should call items.acquirement_items with an argument of 1 to get an array of items.Item representations of the offered items. If it returns a valid index in this array, the given item will be acquired without the usual acquirement menu.
Returns:
-
int
An index between 1 and the number of offered items.
- c_choose_coglin_gizmo ()
-
Coglin gizmo hook.
This hooks can be defined to execute lua when a coglin's Invent Gizmo ability is used.
The hook should call items.acquirement_items with an argument of 4 to get an array of items.Item representations of the offered items. If it returns a valid index in this array, the given item will be acquired without the usual acquirement menu.
Returns:
-
int
An index between 1 and the number of offered items.
- c_choose_okawaru_armour ()
-
Okawaru armour acquirement hook.
This hook can be defined to execute lua when Okawaru's Recieve Armour capstone ability is used.
The hook should call items.acquirement_items with an argument of 3 to get an array of items.Item representations of the offered items. If it returns a valid index in this array, the given item will be acquired without the usual acquirement menu.
Returns:
-
int
An index between 1 and the number of offered items.
- c_choose_okawaru_weapon ()
-
Okawaru weapon acquirement hook.
This hook can be defined to execute lua when Okawaru's Recieve Weapon capstone ability is used.
The hook should call items.acquirement_items with an argument of 2 to get an array of items.Item representations of the offered items. If it returns a valid index in this array, the given item will be acquired without the usual acquirement menu.
Returns:
-
int
An index between 1 and the number of offered items.
- c_message (text, channel)
-
Receive a message from the message window.
This hook can be re-defined to receive messages from the message window. It is called for each message after player configured mute settings are applied to the message.
Parameters:
- text string The message text
- channel string The message channel name
- c_trap_is_safe (trapname)
-
Is this trap safe?
This hook can be defined to extend trap safety checks.
Crawl will call this hook with the trap name when the player tries to move onto a tile with a trap. A failed check will result in the user being prompted if they try to move onto the trap.
Parameters:
- trapname string
Returns:
-
boolean
- ch_mon_is_safe (monster, is_safe, moving, dist)
-
Is this monster safe?
This hook can be defined to add extra safety checks or overrides. It is called when crawl wants to consider interrupting a repeat action because there are unsafe monsters around.
Parameters:
- monster monster.mon-info info
- is_safe boolean what crawl currently thinks about the monster
- moving boolean is this safe to move near
- dist int how far away is this monster
Returns:
-
boolean
is it safe?
- ch_start_running (kind)
-
Pre runrest hook.
This hook can be defined to execute lua when some form of rest or autotravel starts.
The parameter is what kind of running was just stopped, and has the following possible values:
- "travel" for autotravel (with XG or similar)
- "interlevel" for interlevel travel
- "explore" for autoexplore
- "explore_greedy" for autoexplore + item pickup
- "run" for a plain run (Shift+Dir)
- "" for a rest
Parameters:
- kind string
- ch_stop_running (kind)
-
Post runrest hook.
This hook can be defined to execute lua when some form of rest or autotravel stops.
The parameter is what kind of running was just stopped, and has the following possible values:
- "travel" for autotravel (with XG or similar)
- "interlevel" for interlevel travel
- "explore" for autoexplore
- "explore_greedy" for autoexplore + item pickup
- "run" for a plain run (Shift+Dir)
- "" for a rest
Parameters:
- kind string
- ch_target_monster (x, y)
-
Do we want to target this monster?
This hook can be re-defined to alter the auto-targeter.
Called by the targeter by each cell in sight, spiralling outward from the player, until a target is found, to set the default target Uses player centered coordinates.
Return true for yes, false for no, and nil for no opinion.
Parameters:
- x int
- y int
Returns:
-
boolean
or
nil
- ch_target_monster_expl (x, y)
-
Do we want to target this monster for an explosion?
This hook can be re-defined to alter the auto-targeter.
Called by the explosion targeter by each cell in sight, spiralling outward from the player, until a target is found, to set the default target Uses player centered coordinates.
Return true for yes, false for no, and nil for no opinion.
Parameters:
- x int
- y int
Returns:
-
boolean
or
nil
- ch_target_shadow_step (x, y)
-
Do we want to try to shadow step here?
This hook can be re-defined to alter the auto-targeter.
Called by the targeter by each cell in sight, spiralling outward from the player, until a target is found, to set the default target Uses player centered coordinates. If this function has no opinion ch_target_monster is called in fall-through.
Return true for yes, false for no, and nil for no opinion.
Parameters:
- x int
- y int
Returns:
-
boolean
or
nil
- choose_stat_gain ()
-
Choose a stat.
This hook can be defined to answer the stat choice prompt automatically.
Called on levelup to prompt for a stat choice. Returns a string with the stat choice.
Returns:
-
string
stat choice
- clear_autopickup_funcs ()
- Clear the autopickup function table.
- opt_boolean (optname, default)
-
Define a boolean option.
Convenience function for use with
chk_lua_option
.
Parameters:
- optname
- default
Usage:
chk_lua_option["myboolopt"] = opt_boolean
- ready ()
-
Start of turn hook.
This hook can be defined to provide start of turn checks.
Crawl calls this function at the start of each turn if there are no remaining command repeats, macros, delays, or inputs in the buffer. This is done before reading new input.
- skill_training_needed ()
-
Select skills for training.
Called when no skills are currently selected for training. Can use the skilling functions in you to change training. Will prompt the user if this function fails to select skills for training.
Returns:
-
boolean
true to accept the skilling, false to prompt the user
Tables
- c_persist
-
Persistent data store.
Data placed in this table will automatically persist through saves and
deaths. See
persist.lua
for the internal details of how this is done. - chk_interrupt_activity
- Activity interrupt table. Maps activity names to interrupt functions When crawl needs to interrupt an internal delay it looks up the delay by name in this table and if a function is present, calls it with the parameters name, cause, and extra. The function returns true to interrupt, false to express no opinion, and nil for "don't interrupt". Return nil only if you really know what you're doing.
- chk_interrupt_macro
- Macro interrupt table. Maps macro names to interrupt handling functions. When crawl needs to interrupt a macro it calls this function with the parameters name, cause, and extra. The function returns true if the macro was interrupted
- chk_lua_option
-
Lua option extension table
Add lua processed options to options.txt.
Keys are treated as option names.
Value should be a function that takes parameters key, value, and mode.
When processing an option defined in this way crawl will call the
corresponding function with value the string that is on the other side of
the equals sign and one of the following mode values describing the
assignment type:
-
0 for
=
-
1 for
+=
-
-1 for
-=
-
2 for
^=
The global table Globals.options is provided as a target store for these options.
See also:
-
0 for
- chk_lua_save
- Save hooks. Push into this table, rather than indexing into it. A list of functions which get called when saving. They are expected to return strings of lua that will be executed on load. Data saved with this method is associated with the character save and will be lost on death. For permanent storage see c_persist .
Fields
- chk_ability_choice
-
Ability choice.
This variable can be set by lua before the user is shown the "Activate which ability?" prompt. If set to a valid ability letter that ability will be activated without prompting the user. Otherwise the ability prompt proceeds as normal.
This value is cleared after every ability activation.
The current table mapping letters to abilities can be accessed with the you.ability_table function.
- chk_spell_choice
-
Spell choice.
This variable can be set by lua before the user is shown the "Cast which spell?" prompt. If set to a valid spell letter that will be selected without prompting the user. Execution passes to targeting, which can be handled either through the lua system or by the user.
The current table mapping letters to spells can be accessed with the you.spell_table function.
Module
crawl
General crawl related functions, including interaction.
Functions
article_a (s[, lowercase=true]) | Correctly attach the article 'a'. |
c_input_line () | Cancellably prompt the user for a line of input. |
call_dlua (chunk) | Call lua in dungeon (dlua) context. |
clear_messages (force) | Clear the message window. |
coinflip () | Flip a coin. |
delay (ms) | Delay the display. |
div_rand_round (numerator, denominator) | Random-round integer division. |
do_commands (commands[, hide=false]) | Execute a sequence of named crawl commands The array must be the command names as they appear in cmd-name.h, they are processed in order by the macro internal command buffer. |
do_targeted_command (command[, x=0[, y=0[, if=false]]]) | Handle any command that takes a target and no other parameters. |
dpr (text) | Print to the debugging channel, which is desplayed only for debug builds. |
dump_char () | Produce a character dump |
enable_more (flag) |
Toggle the use of
--- more ---
prompts.
|
err_trace (function, args) | Lua error trace a call Attempts to call-trace a lua function that is producing an error. |
flush_input () | Flush the input buffer (typeahead). |
flush_prev_message () | Flush the previous message to the window. |
formatted_mpr (message, channel) | Print a formatted message. |
game_started () | Has the game started? |
get_command (name) | Look up the current key bound to a command. |
get_target () | Prompt the user to choose a location via the targeting screen. |
getch () | Get input key (combo). |
grammar (what[, how="plain"]) | Grammatically describe something. |
is_tiles () | Are we running under tiles? |
is_webtiles () | Are we running under webtiles? |
kbhit () | Check for pending input. |
message (message, channel) | A wrapper for the low-level sequence of commands needed to produce message output. |
message_filter (pat[, ch=-1]) | Create a message filter |
messages (num) | Retrieve the message buffer. |
more () |
Display a
--- more ---
prompt
|
mpr (message, channel) | Print a message. |
msgch_name (num) | Get the name of a message channel. |
msgch_num (name) | Get the number of a message channel. |
one_chance_in (in) | Perform a weighted coinflip. |
playsound (sf) | Play a sound. |
process_command () | Tell crawl to process a current macro delay. |
process_keys (keys[, hide=false]) | Process a string of input keys The first key of the first argument must be a command key in the default key context. |
random2 (max) | Return a random number from [0, max). |
random2avg (max, num) | Average num random rolls from [0, max). |
random_range (min, max[, rolls=1]) | Random number in a range. |
random_real () | A random floating point number in [0,1.0) |
read_options (filename) | Read options from file. |
redraw_screen () | Redraw the screen. |
regex (pat) | Compile a regular expression |
roll_dice ([num_dice=1], sides) | Roll dice. |
runmacro (macroname) | Run a macro. |
seen_hups () | Whether the crawl process has seen a HUP or INT signal. |
sendkeys (keys[, ...]) | Send keypresses to crawl. |
set_more_autoclear (flag) |
Toggle autoclearing of
--- more ---
prompts.
|
set_sendkeys_errors (param) | Enable or disable crashing on an incomplete buffer. |
setopt (opt) | Set user options from string. |
simplex (x, y[, z[, w]]) | 2D-4D Simplex noise. |
split (s, split) | Split a string at a token. |
split_bytes (num) | Splits a 32-bit integer into four bytes. |
stack ([A]) | Returns a string representation of the stack of either the current clua state or that of a coroutine. |
stat_gain_prompt () | Is crawl asking us to choose a stat? |
stderr (text) | Print to stderr for debugging hooks. |
string_compare (s1, s2) | Compare two strings in a locale-independent way. |
take_note (note) | Make a note. |
trim (s) | Trim newlines and trailing whitespace. |
version ([fmt="long"]) | Get the crawl version The optional argument is a string from "long", "major", or "short" to determine which version type to return. |
weapon_check () | Check if the player really wants to use their weapon. |
worley (px, py, pz) | Get the full Worley noise datum for a given point |
worley_diff (px, py, pz) | Difference between nearest point Worley distances. |
x_chance_in_y (x, y) | Do a random draw. |
yesno (prompt, safe[, safeanswer[, clear_after=true[, interrupt_delays=true[, noprompt=false]]]]) | Ask the player a yes/no question. |
dlua
args () | Get the commandline arguments |
god_speaks (Name, Speech) | Divine voices. |
make_name () | Make an item name at random. |
milestone (type, milestone, origin) | Mark a milestone Register a dgl milestone. |
millis () | Current milliseconds. |
redraw_stats () | Redraw the player stats. |
redraw_view () | Redraw the viewwindow. |
set_max_runes (nrune) | Set Max Runes Modify the total number of obtainable runes. |
unavailable_god (godname) | Check if a god is still available. |
Class Regex
Regex:equals (pat) | Test equality Tests if the two lua variables are the same underlying compiled pattern |
Regex:find (s) | Test against a string. |
Class MessageFilter
MessageFilter:equals (pat) | Test equality Tests if the two lua variables are the same underlying compiled pattern |
MessageFilter:matches (msg, ch) | Check a message against a filter. |
Functions
- article_a (s[, lowercase=true])
-
Correctly attach the article 'a'.
Parameters:
- s string
- lowercase bool ( default true)
Returns:
-
string
- c_input_line ()
-
Cancellably prompt the user for a line of input.
The line is limited to 500 characters.
Returns:
-
string
or
nil
a string if one is input or nil if input is cancelled
- call_dlua (chunk)
-
Call lua in dungeon (dlua) context.
Parameters:
- chunk string code run
Returns:
-
a scalar return value from dlua context
- clear_messages (force)
-
Clear the message window.
Parameters:
- force boolean
- coinflip ()
-
Flip a coin.
Returns:
-
boolean
- delay (ms)
-
Delay the display.
Parameters:
- ms int delay in milliseconds
- div_rand_round (numerator, denominator)
-
Random-round integer division.
Parameters:
- numerator int
- denominator int
Returns:
-
int
- do_commands (commands[, hide=false])
-
Execute a sequence of named crawl commands
The array must be the command names as they appear in cmd-name.h, they are
processed in order by the macro internal command buffer. The input buffer is
flushed before execution.
Parameters:
- commands array
- hide boolean hide targeter while processing ( default false)
- do_targeted_command (command[, x=0[, y=0[, if=false]]])
-
Handle any command that takes a target and no other parameters. This includes
CMD
PRIMARY
ATTACK, and CMD_FIRE. If the target
coordinates are out of bounds (the default), this enters interactive
targeting.
Parameters:
- command string name
- x number coordinate ( default 0)
- y number coordinate ( default 0)
- if boolean true, aim at the target; if false, shoot past it ( default false)
Returns:
-
boolean
whether an action took place
- dpr (text)
-
Print to the debugging channel, which is desplayed only for debug builds.
Parameters:
- text string
- dump_char ()
- Produce a character dump
- enable_more (flag)
-
Toggle the use of
--- more ---
prompts.Parameters:
- flag boolean
- err_trace (function, args)
-
Lua error trace a call
Attempts to call-trace a lua function that is producing an error.
Returns normally if the function runs normally, otherwise sends
Parameters:
- function
- args
Returns:
-
the result of the call if successful
- flush_input ()
- Flush the input buffer (typeahead).
- flush_prev_message ()
- Flush the previous message to the window.
- formatted_mpr (message, channel)
-
Print a formatted message.
Parameters:
- message string message to print
-
channel
channel to print on; defaults to 0 (
MSGCH_PLAIN
)
- game_started ()
-
Has the game started?
Returns:
-
boolean
- get_command (name)
-
Look up the current key bound to a command.
Parameters:
- name string Name as in cmd-name.h
Returns:
-
string
or
nil
- get_target ()
-
Prompt the user to choose a location via the targeting screen.
This is useful for scripts that require a user-selected target. For example,
one could imagine a "mark dangerous monster" script that would place a large
exclusion around a user-chosen monster that would then be deleted if the
monster moved or died. This function could be used for the user to select
a target monster.
Returns:
-
int,
int the relative position of the chosen location to the user
- getch ()
-
Get input key (combo).
Returns:
-
int
the key (combo) input
- grammar (what[, how="plain"])
-
Grammatically describe something.
Crawl provides the following description types:
- "plain": just give the name
- "the": use the definite article
- "a": use the indefinite article
- "your": use the second person possessive
- "its": use the third person possessive
- "worn": how it is equipped
- "inv": describe something carried
- "none": return the empty string
And some specific types for partial item naming:
- "base": base name of the item subtype
- "qualname": name without articles, quantities, or enchantments
These are used as the allowable values for how.
Parameters:
- what string thing to describe
- how string crawl description type ( default "plain")
Returns:
-
string
grammatical description
- is_tiles ()
-
Are we running under tiles?
Returns:
-
boolean
- is_webtiles ()
-
Are we running under webtiles?
Note: returns true if the crawl binary is a webtiles build, even if the
player is currently using console.
Returns:
-
boolean
- kbhit ()
-
Check for pending input.
Returns:
-
int 1 if there is, 0 otherwise
- message (message, channel)
-
A wrapper for the low-level sequence of commands needed to produce
message output.
Parameters:
- message string
- channel int message channel number
See also:
- message_filter (pat[, ch=-1])
-
Create a message filter
Parameters:
- pat string filter pattern
- ch int channel number, -1 for anu ( default -1)
Returns:
-
MessageFilter
or
nil
- messages (num)
-
Retrieve the message buffer.
See also Hooks.c_message for programmatically receiving messages as they are sent.
Parameters:
- num int how many lines back to go
Returns:
-
string
- more ()
-
Display a
--- more ---
prompt - mpr (message, channel)
-
Print a message.
Parameters:
- message string message to print
-
channel
channel to print on; defaults to 0 (
MSGCH_PLAIN
)
- msgch_name (num)
-
Get the name of a message channel.
Parameters:
- num int channel number
Returns:
-
string
channel name
- msgch_num (name)
-
Get the number of a message channel.
Parameters:
- name string channel name
Returns:
-
int
channel number
- one_chance_in (in)
-
Perform a weighted coinflip.
Parameters:
- in int
Returns:
-
boolean
- playsound (sf)
-
Play a sound.
Only available when crawl is compiled with sound.
Parameters:
- sf string filename of sound to play
- process_command ()
-
Tell crawl to process a current macro delay.
Returns:
-
boolean whether it will actually do so
- process_keys (keys[, hide=false])
-
Process a string of input keys
The first key of the first argument must be a command key in the default key
context. The subsequent keys are processed as in sendkeys().
Parameters:
- keys string
- hide boolean hide targeter while processing ( default false)
- random2 (max)
-
Return a random number from [0, max).
Parameters:
- max int
Returns:
-
int
- random2avg (max, num)
-
Average num random rolls from [0, max).
Parameters:
- max int
- num int
Returns:
-
int
- random_range (min, max[, rolls=1])
-
Random number in a range.
Parameters:
- min int
- max int
- rolls int Average over multiple rolls ( default 1)
- random_real ()
-
A random floating point number in [0,1.0)
Returns:
-
number
- read_options (filename)
-
Read options from file.
Parameters:
- filename string name of file to read from
- redraw_screen ()
- Redraw the screen.
- regex (pat)
-
Compile a regular expression
Parameters:
- pat string the pattern string (PCRE)
Returns:
-
Regex
or
nil
- roll_dice ([num_dice=1], sides)
-
Roll dice.
Parameters:
- num_dice int ( default 1)
- sides int
Returns:
-
int
- runmacro (macroname)
-
Run a macro.
Parameters:
- macroname string name of macro to run
- seen_hups ()
-
Whether the crawl process has seen a HUP or INT signal.
Returns:
-
int
the number of hups seen
- sendkeys (keys[, ...])
-
Send keypresses to crawl.
A flexible variadic function to send input to crawl. Will process any number
of arguments. Each argument can be a string, keycode number, or array of the
previous two types. They are processed in left-to-right order.
Parameters:
- keys string , int or array
- ... ( optional )
- set_more_autoclear (flag)
-
Toggle autoclearing of
--- more ---
prompts.Parameters:
- flag boolean
- set_sendkeys_errors (param)
-
Enable or disable crashing on an incomplete buffer.
Used for tests, not generally useful in real life. Crashing only happens in
wizmode.
Parameters:
- param boolean
- setopt (opt)
-
Set user options from string.
Parameters:
- opt string an option string in the same format as init.txt / .crawlrc
- simplex (x, y[, z[, w]])
-
2D-4D Simplex noise.
The first two parameters are required for 2D noise, the next two are
optional for and specify 3D or 4D, respectively.
Parameters:
- x number
- y number
- z number ( optional )
- w number ( optional )
Returns:
-
number
- split (s, split)
-
Split a string at a token.
Parameters:
- s string
- split string
Returns:
-
{string,...}
- split_bytes (num)
-
Splits a 32-bit integer into four bytes.
This is useful in conjunction with worley ids to get four random numbers
instead of one from the current node id.
Parameters:
- num int
Returns:
- byte
- byte
- byte
- byte
- stack ([A])
-
Returns a string representation of the stack of either the current clua
state or that of a coroutine. This is useful for debugging clua code.
Parameters:
- A coroutine coroutine to analyze instead of the current clua state. ( optional )
Returns:
-
string
The stack trace
- stat_gain_prompt ()
-
Is crawl asking us to choose a stat?
Returns:
-
boolean
- stderr (text)
-
Print to stderr for debugging hooks.
Parameters:
- text string
- string_compare (s1, s2)
-
Compare two strings in a locale-independent way.
Lua's built in comparison operations for strings are dependent on locale,
which isn't always desirable. This is just a wrapper on
std::basic_string::compare.
Parameters:
- s1 string the first string.
- s2 string the second string.
Returns:
-
number
-1 if s1 < s2, 1 if s2 < s1, 0 if s1 == s2.
- take_note (note)
-
Make a note.
Parameters:
- note string
- trim (s)
-
Trim newlines and trailing whitespace.
Parameters:
- s string
Returns:
-
string
- version ([fmt="long"])
-
Get the crawl version
The optional argument is a string from "long", "major", or "short" to
determine which version type to return. The argument * check is
case-insensitive.
Parameters:
- fmt string ( default "long")
Returns:
-
string
- weapon_check ()
-
Check if the player really wants to use their weapon.
Returns:
-
boolean
- worley (px, py, pz)
-
Get the full Worley noise datum for a given point
Parameters:
- px number
- py number
- pz number
Returns:
- number distance1
- number distance2
- number id1
- number id2
- number id1
- number pos1x
- number pos1y
- number pos1z
- number pos2x
- number pos2y
- number pos2z
- worley_diff (px, py, pz)
-
Difference between nearest point Worley distances.
Parameters:
- px number
- py number
- pz number
Returns:
- number diff
- number id1
- x_chance_in_y (x, y)
-
Do a random draw.
Parameters:
- x int
- y int
Returns:
-
boolean
- yesno (prompt, safe[, safeanswer[, clear_after=true[, interrupt_delays=true[, noprompt=false]]]])
-
Ask the player a yes/no question.
The player is supposed to answer by pressing Y or N.
Parameters:
- prompt string question for the user
- safe boolean accept lowercase answers
- safeanswer string or nil if a letter, this will be considered a safe default ( optional )
- clear_after boolean clear the question after the user answers ( default true)
- interrupt_delays boolean interrupt any ongoing delays to ask the question ( default true)
- noprompt boolean skip asking the question; just wait for the answer ( default false)
dlua
- args ()
-
Get the commandline arguments
Returns:
-
table
- god_speaks (Name, Speech)
-
Divine voices.
Parameters:
- Name string of a current crawl god.
- Speech string
- make_name ()
-
Make an item name at random.
Returns:
-
string
- milestone (type, milestone, origin)
-
Mark a milestone
Register a dgl milestone. No op if not a dgl game.
Parameters:
- type string
- milestone string
- origin string
- millis ()
-
Current milliseconds.
Gives the current milliseconds of the time of day.
Returns:
-
int
- redraw_stats ()
- Redraw the player stats. You probably want redraw_screen unless you specifically want only the player stats.
- redraw_view ()
- Redraw the viewwindow. You probably want redraw_screen unless you specifically want only the view window.
- set_max_runes (nrune)
-
Set Max Runes
Modify the total number of obtainable runes.
Parameters:
- nrune int
- unavailable_god (godname)
-
Check if a god is still available.
For gods that are no longer appearing in new games, and Jiyva if its been
killed by the player.
Parameters:
- godname string
Returns:
-
boolean
Class Regex
- Regex:equals (pat)
-
Test equality
Tests if the two lua variables are the same underlying compiled pattern
Parameters:
- pat regex
Returns:
-
boolean
- Regex:find (s)
-
Test against a string.
Returns nil if the pattern object does not exist or if a non-string is
passed.
Parameters:
- s string
Returns:
-
boolean
or
nil
Class MessageFilter
- MessageFilter:equals (pat)
-
Test equality
Tests if the two lua variables are the same underlying compiled pattern
Parameters:
- pat regex
Returns:
-
boolean
- MessageFilter:matches (msg, ch)
-
Check a message against a filter.
Parameters:
- msg string
- ch int message channel
Returns:
-
boolean
Module
items
Item handling functions and type.
Functions
acquirement_items (An) | See the items offered by acquirement. |
equipped_at (Slot, Index) | Get the Item in a given equipment slot. |
fire (the[, x=0[, y=0[, if=false[, whether=false]]]]) | Fire an item in inventory at a target, either an evokable or a throwable ammo. |
fired_item () | Get the ammo Item we should fire by default. |
get_items_at (x, y) | List the seen items at a grid cell. |
index_to_letter (idx) | Get the inventory letter of a slot number. |
inslot (idx) | What item is in this slot? |
inventory () | Get the current inventory. |
letter_to_index (let) | Get the index of an inventory letter. |
pickup (what[, qty]) | Pick up items. |
shop_inventory () | See what a shop has for sale. |
shopping_list () | Look at the shopping list. |
slot_is_available (Slot) | Checks whether a given player equipment slot (or an alternative) is available to equip something in. |
swap_slots (idx1, idx2) | Swap item slots. |
Class Item
item.ac | Item base AC. |
item.accuracy | Item base accuracy. |
item.artefact | Is this an artefact? |
item.artprops |
Artefact properties
Full list in
artefact-prop-type.h
|
item.branded | Is this branded? |
item.cursed | Is this item cursed? |
item.damage | Item base damage. |
item.delay | Item base delay. |
item.description | Item description string, as displayed in the game UI. |
item.dropped | Did we drop this? |
item.encumbrance | Item encumbrance rating. |
item.equip_type | The default slot type this item goes in. |
item.equipped | Is this equipped? |
item.evoke_damage | Item evoke damage. |
item.god_gift | Is this a god gift? |
item.ininventory | Is this item in the inventory? |
item.inscription | Item inscription string. |
item.is_corpse | Is this a corpse? |
item.is_enchantable | Is this item enchantable? |
item.is_identified | Is this fully identified? |
item.is_in_shop | Item is for sale. |
item.is_melded | Is this item currently melded to us? |
item.is_ranged | Is this a ranged weapon? |
item.is_throwable | Can this be thrown effectively? |
item.is_useless | Is this useless? |
item.is_weapon | Is this item a weapon? |
item.is_xp_evoker | Is this an elemental evoker? |
item.plus | Item plus. |
item.quantity | How many do we have in a stack? |
item.reach_range | The reach range of this item. |
item.slot | This item's inventory slot. |
item.spells | What spells are in this? |
item.weap_skill | The weapon skill this item requires. |
item:class ([terse=false]) | What is the item class? |
item:damage_rating () | Item damage rating. |
item:drop ([qty]) | Drop this. |
item:ego ([terse=false]) | What is the ego? |
item:equip () | Equip this item. |
item:inscribe ([inscription=""[, append=true]]) | Edit this item's inscription. |
item:name ([desc="plain"[, terse="false"]]) | Get this item's name. |
item:name_coloured ([desc="plain"[, terse="false"]]) | Get this item's name as a colour-formatted string. |
item:remove () | Remove this item from our body. |
item:subtype () | What is the subtype? |
Functions
- acquirement_items (An)
-
See the items offered by acquirement.
Only works when the acquirement menu is active.
Parameters:
-
An
int
integer indicating the type of acquirement:
1: The normal acquirement menu. 2: Okawaru weapon gift acquirement. 3: Okawaru armour gift acquirement. 4: Coglin gizmo acquirement.
Returns:
-
array
or
nil
An array of
Item
objects or nil if not acquiring.
-
An
int
- equipped_at (Slot, Index)
-
Get the Item in a given equipment slot.
Takes either a slot name or a slot number.
Parameters:
- Slot string or int type name or index
- Index int[opt] of item in that slot type (ie: ring #2). Default 1.
Returns:
-
Item
or
nil
returns nil for nothing equipped or invalid slot
- fire (the[, x=0[, y=0[, if=false[, whether=false]]]])
-
Fire an item in inventory at a target, either an evokable or a throwable
ammo. This will work for launcher ammo, but only if the launcher is wielded.
Some evokables (e.g. artefact weapons) may also need to be wielded.
Parameters:
- the number item's slot
- x number coordinate ( default 0)
- y number coordinate ( default 0)
- if boolean true, aim at the target; if false, shoot past it ( default false)
- whether boolean to allow fumble throwing of non-activatable items ( default false)
Returns:
-
boolean
whether an action took place
- fired_item ()
-
Get the ammo Item we should fire by default.
Returns:
-
Item
or
nil
returns nil if something other than ammo is quivered
- get_items_at (x, y)
-
List the seen items at a grid cell.
This function uses player centered coordinates.
Parameters:
- x int
- y int
Returns:
-
array
An array of
Item
objects
- index_to_letter (idx)
-
Get the inventory letter of a slot number.
Parameters:
- idx int
Returns:
-
string
- inslot (idx)
-
What item is in this slot?
Uses numeric slot index, use
letter_to_index
to look up the index from
the number.
Parameters:
- idx int slot index
Returns:
-
Item
or
nil
the item in that slot, nil if none
- inventory ()
-
Get the current inventory.
Returns:
-
array
An array of
Item
objects for the current inventory
- letter_to_index (let)
-
Get the index of an inventory letter.
Parameters:
- let string
Returns:
-
int
- pickup (what[, qty])
-
Pick up items.
Accepts either a single Item object, and optionally a quantity (for picking
up part of a stack), defaulting to the whole stack, or a table of (Item,qty)
pairs.
In the first usage returns how many of the single Item were picked up. In the second usage returns how many keys were successfully picked up.
Parameters:
- what Item or table
- qty int how many; defaults to the whole stack ( optional )
Returns:
-
int
- shop_inventory ()
-
See what a shop has for sale.
Only works when standing at a shop.
Returns:
-
array
or
nil
An array of
Item
objects or nil if not on a shop
- shopping_list ()
-
Look at the shopping list.
Returns:
-
array
or
nil
Array of
Item
s on the shopping list or nil if the
shopping list is empty
- slot_is_available (Slot)
-
Checks whether a given player equipment slot (or an alternative) is
available to equip something in. Takes either a slot name or a slot number.
Parameters:
- Slot string or int type name or index
Returns:
-
returns
true if there is room to equip another item of this slot
type (including equivalent slots), false otherwise.
- swap_slots (idx1, idx2)
-
Swap item slots.
Requires item indexes, use
letter_to_index
if you want to swap letters.
Parameters:
- idx1 int
- idx2 int
Class Item
- item.ac
-
Item base AC.
- ac int
- item.accuracy
-
Item base accuracy.
- accuracy int
- item.artefact
-
Is this an artefact?
- artefact boolean
- item.artprops
-
Artefact properties
Full list in
artefact-prop-type.h
- artprops table artefact property table
- item.branded
-
Is this branded?
- branded
- item.cursed
-
Is this item cursed?
- cursed boolean
- item.damage
-
Item base damage.
- damage int
- item.delay
-
Item base delay.
- delay int
- item.description
-
Item description string, as displayed in the game UI.
- description string
- item.dropped
-
Did we drop this?
- dropped boolean
- item.encumbrance
-
Item encumbrance rating.
- encumbrance int
- item.equip_type
-
The default slot type this item goes in.
- equip_type int
- item.equipped
-
Is this equipped?
- equipped boolean
- item.evoke_damage
-
Item evoke damage.
- evoke_damage string The evokable item's damage string.
- item.god_gift
-
Is this a god gift?
- god_gift boolean
- item.ininventory
-
Is this item in the inventory?
- ininventory boolean
- item.inscription
-
Item inscription string.
- inscription string
- item.is_corpse
-
Is this a corpse?
- is_corpse boolean
- item.is_enchantable
-
Is this item enchantable?
- is_enchantable boolean
- item.is_identified
-
Is this fully identified?
- is_identified boolean
- item.is_in_shop
-
Item is for sale.
- is_in_shop boolean
- item.is_melded
-
Is this item currently melded to us?
- is_melded boolean
- item.is_ranged
-
Is this a ranged weapon?
- is_ranged boolean
- item.is_throwable
-
Can this be thrown effectively?
- is_throwable boolean
- item.is_useless
-
Is this useless?
- is_useless boolean
- item.is_weapon
-
Is this item a weapon?
- is_weapon boolean
- item.is_xp_evoker
-
Is this an elemental evoker?
- is_xp_evoker boolean
- item.plus
-
Item plus.
- plus int
- item.quantity
-
How many do we have in a stack?
- quantity int
- item.reach_range
-
The reach range of this item.
- reach_range int
- item.slot
-
This item's inventory slot.
- slot index or nil
- item.spells
-
What spells are in this?
- spells array of spell names
- item.weap_skill
-
The weapon skill this item requires.
- weap_skill string|nil nil for non-weapons
- item:class ([terse=false])
-
What is the item class?
Parameters:
- terse boolean ( default false)
Returns:
-
string
- item:damage_rating ()
-
Item damage rating.
Returns:
- number The item's damage rating.
- string The item's full damage rating string.
- item:drop ([qty])
-
Drop this.
Optionally specify how many for partially dropping a stack.
Parameters:
- qty int ( optional )
Returns:
-
boolean
successfully dropped
- item:ego ([terse=false])
-
What is the ego?
Parameters:
- terse boolean ( default false)
Returns:
-
string
or
nil
the item's ego, if any
- item:equip ()
-
Equip this item.
Returns:
-
boolean
successfully equipped
- item:inscribe ([inscription=""[, append=true]])
-
Edit this item's inscription.
Parameters:
- inscription string to add ( default "")
- append boolean to existing inscription; if false, replace ( default true)
Returns:
-
boolean
successfully inscribed
- item:name ([desc="plain"[, terse="false"]])
-
Get this item's name.
For the levels of item descriptions see
crawl.grammar
Parameters:
- desc string description type ( default "plain")
- terse boolean ( default "false")
Returns:
-
string
- item:name_coloured ([desc="plain"[, terse="false"]])
-
Get this item's name as a colour-formatted string.
Adds item colouring suitable for
crawl.formatted_mpr
.
Parameters:
- desc string description type ( default "plain")
- terse boolean ( default "false")
Returns:
-
string
- item:remove ()
-
Remove this item from our body.
Returns:
-
boolean
or
nil
successfully removed something; nil if nothing to
remove
- item:subtype ()
-
What is the subtype?
Returns:
-
string
or
nil
the item's subtype, if any
Module
monster
Monster information.
Functions
get_monster_at (x, y) | Get information about a monster at a cell. |
Class monster.info
monster.info:ac () | The monster's AC value, in "pips" (number of +'s shown on its description). |
monster.info:attitude () | The monster's current attitude. |
monster.info:avg_local_depth () | Get the monster's average depth of (random) generation in the current branch Returns -1 if the monster is not generated in this branch. |
monster.info:avg_local_prob () | Get the monster's probability of randomly generating on the current floor This can be used to estimate difficulty, but keep in mind that it is highly dependent on the branch's generation table. |
monster.info:base_type () | Monster base type as in monster_type.h. |
monster.info:can_be_constricted () | Can this monster be constricted? |
monster.info:can_go_frenzy () | Can the monster currently be frenzied? |
monster.info:can_traverse (x, y) | Can this monster traverse a particular cell? |
monster.info:can_use_doors () | Can this monster use doors? |
monster.info:colour () | Monster glyph colour. |
monster.info:damage_desc () | Get a string describing how injured this monster is. |
monster.info:damage_level () | How hurt is this monster? |
monster.info:defeat_wl (spell[, true]) | Your probability of defeating the monster's WL with a given spell or zap. |
monster.info:desc ([set]) | A description of this monster. |
monster.info:ev () | The monster's EV value, in "pips" (number of +'s shown on its description). |
monster.info:flags () | Get the monster's flags. |
monster.info:has_ranged_attack () | Does this monster have a ranged attack we know about? |
monster.info:holiness ([holiness]) | Get the monster's holiness. |
monster.info:intelligence () | Get the monster's intelligence. |
monster.info:is (flagname) | Test a monster flag. |
monster.info:is_caught () | Is the monster caught in something? |
monster.info:is_constricted () | Is the monster constricted? |
monster.info:is_constricting () | Is the monster constricting something? |
monster.info:is_constricting_you () | Is the monster constricting you in particular? |
monster.info:is_firewood () | Is this monster firewood. |
monster.info:is_safe () | Is this monster safe by default? |
monster.info:is_stationary () | Can this monster move? |
monster.info:is_unique () | Is this monster a unique? |
monster.info:items () | Returns the monster's items as an array of items. |
monster.info:max_hp () | The monster's max HP given in its description. |
monster.info:mname () | Simple monster name. |
monster.info:name () | The monster's full name. |
monster.info:number () | Monster number field. |
monster.info:pos () | The x,y coordinates of the monster in player centered coordinates. |
monster.info:range () | What's the monster's maximum range with a weapon, spell, or wand? |
monster.info:reach_range () | How far can the monster reach with their melee weapon? |
monster.info:res_cold () | Does the monster resist cold? |
monster.info:res_corr () | Does the monster resist corrosion? |
monster.info:res_draining () | Does the monster resist negative energy? |
monster.info:res_fire () | Does the monster resist fire? |
monster.info:res_shock () | Does the monster resist electricity? |
monster.info:speed_description () | A string describing monster speed. |
monster.info:spells () | Get the monster's spells. |
monster.info:stabbability () | What quality of stab can you get on this monster? |
monster.info:status ([statusname]) | What statuses is this monster under? |
monster.info:target_desc () | The string displayed if you target this monster. |
monster.info:target_evoke (object) | Returns the string displayed if you target this monster with an evocable. |
monster.info:target_spell (spell) | Returns the string displayed if you target this monster with a spell. |
monster.info:target_throw (object) | Returns the string displayed if you target this monster with a thrown item. |
monster.info:target_weapon () | Returns the string displayed in xv for your current weapon hit chance. |
monster.info:threat () | The monster's threat level. |
monster.info:type () | Monster type enum value as in monster_type.h. |
monster.info:type () | The last turn the monster was seen at this location. |
monster.info:wl () | The monster's WL level, in "pips" (number of +'s shown on its description). |
monster.info:x_pos () | The monster's x coordinate in player centered coordinates. |
monster.info:y_pos () | The monster's y coordinate in player centered coordinates. |
Functions
- get_monster_at (x, y)
-
Get information about a monster at a cell.
Returns a monster.info object of a monster at the specified coordinates.
Uses player coordinates
Parameters:
- x int
- y int
Returns:
-
monster.info
or
nil
Class monster.info
- monster.info:ac ()
-
The monster's AC value, in "pips" (number of +'s shown on its description).
Returns a value ranging from 0 to 5 (highest).
Returns:
-
int
AC level
- monster.info:attitude ()
-
The monster's current attitude. A numerical value representing the monster's attitude. Possible values:
- 0 hostile
- 1 neutral
- 2 strict neutral (neutral but won't attack the player)
- 3 good neutral (neutral but won't attack friendlies)
- 4 friendly (created friendly, not charmed)
Returns:
-
int
- monster.info:avg_local_depth ()
-
Get the monster's average depth of (random) generation in the current branch
Returns -1 if the monster is not generated in this branch. Does not handle
fish or zombies.
Returns:
- monster.info:avg_local_prob ()
-
Get the monster's probability of randomly generating on the current floor
This can be used to estimate difficulty, but keep in mind that it is highly
dependent on the branch's generation table.
Returns -1 if the monster is not generated in this branch. Does not handle
fish or zombies.
Returns:
- monster.info:base_type ()
-
Monster base type as in monster_type.h.
Returns:
-
int
- monster.info:can_be_constricted ()
-
Can this monster be constricted?
Returns:
-
boolean
- monster.info:can_go_frenzy ()
-
Can the monster currently be frenzied?
Is it possible to affect the monster with the discord spell or a datura
dart?
Returns:
-
boolean
- monster.info:can_traverse (x, y)
-
Can this monster traverse a particular cell?
Does not address doors or traps; returns true if the monster can occupy the cell.
Uses player coordinates
Parameters:
- x int
- y int
Returns:
-
boolean
- monster.info:can_use_doors ()
-
Can this monster use doors?
Returns:
-
boolean
- monster.info:colour ()
-
Monster glyph colour.
Return is a crawl colour number.
Returns:
-
int
- monster.info:damage_desc ()
-
Get a string describing how injured this monster is.
Returns:
-
string
- monster.info:damage_level ()
-
How hurt is this monster?
Numeric representation of the level of damage sustained by the monster.
Return value ranges from 0 (full HP) to 6 (dead).
Returns:
-
boolean
- monster.info:defeat_wl (spell[, true])
-
Your probability of defeating the monster's WL with a given spell or zap. Returns a value ranging from 0 (no chance) to 100 (guaranteed success).
Returns nil if WL does not apply or the spell can't be cast.
Parameters:
- spell string name
-
true
boolean
if this spell is evoked rather than cast;
( optional )defaults to false
Returns:
-
int
,
string
or
nil
percent chance of success (0-100);
returns "infinite will" if monster is immune; returns nil if WL does not apply.
- monster.info:desc ([set])
-
A description of this monster.
Parameters:
-
set
boolean
true to get the description information body
( optional )displayed when examining the monster; if false (default) returns a short description.
Returns:
-
string
-
set
boolean
- monster.info:ev ()
-
The monster's EV value, in "pips" (number of +'s shown on its description).
Returns a value ranging from 0 to 5 (highest).
Returns:
-
int
evasion level
- monster.info:flags ()
-
Get the monster's flags.
Returns all flags set for the monster, as a list of flag names.
Returns:
-
array
- monster.info:has_ranged_attack ()
-
Does this monster have a ranged attack we know about?
A monster is considered to have a ranged attack if it has any of the
following: a reach attack, a throwable missile, a launcher weapon, an
attack wand, or an attack spell with a range greater than 1.
Returns:
-
boolean
- monster.info:holiness ([holiness])
-
Get the monster's holiness.
If passed a holiness, returns a boolean test of whether the monster has the
given holiness. Otherwise returns a string describing the monster's
holiness.
Possible holinesses: "holy", "natural", "undead", "demonic", "nonliving", "plant", "evil". Evil is a pseudo-holiness given to natural, nonliving, or plant monsters that are hated by the good gods for the spells they cast or gods they worship.
Parameters:
- holiness string ( optional )
Returns:
-
string
or
boolean
- monster.info:intelligence ()
-
Get the monster's intelligence.
Returns a string describing the intelligence level of the monster. Possible
descriptions: "Mindless", "Animal", or "Human"
Returns:
-
string
- monster.info:is (flagname)
-
Test a monster flag.
Check if a monster has a flag set. See
mi-flag.h
for a list of flags.Parameters:
- flagname string
Returns:
-
boolean
- monster.info:is_caught ()
-
Is the monster caught in something?
Tests for nets or webs.
Returns:
-
boolean
- monster.info:is_constricted ()
-
Is the monster constricted?
Returns:
-
boolean
- monster.info:is_constricting ()
-
Is the monster constricting something?
Returns:
-
boolean
- monster.info:is_constricting_you ()
-
Is the monster constricting you in particular?
Returns:
-
boolean
- monster.info:is_firewood ()
-
Is this monster firewood.
Plants and fungi. Immobile things that give no exp.
Returns:
-
boolean
- monster.info:is_safe ()
-
Is this monster safe by default?
Check if this monster is thought of as safe by crawl internally. Does not
check
Hooks.ch_mon_is_safe
, so this can be used there without causing an
infinite loop.
Returns:
-
boolean
- monster.info:is_stationary ()
-
Can this monster move?
Returns:
-
boolean
- monster.info:is_unique ()
-
Is this monster a unique?
Returns:
-
boolean
- monster.info:items ()
-
Returns the monster's items as an array of items.
Returns:
-
array
- monster.info:max_hp ()
-
The monster's max HP given in its description.
Returns:
-
string
describing the max HP (usually "about X").
- monster.info:mname ()
-
Simple monster name.
Returns the name of the monster.
Returns:
-
string
See also:
- monster.info:name ()
-
The monster's full name.
Includes any vault defined names, the uniques name, name changes induced by
polymorph, &c.
Returns:
-
string
See also:
- monster.info:number ()
-
Monster number field.
Contains hydra heads or slime size. Meaningless for all others.
Returns:
-
int
- monster.info:pos ()
-
The x,y coordinates of the monster in player centered coordinates.
Returns:
- int
- int
- monster.info:range ()
-
What's the monster's maximum range with a weapon, spell, or wand?
Returns:
-
int
- monster.info:reach_range ()
-
How far can the monster reach with their melee weapon?
Returns:
-
int
- monster.info:res_cold ()
-
Does the monster resist cold?
Returns a value ranging from -1 (vulnerable) to 3 (immune).
Returns:
-
int
resistance level
- monster.info:res_corr ()
-
Does the monster resist corrosion?
Returns a value ranging from -1 (vulnerable) to 3 (immune).
Returns:
-
int
resistance level
- monster.info:res_draining ()
-
Does the monster resist negative energy?
Returns a value ranging from -1 (vulnerable) to 3 (immune).
Returns:
-
int
resistance level
- monster.info:res_fire ()
-
Does the monster resist fire?
Returns a value ranging from -1 (vulnerable) to 3 (immune).
Returns:
-
int
resistance level
- monster.info:res_shock ()
-
Does the monster resist electricity?
Returns a value ranging from -1 (vulnerable) to 3 (immune).
Returns:
-
int
resistance level
- monster.info:speed_description ()
-
A string describing monster speed.
Possible values are: "very slow", "slow", "normal", "fast", "very fast", and
"extremely fast".
Returns:
-
string
- monster.info:spells ()
-
Get the monster's spells.
Returns the monster's spellbook. The spellbook is given
as a list of spell names.
Returns:
-
array
- monster.info:stabbability ()
-
What quality of stab can you get on this monster? The return value is a number representing the percentage of a top-tier stab you can currently get by attacking the monster. Possible values are:
- 1.0 Sleep, petrified, and paralysis stabs.
- 0.25 Net, web, petrifying, confusion, fear, invisibility, and distraction stabs
- 0.0 No stab bonus.
Returns:
- monster.info:status ([statusname])
-
What statuses is this monster under?
If passed a string parameter, returns a boolean indicating if the monster
has that status. Otherwise returns a comma separated string with all the
statuses the monster has.
Parameters:
- statusname string ( optional )
Returns:
-
string
or
boolean
- monster.info:target_desc ()
-
The string displayed if you target this monster.
Returns:
-
string
targeting description of the monster
(such as "Sigmund, wielding a +0 scythe and wearing a +0 robe")
- monster.info:target_evoke (object)
-
Returns the string displayed if you target this monster with an evocable.
Parameters:
- object item to be evoked
Returns:
-
string
(such as "about 45% to hit")
- monster.info:target_spell (spell)
-
Returns the string displayed if you target this monster with a spell.
Parameters:
- spell string name
Returns:
-
string
(such as "74% to hit")
- monster.info:target_throw (object)
-
Returns the string displayed if you target this monster with a thrown item.
Parameters:
- object item to be thrown
Returns:
-
string
(such as "about 45% to hit")
- monster.info:target_weapon ()
-
Returns the string displayed in xv for your current weapon hit chance.
Returns:
-
string
(such as "about 82% to hit with your dagger")
- monster.info:threat ()
-
The monster's threat level. A numeric representation of the the threat level in the monster list.
- 0 dark grey threat (trivial)
- 1 light grey threat (easy)
- 2 yellow threat (dangerous)
- 3 red threat (extremely dangerous)
Returns:
-
int
- monster.info:type ()
-
Monster type enum value as in monster_type.h.
Returns:
-
int
- monster.info:type ()
-
The last turn the monster was seen at this location.
Returns:
-
int
- monster.info:wl ()
-
The monster's WL level, in "pips" (number of +'s shown on its description).
Returns a value ranging from 0 to 125 (immune).
Returns:
-
int
WL level
- monster.info:x_pos ()
-
The monster's x coordinate in player centered coordinates.
Returns:
-
int
- monster.info:y_pos ()
-
The monster's y coordinate in player centered coordinates.
Returns:
-
int
Module
spells
Information about spells.
Functions
cast (spell[, x=0[, y=0[, if=false]]]) | Cast a spell at a target. |
describe (spell) | Describe a spell. |
dir (name) | Is this spell castable in a direction? |
dir_or_target (name) | Does this spell take a direction or target? |
fail (name) | The failure rate of the spell as a number in [0,100]. |
fail_severity (name) | The miscast severity of the spell as a number in [0,5]. |
god_hates (name) | Does our god hate this spell? |
god_likes (name) | Does our god like this spell? |
letter (name) | What letter is this spell assigned to? |
level (name) | The level of the named spell. |
mana_cost (name) | The MP cost of the spell. |
max_power (name) | The maximum spellpower (in bars). |
max_range (name) | The maximum range of the spell. |
memorised (spellname) | Is this spell memorised? |
min_range (name) | The minimum range of the spell. |
path (spell, x, y, x, y, if) | If this spell is aimed at (x,y), what path will it actually take? |
power (name) | The current spellpower (in bars). |
power_perc (name) | The current spellpower (as an integer percentage 0-100). |
range (name) | The current range of the spell. |
targ_obj (name) | Can this spell target objects? |
target (name) | Is this spell targetable? |
Functions
- cast (spell[, x=0[, y=0[, if=false]]])
-
Cast a spell at a target. If the target is not provided, enters interactive
targeting.
Parameters:
- spell string name
- x number coordinate ( default 0)
- y number coordinate ( default 0)
- if boolean true, aim at the target; if false, shoot past it ( default false)
Returns:
-
boolean
whether an action took place
- describe (spell)
-
Describe a spell.
Provide the complete text description of a spell as displayed in the
game UI
Parameters:
- spell string name
Returns:
-
string
description
- dir (name)
-
Is this spell castable in a direction?
Parameters:
- name string
Returns:
-
boolean
- dir_or_target (name)
-
Does this spell take a direction or target?
Parameters:
- name string
Returns:
-
boolean
- fail (name)
-
The failure rate of the spell as a number in [0,100].
Parameters:
- name string
Returns:
-
int
- fail_severity (name)
-
The miscast severity of the spell as a number in [0,5].
0: light grey, no chance of damaging miscast
1: white, <= 10% max HP damage
2: yellow, <= 30% max HP damage
3: light red, <= 50% max HP damage
4: red, <= 70% max HP damage
5: magenta, > 70% max HP damage (potentially lethal)
Parameters:
- name string
Returns:
-
int
- god_hates (name)
-
Does our god hate this spell?
Casting this will result in pennance or excommunication.
Parameters:
- name string
Returns:
-
boolean
- god_likes (name)
-
Does our god like this spell?
Parameters:
- name string
Returns:
-
boolean
- letter (name)
-
What letter is this spell assigned to?
Parameters:
- name string
Returns:
-
string
or
nil
the spell letter or nil if not memorised
- level (name)
-
The level of the named spell.
Parameters:
- name string
Returns:
-
int
- mana_cost (name)
-
The MP cost of the spell.
Parameters:
- name string
Returns:
-
int
- max_power (name)
-
The maximum spellpower (in bars).
Parameters:
- name string
Returns:
-
int
- max_range (name)
-
The maximum range of the spell.
Parameters:
- name string
Returns:
-
int
- memorised (spellname)
-
Is this spell memorised?
Parameters:
- spellname string
Returns:
-
boolean
- min_range (name)
-
The minimum range of the spell.
Parameters:
- name string
Returns:
-
int
- path (spell, x, y, x, y, if)
-
If this spell is aimed at (x,y), what path will it actually take?
Parameters:
- spell string name
- x int coordinate of spell source, in player coordinates (default=0)
- y int coordinate of spell source, in player coordinates (default=0)
- x int coordinate of spell source, in player coordinates (default=0)
- y int coordinate of spell source, in player coordinates (default=0)
-
if
boolean[opt=false]
true, have the spell aim at the target; if
false, shoot past it.
Returns:
-
table
or
nil
a table of {x,y} of the path the spell will take, in
player coordinates.
Nil is returned if the spell does not follow a path (eg. smite-targeted spells) or if the spell has zero range.
- power (name)
-
The current spellpower (in bars).
Parameters:
- name string
Returns:
-
int
- power_perc (name)
-
The current spellpower (as an integer percentage 0-100).
Parameters:
- name string
Returns:
-
int
- range (name)
-
The current range of the spell.
Parameters:
- name string
Returns:
-
int
- targ_obj (name)
-
Can this spell target objects?
Parameters:
- name string
Returns:
-
boolean
- target (name)
-
Is this spell targetable?
Parameters:
- name string
Returns:
-
boolean
Module
travel
Functions related to (auto)traveling.
Functions
clear_travel_trail () | Clears the travel trail. |
del_exclude (x, y) | Remove an exclusion. |
feature_solid (featurename) | Is this feature solid? |
feature_traversable (featurename, assume_flight) | Can we move onto this feature? |
find_deepest_explored (branch) | What's the deepest floor we've reached in this branch? |
is_excluded (x, y) | Test for exclusion. |
set_exclude (x, y[, r=LOS_RADIUS]) | Set an exclusion. |
set_travel_trail (x, y) | Set travel trail on a cell Call crawl.redraw screen afterward to see changes. |
set_waypoint (waynum, x, y) | Set a numbered waypoint. |
waypoint_delta () | Deltas to a given waypoint. |
Functions
- clear_travel_trail ()
- Clears the travel trail. Call crawl.redraw_screen afterward to see changes.
- del_exclude (x, y)
-
Remove an exclusion.
Uses player-centered coordinates
Parameters:
- x int
- y int
- feature_solid (featurename)
-
Is this feature solid?
Parameters:
- featurename string
Returns:
-
boolean
- feature_traversable (featurename, assume_flight)
-
Can we move onto this feature? Considers player properties like
amphibiousness and permanent (but not temporary) flight, and also considers
travel
avoid
terrain.
Parameters:
- featurename string
-
assume_flight
boolean
If true, assume the player has permanent
flight.
Returns:
-
boolean
- find_deepest_explored (branch)
-
What's the deepest floor we've reached in this branch?
Parameters:
- branch string
Returns:
-
int
depth
- is_excluded (x, y)
-
Test for exclusion.
Uses player-centered coordinates
Parameters:
- x int
- y int
Returns:
-
boolean
- set_exclude (x, y[, r=LOS_RADIUS])
-
Set an exclusion.
Uses player-centered coordinates
Parameters:
- x int
- y int
- r int ( default LOS_RADIUS)
- set_travel_trail (x, y)
-
Set travel
trail on a cell
Call crawl.redraw
screen afterward to see changes.
Uses player-centered coordinates.
Parameters:
- x int
- y int
- set_waypoint (waynum, x, y)
-
Set a numbered waypoint.
Uses player-centered coordinates
Parameters:
- waynum int
- x int
- y int
- waypoint_delta ()
-
Deltas to a given waypoint.
Returns:
- nil if the waypoint is not on the current floor
- int,int the x and y deltas to the waypoint
Module
view
View the world.
All functions in this module that take coordinates use a player centered coordinate system.
Functions
can_reach (x, y) | Can we get to this square? |
cell_see_cell (x1, y1, x2, y2) | Can one cell see the other? |
cloud_at (x, y) | What kind of cloud (if any) is here? |
feature_at (x, y) | What is the feature here? |
get_map () | Returns the entire known map as a table of cell objects. |
in_known_map_bounds (x, y) | Are the given coordinates in the minimal bounding box of the known map? |
invisible_monster (x, y) | Did we detect an invisible monster on this square? |
is_safe_square (x, y, assume_flight) | Is it safe here? |
trap_at (x, y) | What kind of trap (if any) is here? |
withheld (x, y) | Is this square excluded from movement by mesmerise-like effects? |
Functions
- can_reach (x, y)
-
Can we get to this square?
Parameters:
- x int
- y int
Returns:
-
boolean
- cell_see_cell (x1, y1, x2, y2)
-
Can one cell see the other?
Parameters:
- x1 int
- y1 int
- x2 int
- y2 int
Returns:
-
boolean
- cloud_at (x, y)
-
What kind of cloud (if any) is here?
Parameters:
- x int
- y int
Returns:
-
string
or
nil
cloud name or nil
- feature_at (x, y)
-
What is the feature here?
Parameters:
- x int
- y int
Returns:
-
string
feature name
- get_map ()
-
Returns the entire known map as a table of cell objects.
Cells have x, y, feature; optional monster (object);
optional cloud (name); and optional flags [visible, mapped,
traversable, solid, door, undiggable, frontier, excluded, item,
unvisited, unsafe, invisible
monster, detected
item, detected_monster].
The frontier flag indicates that the cell is adjacent to an unknown cell.
The key for each cell is 40000*(100+x) + (100+y), which is
a reversible composition of the x,y coordinates (much more efficient
as a key for lua than other options).
Returns:
-
table[cell]
- in_known_map_bounds (x, y)
-
Are the given coordinates in the minimal bounding box of the known map?
Parameters:
- x int
- y int
Returns:
-
boolean
- invisible_monster (x, y)
-
Did we detect an invisible monster on this square?
Parameters:
- x int
- y int
Returns:
-
boolean
- is_safe_square (x, y, assume_flight)
-
Is it safe here? A square is considered unsafe if it has a harmful cloud,
harmful trap, untraversable terrain, a runed door, or is excluded. The
untraversable terrain check is the same as travel.feature
is
traversable().
Parameters:
- x int
- y int
-
assume_flight
boolean
If true, assume the player has permanent
flight.
Returns:
-
boolean
- trap_at (x, y)
-
What kind of trap (if any) is here?
Parameters:
- x int
- y int
Returns:
-
string
or
nil
The base trap name or nil. Here the base name doesn't
include the word "trap" and is the same string passed to the c_trap_is_safe() hook.
- withheld (x, y)
-
Is this square excluded from movement by mesmerise-like effects?
Parameters:
- x int
- y int
Returns:
-
boolean
Module
util
Utilities for lua programming.
Functions
append (first, ...) | Appends the elements in any number of additional tables to the first table. |
callable (x) | Is x a callable type? |
cathash (...) | Creates a single table from any number of input tables. |
catlist (...) | Creates a single list from any number of lists. |
contains (haystack, needle) | Check if a table contains an item |
copy_table (object) | Copy a table. |
curry (fn, ...) | Curry a function |
defclass (name) | Define a new class |
exists (list, pred) | Test list for at least one value matching pred |
filter (fn, list) | Filter a list based on fn |
forall (list, pred) | Test every list element against pred |
foreach (list, fn) | Apply a function to each value in a table. |
identity (x) | Identity function. |
indexof (list, item) | Find the key of item |
join (sep, list) | Creates a string of the elements in list joined by separator. |
keys (map) | Returns a list of the keys in the given map. |
map (fn, ...) | Classic map, but discards nil values (table.insert doesn't like nil). |
namespace (table_name) | Initialises a namespace that has functions spread across multiple files. |
newinstance (class) | Instantiate a new object |
pairs (map) | Make a list of pairs from a map. |
partition (list, slice[, increment=slice]) | Partition a list. |
random_branch_weighted (list) |
Select randomly from a list based on branch and weight The list should be a list of tables with any of:
|
random_choose_weighted (list) | Given a list of pairs, where the second element of each pair is an integer weight, randomly choose from the list. |
random_from (list) | Pick a random element from a list (unweighted) |
random_range_real (lower, upper) | Random real number in the range [lower,upper) |
random_subset (set, n) | Given a table of elements, choose a subset of size n without replacement. |
random_weighted_from (weightfn, list) | Pick a random element from a list based on a weight function |
random_weighted_keys (weightfn, list[, order]) | Pick a random key from a table using weightfn weightfn is used as in util.random_weighted_from |
remove (list, item) | Remove an item |
set (list) | Creates a set (a map of keys to true) from the list supplied. |
slice (list, istart, iend) | Slice a list. |
sort (t, f) |
A wrapper on
table.sort
that uses locale-insensitive comparison for
strings by default.
|
stable_lessthan (x1, x2) | a locale-insensitive less-than operation. |
subclass (parent, subclassname) | Define a subclass |
trim (s) | Remove leading and trailing whitespace From http://lua-users.org/wiki/CommonFunctions |
values (map) | Returns a list of the values in the given map. |
Functions
- append (first, ...)
-
Appends the elements in any number of additional tables to the first table.
Parameters:
- first
- ...
- callable (x)
-
Is x a callable type?
Parameters:
- x
- cathash (...)
-
Creates a single table from any number of input tables.
Keys get overwritten in the merge.
Parameters:
- ...
- catlist (...)
-
Creates a single list from any number of lists.
Parameters:
- ...
- contains (haystack, needle)
-
Check if a table contains an item
Parameters:
- haystack
- needle
- copy_table (object)
-
Copy a table.
Copied from http://lua-users.org/wiki/CopyTable
Parameters:
- object
- curry (fn, ...)
-
Curry a function
Parameters:
- fn
- ...
- defclass (name)
-
Define a new class
Parameters:
- name
- exists (list, pred)
-
Test list for at least one value matching pred
Parameters:
- list
- pred
- filter (fn, list)
-
Filter a list based on fn
Parameters:
- fn
- list
- forall (list, pred)
-
Test every list element against pred
Parameters:
- list
- pred
- foreach (list, fn)
-
Apply a function to each value in a table.
Parameters:
- list
- fn
- identity (x)
-
Identity function.
Parameters:
- x
- indexof (list, item)
-
Find the key of item
Parameters:
- list
- item
- join (sep, list)
-
Creates a string of the elements in list joined by separator.
Parameters:
- sep
- list
- keys (map)
-
Returns a list of the keys in the given map.
Parameters:
- map
- map (fn, ...)
-
Classic map, but discards nil values (table.insert doesn't like nil).
Parameters:
- fn
- ...
- namespace (table_name)
-
Initialises a namespace that has functions spread across multiple files.
If the namespace table does not exist, it is created. If it already exists,
it is not modified.
Parameters:
- table_name
- newinstance (class)
-
Instantiate a new object
Parameters:
- class
- pairs (map)
-
Make a list of pairs from a map.
Parameters:
- map
Returns:
-
a list of lists built from the given map, each sublist being
in the form { key, value } for each key-value pair in the map.
- partition (list, slice[, increment=slice])
-
Partition a list.
Parameters:
- list the list
- slice the slice size
- increment the increment for slice start ( default slice)
Returns:
-
a list of pieces
- random_branch_weighted (list)
-
Select randomly from a list based on branch and weight
The list should be a list of tables with any of:
- Keys for each branch name specifying the weight in that branch.
-
A single key
branch
containing a string, restricting the item to appear only in that branch -
A single key
weight
giving the default weight.
An item with no keys gets a default weight of 10.
Parameters:
- list A list of tables with weighting keys.
- random_choose_weighted (list)
-
Given a list of pairs, where the second element of each pair is an integer
weight, randomly choose from the list.
Parameters:
- list the list of pairs to choose from
- random_from (list)
-
Pick a random element from a list (unweighted)
Parameters:
- list
See also:
- random_range_real (lower, upper)
-
Random real number in the range [lower,upper)
Parameters:
- lower
- upper
- random_subset (set, n)
-
Given a table of elements, choose a subset of size n without replacement.
Parameters:
- set
- n
- random_weighted_from (weightfn, list)
-
Pick a random element from a list based on a weight function
Parameters:
- weightfn function or key to choose weights
- list if weightfn is a key then elements of list have weights chosen according to the number in key (default weight is 10).
- random_weighted_keys (weightfn, list[, order])
-
Pick a random key from a table using weightfn
weightfn is used as in
util.random_weighted_from
Parameters:
- weightfn function or key to choose weights
- list the list
- order order function to use on keys ( optional )
- remove (list, item)
-
Remove an item
Parameters:
- list
- item
- set (list)
-
Creates a set (a map of keys to true) from the list supplied.
Parameters:
- list
- slice (list, istart, iend)
-
Slice a list.
Parameters:
- list
- istart
- iend
Returns:
-
the sublist of elements at indices [istart, iend) of the
supplied list.
- sort (t, f)
-
A wrapper on
table.sort
that uses locale-insensitive comparison for strings by default. Liketable.sort
, this sorts an array in-place.Parameters:
- t array an array to sort.
- f function(a,b) an optional less-than function to use for determining sort order.
- stable_lessthan (x1, x2)
-
a locale-insensitive less-than operation.
Parameters:
- x1
- x2
- subclass (parent, subclassname)
-
Define a subclass
Parameters:
- parent should have no-arg constructor.
- subclassname name
- trim (s)
-
Remove leading and trailing whitespace
From http://lua-users.org/wiki/CommonFunctions
Parameters:
- s
See also:
- values (map)
-
Returns a list of the values in the given map.
Parameters:
- map
Module
you
Information about the player.
Functions
abilities () | Available abilities |
ability_letters () | Ability letters in use. |
ability_table () | Ability table. |
absdepth () | The current "absolute depth". |
ac () | Armour class. |
activate_ability (the[, x=0[, y=0[, if=false]]]) | Activate an ability by name, supplying a target where relevant. |
agile () | Are you agile? |
anchored () | Are you dimensionally anchored? |
asleep () | Are you asleep? |
base_mp () | Base max mp. |
base_skill (name) | Base skill level. |
berserk () | Are you berserk? |
best_skill () | Best skill. |
branch () | What branch are you in? |
breath_timeout () | Are you out of breath? |
brilliant () | Are you brilliant? |
can_smell () | Can you smell? |
can_train_skill (name) | Can a skill be trained? |
caught () | Are you caught in something? |
class () | Get name of player's background. |
confused () | Are you confused? |
constricted () | Are you currently constricted? |
constricting () | Are you currently constricting anything? |
contaminated () | Are you contaminated? |
corrosion () | Corrosion amount. |
deaths () | How many times have you died? |
depth () | Your current depth in that branch. |
depth_fraction () | What fraction of the branch you've gone into. |
dexterity () | Dexterity. |
drain () | How much drain. |
ego ([terse=false]) | What is the ego of our unarmed attack? |
ev () | Evasion. |
evil_god ([god=you.god()]) | Is this [player's] god evil? |
exhausted () | Are you exhausted? |
extra_resistant () | Are you extra resistant? |
feel_safe () | Do you feel safe? |
floor_items () | The items on your cell on the floor. |
flying () | Are you flying? |
genus () | Your genus. |
get_base_mutation_level (mutationname[, innate=true[, temp=true[, normal=true]]]) | Get the mutation level of a mutation. |
get_training_target (name) | Get a training target. |
god () | Get name of player's god |
gold () | How much gold do you have? |
good_god ([god=you.god()]) | Is this [player's] god good? |
hand () | Get noun for player's hands. |
has_claws () | Do you have claws? |
hasted () | Are you hasted? |
have_orb () | Do you have the orb? |
have_rune (rune) | Do you have the given rune? |
how_mutated (innate, levels, temp) | How mutated are you? |
hp () | Hit points. |
intelligence () | Intelligence. |
invisible () | Are you invisible? |
is_level_on_stack (levelname) | Check the level stack. |
known_items () | Get the current state of item identification as a list of strings. |
lives () | How many extra lives do you have? |
los () | LOS Radius. |
mem_spells () | Get memorisable spells. |
memorise () | Memorise a spell by name Memorise a spell by name, erroring only on an invalid spell name. |
mesmerised () | Are you mesmerised? |
mighty () | Are you mighty? |
monster () | The name of your monster type. |
mp () | Magic points. |
mutation (mutation) | Deprecated: use you.get_base_mutation_level . |
mutation_overview () | Mutation overview string. |
name () | Get player's name. |
noise_perception () | What was the loudest noise you heard in the last turn? |
num_runes () | How many runes do you have? |
on_fire () | Are you on fire? |
one_time_ability_used () | Has the [player's] current god's one-time ability been used? |
paralysed () | Are you paralysed? |
petrifying () | Are you petrifying? |
piety_rank () | Stars of piety. |
poison_survival () | Minimum hp after poison wears off. |
poisoned () | Are you poisoned? |
race () | Get name of player's race. |
reach_range () | What is your current reaching range? |
real_time () | Total elapsed real time in seconds. |
regenerating () | Are you regenerating? |
res_cold () | Cold resistance (rC). |
res_corr () | Corrosion resistance (rCorr). |
res_draining () | Negative energy resistance (rN). |
res_drowning () | Drowning resistance (rDrown). |
res_fire () | Fire resistance (rF). |
res_mutation () | Mutation resistance (rMut). |
res_poison () | Poison resistance (rPois). |
res_shock () | Electric resistance (rElec). |
rooted () | Are you rooted? |
see_cell (x, y) | Can you see a cell? |
see_cell_no_trans (x, y) | Can you see this cell without looking through a window? |
see_cell_solid (x, y) | Can you see this cell without something solid in the way? |
see_cell_solid_see (x, y) | Can you see this cell with nothing in the way? |
see_invisible () | See invisible (sInv). |
set_training_target (name, target) | Set a training target. |
sh () | Shield class. |
sick () | Are you sick? |
silenced () | Are you silenced? |
silencing () | Are you silencing the world around you? |
skill (name) | Current skill level. |
skill_cost (name) | Cost of training this skill. |
skill_progress (name) | Skill progress. |
slowed () | Are you slowed? |
species () | Get name of player's species. |
spell_letters () | Currently used spell letters |
spell_levels () | How many spell levels are currently available. |
spell_table () | Get the spell table. |
spells () | List your spells |
spirit_shield () | Guardian spirit. |
status ([stat]) | Check status effects. |
stealth_pips () | Stealth pips. |
stop_activity () | Interrupt the current multi-turn activity or macro sequence. |
strength () | Strength. |
swift () | Are you currently +Swift or -Swift? |
taking_stairs () | Are you taking the stairs? |
teleporting () | Are you teleporting? |
temp_mutation (mutation) | Deprecated: use you.get_base_mutation_level . |
temp_mutations () | How many temporary mutations do you have? |
time () | Total elapsed time in auts. |
torment_immune () | Are you currently immune to torment? |
train_skill (name[, level]) | Train a skill. |
transform () | Current transformation, if any. |
turn_is_over () | Has player done something that takes time? |
turns () | How many turns have been taken. |
turns_on_level () | How long has the player been on the current level? |
unarmed_damage_rating () | Unarmed damage rating. |
under_penance () | Are you under penance? |
where () | Where are you? |
willpower () | Willpower (WL). |
wizard () | Is player in wizard mode? |
xl_progress () | XL progress. |
you_immune_to_hex (spell) | Are you intrinsically immune to this particular hex spell? |
Functions
- abilities ()
-
Available abilities
Returns:
-
array
An array of ability names.
- ability_letters ()
-
Ability letters in use.
Returns:
-
array
An array of ability letters
- ability_table ()
-
Ability table.
Returns:
-
table
A map of letters to ability names
- absdepth ()
-
The current "absolute depth".
Absolute depth of the current location.
Returns:
-
number
- ac ()
-
Armour class.
Returns:
-
int
- activate_ability (the[, x=0[, y=0[, if=false]]])
-
Activate an ability by name, supplying a target where relevant. If the
ability is not targeted, the target is ignored. An invalid target will
open interactive targeting.
Parameters:
- the string name of the ability
- x number coordinate ( default 0)
- y number coordinate ( default 0)
- if boolean true, aim at the target; if false, shoot past it ( default false)
Returns:
-
boolean
whether an action took place
- agile ()
-
Are you agile?
Returns:
-
boolean
- anchored ()
-
Are you dimensionally anchored?
Returns:
-
boolean
- asleep ()
-
Are you asleep?
Returns:
-
boolean
- base_mp ()
-
Base max mp.
Returns:
-
int
- base_skill (name)
-
Base skill level.
Ignores drain, crosstraining, &c.
Parameters:
- name string
- berserk ()
-
Are you berserk?
Returns:
-
boolean
- best_skill ()
-
Best skill.
Returns:
-
string
- branch ()
-
What branch are you in?
Returns:
-
string
- breath_timeout ()
-
Are you out of breath?
Returns:
-
boolean
- brilliant ()
-
Are you brilliant?
Returns:
-
boolean
- can_smell ()
-
Can you smell?
Returns:
-
boolean
- can_train_skill (name)
-
Can a skill be trained?
Parameters:
- name string skill name
Returns:
-
boolean
- caught ()
-
Are you caught in something?
Returns:
-
string
or
nil
what's got you
- class ()
-
Get name of player's background.
Returns:
-
string
- confused ()
-
Are you confused?
Returns:
-
boolean
- constricted ()
-
Are you currently constricted?
Returns:
-
boolean
- constricting ()
-
Are you currently constricting anything?
Returns:
-
boolean
- contaminated ()
-
Are you contaminated?
Returns:
-
number
- corrosion ()
-
Corrosion amount.
Returns:
-
int
- deaths ()
-
How many times have you died?
Returns:
-
int
- depth ()
-
Your current depth in that branch.
Returns:
-
int
- depth_fraction ()
-
What fraction of the branch you've gone into.
Returns:
-
number
- dexterity ()
-
Dexterity.
Returns:
-
int
current dexterity
- drain ()
-
How much drain.
Returns:
-
int
- ego ([terse=false])
-
What is the ego of our unarmed attack?
Parameters:
- terse boolean ( default false)
Returns:
-
string
or
nil
the ego for unarmed combat, if any
- ev ()
-
Evasion.
Returns:
-
int
- evil_god ([god=you.god()])
-
Is this [player's] god evil?
Parameters:
- god string ( default you.god())
Returns:
-
boolean
- exhausted ()
-
Are you exhausted?
Returns:
-
boolean
- extra_resistant ()
-
Are you extra resistant?
Returns:
-
boolean
- feel_safe ()
-
Do you feel safe?
Returns:
-
boolean
- floor_items ()
-
The items on your cell on the floor.
Returns:
-
array
an Array of
items.Item
objects
- flying ()
-
Are you flying?
Returns:
-
boolean
- genus ()
-
Your genus.
As a lower-case plural string.
Returns:
-
string
- get_base_mutation_level (mutationname[, innate=true[, temp=true[, normal=true]]])
-
Get the mutation level of a mutation.
If all optional parameters are false this returns zero.
Parameters:
- mutationname string
- innate boolean include innate mutations ( default true)
- temp boolean include temporary mutations ( default true)
- normal boolean include normal mutations ( default true)
Returns:
-
int
level
- get_training_target (name)
-
Get a training target.
Parameters:
- name string
Returns:
-
number
- god ()
-
Get name of player's god
Returns:
-
string
- gold ()
-
How much gold do you have?
Returns:
-
int
- good_god ([god=you.god()])
-
Is this [player's] god good?
Parameters:
- god string ( default you.god())
Returns:
-
boolean
- hand ()
-
Get noun for player's hands.
Returns:
-
string
- has_claws ()
-
Do you have claws?
Returns:
-
int
claws level
- hasted ()
-
Are you hasted?
Returns:
-
boolean
- have_orb ()
-
Do you have the orb?
Returns:
-
boolean
- have_rune (rune)
-
Do you have the given rune?
Parameters:
- rune string or number number or rune name
Returns:
-
boolean
- how_mutated (innate, levels, temp)
-
How mutated are you?
Adds up the total number (including levels if requested) of mutations.
Parameters:
- innate boolean include innate mutations
- levels boolean count levels
- temp boolean include temporary mutations
Returns:
-
int
- hp ()
-
Hit points.
Returns:
- int current hp
- int current max hp
- intelligence ()
-
Intelligence.
Returns:
-
int
current intelligence
- invisible ()
-
Are you invisible?
Returns:
-
boolean
- is_level_on_stack (levelname)
-
Check the level stack.
When entering portal branches or the abyss crawl tracks
where we came from with a level stack, which we can query.
Can take a Branch or Branch:depth string.
Parameters:
- levelname string
Returns:
-
boolean
- known_items ()
-
Get the current state of item identification as a list of strings.
Returns:
-
table
The list of names of known identifiable items.
- lives ()
-
How many extra lives do you have?
Returns:
-
int
- los ()
-
LOS Radius.
Returns:
-
int
- mem_spells ()
-
Get memorisable spells.
This lists the spells available in the spell library.
Returns:
-
array
An array of spell names.
- memorise ()
-
Memorise a spell by name
Memorise a spell by name, erroring only on an invalid spell name.
Returns:
-
boolean
whether memorisation succeeded
- mesmerised ()
-
Are you mesmerised?
Returns:
-
boolean
- mighty ()
-
Are you mighty?
Returns:
-
boolean
- monster ()
-
The name of your monster type.
Returns:
-
string
- mp ()
-
Magic points.
Returns:
- int current mp
- int current max mp
- mutation (mutation)
-
Deprecated: use
you.get_base_mutation_level
.
Equivalent to
you.get_base_mutation_level(name)
Parameters:
- mutation string name
Returns:
-
int
num
- mutation_overview ()
-
Mutation overview string.
Returns:
-
string
- name ()
-
Get player's name.
Returns:
-
string
- noise_perception ()
-
What was the loudest noise you heard in the last turn?
Returns a number from [0, 1000], representing the current noise bar.
If the player's coordinates are silenced, return 0.
Noise bar colour breakpoints, listed here for clua api convenience: LIGHTGREY <= 333 , YELLOW <= 666 , RED < 1000 , else LIGHTMAGENTA Each colour breakpoint aims to approximate 1 additional los radius of noise.
Returns:
-
int
noise value
- num_runes ()
-
How many runes do you have?
Returns:
-
int
- on_fire ()
-
Are you on fire?
Returns:
-
boolean
- one_time_ability_used ()
-
Has the [player's] current god's one-time ability been used? (if any).
Returns:
-
boolean
- paralysed ()
-
Are you paralysed?
Returns:
-
boolean
- petrifying ()
-
Are you petrifying?
Returns:
-
boolean
- piety_rank ()
-
Stars of piety.
Returns:
-
int
- poison_survival ()
-
Minimum hp after poison wears off.
Returns:
-
int
- poisoned ()
-
Are you poisoned?
Returns:
-
boolean
- race ()
-
Get name of player's race.
Returns:
-
string
- reach_range ()
-
What is your current reaching range?
Returns:
-
int
- real_time ()
-
Total elapsed real time in seconds.
Returns:
-
int
- regenerating ()
-
Are you regenerating?
Returns:
-
boolean
- res_cold ()
-
Cold resistance (rC).
Returns:
-
int
resistance level
- res_corr ()
-
Corrosion resistance (rCorr).
Returns:
-
int
resistance level
- res_draining ()
-
Negative energy resistance (rN).
Returns:
-
int
resistance level
- res_drowning ()
-
Drowning resistance (rDrown).
Returns:
-
boolean
- res_fire ()
-
Fire resistance (rF).
Returns:
-
int
resistance level
- res_mutation ()
-
Mutation resistance (rMut).
Returns:
-
int
resistance level
- res_poison ()
-
Poison resistance (rPois).
Returns:
-
int
resistance level
- res_shock ()
-
Electric resistance (rElec).
Returns:
-
int
resistance level
- rooted ()
-
Are you rooted?
Returns:
-
boolean
- see_cell (x, y)
-
Can you see a cell?
Uses player-centered coordinates
Parameters:
- x int
- y int
Returns:
-
boolean
- see_cell_no_trans (x, y)
-
Can you see this cell without looking through a window?
Checks line of sight treating transparent rock and stone as opaque.
Uses player-centered coordinates.
Parameters:
- x int
- y int
Returns:
-
boolean
- see_cell_solid (x, y)
-
Can you see this cell without something solid in the way?
Checks line of sight treating all solid features as opaque.
Uses player-centered coordinates.
Parameters:
- x int
- y int
Returns:
-
boolean
- see_cell_solid_see (x, y)
-
Can you see this cell with nothing in the way?
Checks line of sight treating all solid features as opaque and properly
checking bushes and clouds.
Uses player-centered coordinates.
Parameters:
- x int
- y int
Returns:
-
boolean
- see_invisible ()
-
See invisible (sInv).
Returns:
-
boolean
- set_training_target (name, target)
-
Set a training target.
Parameters:
- name string
- target number
Returns:
-
number
or
nil
if successfully set the new target
- sh ()
-
Shield class.
Returns:
-
int
- sick ()
-
Are you sick?
Returns:
-
boolean
- silenced ()
-
Are you silenced?
Returns:
-
boolean
- silencing ()
-
Are you silencing the world around you?
Returns:
-
boolean
- skill (name)
-
Current skill level.
Parameters:
- name string
Returns:
-
number
- skill_cost (name)
-
Cost of training this skill.
Parameters:
- name string
Returns:
-
number
- skill_progress (name)
-
Skill progress.
Parameters:
- name string skill name
Returns:
-
number
percentage of the way to the next skill level
- slowed ()
-
Are you slowed?
Returns:
-
boolean
- species ()
-
Get name of player's species.
Returns:
-
string
- spell_letters ()
-
Currently used spell letters
Returns:
-
array
An array of letters
See also:
- spell_levels ()
-
How many spell levels are currently available.
Returns:
-
int
- spell_table ()
-
Get the spell table.
Returns:
-
table
A table matching spell letters to spell names
See also:
- spells ()
-
List your spells
Returns:
-
array
An array of spell names
See also:
- spirit_shield ()
-
Guardian spirit.
Returns a number for backwards compatibility.
Returns:
-
int
- status ([stat])
-
Check status effects.
Given a specific status name, checks for that status.
Otherwise, lists all statuses.
Parameters:
- stat string ( optional )
Returns:
-
string
or
boolean
- stealth_pips ()
-
Stealth pips.
Returns:
-
int
number of stealth pips
- stop_activity ()
- Interrupt the current multi-turn activity or macro sequence.
- strength ()
-
Strength.
Returns:
-
int
current strength
- swift ()
-
Are you currently +Swift or -Swift?
If you have neither, returns 0. If you are +Swift, +1, and -Swift, -1.
Returns:
-
int
Swift level
- taking_stairs ()
-
Are you taking the stairs?
Returns:
-
boolean
- teleporting ()
-
Are you teleporting?
Returns:
-
boolean
- temp_mutation (mutation)
-
Deprecated: use
you.get_base_mutation_level
.
Equivalent to
you.get_base_mutation_level(name, false, true, false)
Parameters:
- mutation string name
Returns:
-
int
num
- temp_mutations ()
-
How many temporary mutations do you have?
Returns:
-
int
- time ()
-
Total elapsed time in auts.
Returns:
-
int
- torment_immune ()
-
Are you currently immune to torment?
Returns:
-
boolean
- train_skill (name[, level])
-
Train a skill.
Training levels:
- 0 is disable
- 1 is enable
- 2 is focus
If no level is passed, does not change the current training.
Parameters:
- name string
- level int set training level ( optional )
Returns:
-
int
training level
- transform ()
-
Current transformation, if any.
Returns:
-
string
transformation name
- turn_is_over ()
-
Has player done something that takes time?
Returns:
-
boolean
- turns ()
-
How many turns have been taken.
Returns:
-
int
- turns_on_level ()
-
How long has the player been on the current level?
Returns:
-
number
- unarmed_damage_rating ()
-
Unarmed damage rating.
Returns:
- number The damage rating for unarmed combat.
- string The full damage rating string for unarmed combat.
- under_penance ()
-
Are you under penance?
Returns:
-
boolean
- where ()
-
Where are you?
Returns:
-
string
- willpower ()
-
Willpower (WL).
Returns:
-
int
number of WL pips
- wizard ()
-
Is player in wizard mode?
Returns:
-
boolean
- xl_progress ()
-
XL progress.
Returns:
-
number
percentage of the way to the next xl [0,100]
- you_immune_to_hex (spell)
-
Are you intrinsically immune to this particular hex spell?
Parameters:
- spell string name
Returns:
-
boolean