Lua: nhcore script with function callbacks

Adds possible callbacks for "start_new_game", "restore_old_game",
"moveloop_turn", and "game_exit" which when defined, will be called
from core code at the appropriate time.

Adds lua hooks for dump_fmtstr (only if DUMPLOG), dnum_name, u.moves,
u.uhave_amulet, and u.depth.
This commit is contained in:
Pasi Kallinen
2021-05-21 17:54:53 +03:00
parent 0e9bf2e03c
commit 29868036f1
12 changed files with 248 additions and 2 deletions

View File

@@ -890,6 +890,7 @@ split off some of the functionality that was in makedefs (compiled-in options
and accessed on the target platform
replace quest.txt and associated conversion to quest.dat via makedefs with
Lua quest texts loaded at runtime
callback lua functions from core at certain game actions
some altars are displayed in different colors (for tty and curses at least)
add 'quick_farsight' option to provide some control over random clairvoyance
where pausing to be able to browse temporarily visible aspects of the

View File

@@ -14,6 +14,35 @@ Example:
local str = nh.an("unicorn");
=== dnum_name
Returns the full dungeon name (as defined in dungeon.lua) for the dungeon
number given as parameter.
Example:
local dungeon_name = nh.dnum_name(u.dnum);
=== dump_fmtstr
Returns a string replacing special format chars with game data.
Only available if NetHack was compiled with DUMPLOG.
|===
| %% | literal '%'
| %t | game start, timestamp
| %T | current time, timestamp
| %d | game start, YYYYMMDDhhmmss
| %D | current time, YYYYMMDDhhmmss
| %v | game version, eg. '3.7.0-0'
| %u | UID
| %n | player name
| %N | first character of player name
|===
Example:
local filename = nh.dump_fmtstr("/tmp/nethack.%n.%d.log");
=== getlin