From feb135ce2ef26d3e98a640e4529939f38b90d412 Mon Sep 17 00:00:00 2001 From: fatratknight Date: Tue, 15 Sep 2009 18:20:10 +0000 Subject: [PATCH] Added in an invert possibility for joypad_set. Using a string instead of true/false/nil will let lua invert the player's input. --- changelog.txt | 1 + src/lua-engine.cpp | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index e1dd369d..bb943c3e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,4 @@ +15-september-2009 - FatRatKnight - Finally got in that "invert" value for joypad.set. This value simply inverts the player input. Actually, any string will invert it, since we have not used strings for anything else in joypad.set. 15-september-2009 - FatRatKnight - Reworked how input is taken from lua, and generally everything related to joypad.set and what it affects. Now setting stuff to false will: Prevent user control for exactly one frame, and allow more than one false button as a time. Yeah, bug fixes. Hopefully runs a little faster now. 22-august-2009 - adelikat - Win32 - Map Hotkeys Dialog - Fixed but where "X" and Alt+F4 would not close dialog 22-august-2009 - adelikat - Win32 - Added a Save Config File menu item diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 0135962b..a0333016 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -709,7 +709,7 @@ static int joypad_read(lua_State *L) { // frame advance. The table should have the right // keys (no pun intended) set. /*FatRatKnight: I changed some of the logic. - */ + Now with 4 options!*/ static int joypad_set(lua_State *L) { // Which joypad we're tampering with @@ -733,10 +733,9 @@ static int joypad_set(lua_State *L) { //Button is not nil, so find out if it is true/false if (!lua_isnil(L,-1)) { - if (lua_toboolean(L,-1)) //True + if (lua_toboolean(L,-1)) //True or string luajoypads2[which-1] |= 1 << i; - else //False - //if (lua_toboolean == 0 || 'string is "invert"' + if (lua_toboolean(L,-1) == 0 || lua_isstring(L,-1)) //False or string luajoypads1[which-1] &= ~(1 << i); }