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

@@ -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