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

@@ -995,6 +995,9 @@ struct instance_globals {
int lusername_size;
#endif
/* nhlua.c */
genericptr_t luacore; /* lua_State * */
/* o_init.c */
short disco[NUM_OBJECTS];

View File

@@ -1657,6 +1657,9 @@ extern int l_obj_register(lua_State *);
/* ### nhlua.c ### */
#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET)
extern void l_nhcore_init(void);
extern void l_nhcore_done(void);
extern void l_nhcore_call(int);
extern lua_State * nhl_init(void);
extern void nhl_done(lua_State *);
extern boolean nhl_loadlua(lua_State *, const char *);

View File

@@ -421,6 +421,16 @@ typedef struct sortloot_item Loot;
#define SUPPRESS_HISTORY 4
#define URGENT_MESSAGE 8
/* Lua callback functions */
enum nhcore_calls {
NHCORE_START_NEW_GAME = 0,
NHCORE_RESTORE_OLD_GAME,
NHCORE_MOVELOOP_TURN,
NHCORE_GAME_EXIT,
NUM_NHCORE_CALLS
};
/* Macros for messages referring to hands, eyes, feet, etc... */
enum bodypart_types {
ARM = 0,