Merge branch 'key-hooks-no-return' into 'next'

Use return value of KeyDown and KeyUp hooks

See merge request STJr/SRB2!1559
This commit is contained in:
Tatsuru 2021-06-29 11:42:26 -04:00
commit b597508c55
2 changed files with 12 additions and 12 deletions

View file

@ -107,6 +107,7 @@ void LUA_HookInt(INT32 integer, int hook);
void LUA_HookBool(boolean value, int hook);
int LUA_HookPlayer(player_t *, int hook);
int LUA_HookTiccmd(player_t *, ticcmd_t *, int hook);
int LUA_HookKey(INT32 keycode, int hook); // Hooks for key events
void LUA_HookThinkFrame(void);
int LUA_HookMobjLineCollide(mobj_t *, line_t *);
@ -130,4 +131,3 @@ int LUA_HookPlayerCmd(player_t *, ticcmd_t *);
int LUA_HookMusicChange(const char *oldname, struct MusicChange *);
fixed_t LUA_HookPlayerHeight(player_t *player);
int LUA_HookPlayerCanEnterSpinGaps(player_t *player);
int LUA_HookKey(INT32 keycode, int hooktype); // Hooks for key events

View file

@ -588,6 +588,17 @@ int LUA_HookTiccmd(player_t *player, ticcmd_t *cmd, int hook_type)
return hook.status;
}
int LUA_HookKey(INT32 keycode, int hook_type)
{
Hook_State hook;
if (prepare_hook(&hook, false, hook_type))
{
lua_pushinteger(gL, keycode);
call_hooks(&hook, 1, 1, res_true);
}
return hook.status;
}
/* =========================================================================
SPECIALIZED HOOKS
========================================================================= */
@ -1088,14 +1099,3 @@ int LUA_HookPlayerCanEnterSpinGaps(player_t *player)
}
return hook.status;
}
int LUA_HookKey(INT32 keycode, int hooktype)
{
Hook_State hook;
if (prepare_hook(&hook, 0, hooktype))
{
lua_pushinteger(gL, keycode);
call_hooks(&hook, 1, 0, res_true);
}
return hook.status;
}