diff --git a/src/g_game.c b/src/g_game.c index fae311694..962c2fd14 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -51,6 +51,7 @@ #include "r_fps.h" // frame interpolation/uncapped #include "lua_hud.h" +#include "lua_libs.h" gameaction_t gameaction; gamestate_t gamestate = GS_NULL; @@ -1170,7 +1171,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // why build a ticcmd if we're paused? // Or, for that matter, if we're being reborn. // ...OR if we're blindfolded. No looking into the floor. - if (paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametyperules & GTR_TAG) + if (ignoregameinputs || paused || P_AutoPause() || (gamestate == GS_LEVEL && (player->playerstate == PST_REBORN || ((gametyperules & GTR_TAG) && (leveltime < hidetime * TICRATE) && (player->pflags & PF_TAGIT))))) {//@TODO splitscreen player cmd->angleturn = ticcmd_oldangleturn[forplayer]; diff --git a/src/g_input.c b/src/g_input.c index fa30c1984..97c0505a3 100644 --- a/src/g_input.c +++ b/src/g_input.c @@ -18,6 +18,8 @@ #include "hu_stuff.h" // need HUFONT start & end #include "netcode/d_net.h" #include "console.h" +#include "lua_script.h" +#include "lua_libs.h" #define MAXMOUSESENSITIVITY 100 // sensitivity steps @@ -116,7 +118,10 @@ void G_MapEventsToControls(event_t *ev) { case ev_keydown: if (ev->key < NUMINPUTS) - gamekeydown[ev->key] = 1; + { + if (!ignoregameinputs) + gamekeydown[ev->key] = 1; + } #ifdef PARANOIA else { @@ -144,7 +149,7 @@ void G_MapEventsToControls(event_t *ev) case ev_joystick: // buttons are virtual keys i = ev->key; - if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on) + if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on || ignoregameinputs) break; if (ev->x != INT32_MAX) joyxmove[i] = ev->x; if (ev->y != INT32_MAX) joyymove[i] = ev->y; @@ -152,7 +157,7 @@ void G_MapEventsToControls(event_t *ev) case ev_joystick2: // buttons are virtual keys i = ev->key; - if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on) + if (i >= JOYAXISSET || menuactive || CON_Ready() || chat_on || ignoregameinputs) break; if (ev->x != INT32_MAX) joy2xmove[i] = ev->x; if (ev->y != INT32_MAX) joy2ymove[i] = ev->y; diff --git a/src/lua_inputlib.c b/src/lua_inputlib.c index 0602b3db6..eeb61fed7 100644 --- a/src/lua_inputlib.c +++ b/src/lua_inputlib.c @@ -20,6 +20,7 @@ #include "lua_libs.h" boolean mousegrabbedbylua = true; +boolean ignoregameinputs = false; /////////////// // FUNCTIONS // @@ -163,12 +164,33 @@ static int lib_get(lua_State *L) LUA_PushUserdata(L, &mouse2, META_MOUSE); return 1; } + else if (fastcmp(field, "ignoregameinputs")) + { + lua_pushboolean(L, ignoregameinputs); + return 1; + } else { return 0; } } +static int lib_set(lua_State *L) +{ + const char *field = luaL_checkstring(L, 2); + + if (fastcmp(field, "ignoregameinputs")) + { + ignoregameinputs = luaL_checkboolean(L, 3); + } + else + { + lua_rawset(L, 1); + } + + return 0; +} + /////////////////// // gamekeydown[] // /////////////////// @@ -282,6 +304,9 @@ int LUA_InputLib(lua_State *L) lua_createtable(L, 0, 2); lua_pushcfunction(L, lib_get); lua_setfield(L, -2, "__index"); + + lua_pushcfunction(L, lib_set); + lua_setfield(L, -2, "__newindex"); lua_setmetatable(L, -2); lua_newuserdata(L, 0); diff --git a/src/lua_libs.h b/src/lua_libs.h index 7f8d21f38..2e3c70652 100644 --- a/src/lua_libs.h +++ b/src/lua_libs.h @@ -13,6 +13,7 @@ extern lua_State *gL; extern boolean mousegrabbedbylua; +extern boolean ignoregameinputs; #define MUTABLE_TAGS