diff --git a/src/jsapi.c b/src/jsapi.c index 1d02dbc..45cf382 100644 --- a/src/jsapi.c +++ b/src/jsapi.c @@ -276,13 +276,13 @@ static s32 duk_keyp(duk_context* duk) if(key >= TIC_KEYS_COUNT) { duk_error(duk, DUK_ERR_ERROR, "unknown keyboard code\n"); + return 0; } else { if(duk_is_null_or_undefined(duk, 1) && duk_is_null_or_undefined(duk, 2)) { duk_push_boolean(duk, tic->api.keyp(tic, key, -1, -1)); - return 1; } else { @@ -290,12 +290,11 @@ static s32 duk_keyp(duk_context* duk) u32 period = duk_to_int(duk, 2); duk_push_boolean(duk, tic->api.keyp(tic, key, hold, period)); - return 1; } } } - return 0; + return 1; } static duk_ret_t duk_sfx(duk_context* duk) diff --git a/src/luaapi.c b/src/luaapi.c index 0b005b8..0184c69 100644 --- a/src/luaapi.c +++ b/src/luaapi.c @@ -836,8 +836,6 @@ static s32 lua_keyp(lua_State* lua) if(top == 1) { lua_pushboolean(lua, tic->api.keyp(tic, key, -1, -1)); - - return 1; } else if(top == 3) { @@ -845,13 +843,16 @@ static s32 lua_keyp(lua_State* lua) u32 period = getLuaNumber(lua, 3); lua_pushboolean(lua, tic->api.keyp(tic, key, hold, period)); - return 1; } - else luaL_error(lua, "invalid params, keyp [ code [ hold period ] ]\n"); + else + { + luaL_error(lua, "invalid params, keyp [ code [ hold period ] ]\n"); + return 0; + } } } - return 0; + return 1; } static s32 lua_memcpy(lua_State* lua)