diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 6a5536c1c..9a7ea9828 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -421,35 +421,43 @@ int mobj_localskin_setter(lua_State *L) if (mo->player) { - SetLocalPlayerSkin(mo->player - players, luaL_checkstring(L, 2), NULL); + SetLocalPlayerSkin(mo->player - players, luaL_optstring(L, 2, "none"), NULL); } else { INT32 i; char skin[SKINNAMESIZE+1]; // all skin names are limited to this length - strlcpy(skin, luaL_checkstring(L, 2), sizeof skin); + strlcpy(skin, luaL_optstring(L, 2, "none"), sizeof skin); strlwr(skin); // all skin names are lowercase - // Try localskins - for (i = 0; i < numlocalskins; i++) + if (strcasecmp(skin, "none")) { - if (stricmp(localskins[i].name, skin) == 0) + // Try localskins + for (i = 0; i < numlocalskins; i++) { - mo->localskin = &localskins[i]; - mo->skinlocal = true; - return 0; + if (stricmp(localskins[i].name, skin) == 0) + { + mo->localskin = &localskins[i]; + mo->skinlocal = true; + return 0; + } + } + + // Try other skins + for (i = 0; i < numskins; i++) + { + if (fastcmp(skins[i].name, skin)) + { + mo->localskin = &skins[i]; + mo->skinlocal = false; + return 0; + } } } - - // Try other skins - for (i = 0; i < numskins; i++) + else { - if (fastcmp(skins[i].name, skin)) - { - mo->localskin = &skins[i]; - mo->skinlocal = false; - return 0; - } + mo->localskin = 0; + mo->skinlocal = false; } } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 1b095f7a5..eb537d51f 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -303,7 +303,7 @@ int player_localskin_setter(lua_State *L) { player_t *plr = GETPLAYER(); - SetLocalPlayerSkin(plr - players, luaL_checkstring(L, 2), NULL); + SetLocalPlayerSkin(plr - players, luaL_optstring(L, 2, "none"), NULL); return 0; }