aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2014-10-30 00:11:46 -0400
committerkwolekr <kwolekr@minetest.net>2014-10-30 00:12:12 -0400
commit03f3f958ed4c21937d93637bd79b3e31c83009d8 (patch)
treee59eb1a31a5af2059fa45dd37788c091023f86d4 /src
parent6c9bbb03609d79d455266935947f9bb844022972 (diff)
downloadminetest-03f3f958ed4c21937d93637bd79b3e31c83009d8.tar.gz
minetest-03f3f958ed4c21937d93637bd79b3e31c83009d8.tar.bz2
minetest-03f3f958ed4c21937d93637bd79b3e31c83009d8.zip
Check minetest.hud_change() parameters on conversion (Fix #1714)
Diffstat (limited to 'src')
-rw-r--r--src/script/lua_api/l_object.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp
index a556439dc..7f98c9458 100644
--- a/src/script/lua_api/l_object.cpp
+++ b/src/script/lua_api/l_object.cpp
@@ -970,14 +970,14 @@ int ObjectRef::l_hud_change(lua_State *L)
if (player == NULL)
return 0;
- u32 id = !lua_isnil(L, 2) ? lua_tonumber(L, 2) : -1;
+ u32 id = lua_isnumber(L, 2) ? lua_tonumber(L, 2) : -1;
HudElement *e = player->getHud(id);
if (!e)
return 0;
HudElementStat stat = HUD_STAT_NUMBER;
- if (!lua_isnil(L, 3)) {
+ if (lua_isstring(L, 3)) {
int statint;
std::string statstr = lua_tostring(L, 3);
stat = string_to_enum(es_HudElementStat, statint, statstr) ?
@@ -991,7 +991,7 @@ int ObjectRef::l_hud_change(lua_State *L)
value = &e->pos;
break;
case HUD_STAT_NAME:
- e->name = lua_tostring(L, 4);
+ e->name = luaL_checkstring(L, 4);
value = &e->name;
break;
case HUD_STAT_SCALE:
@@ -999,19 +999,19 @@ int ObjectRef::l_hud_change(lua_State *L)
value = &e->scale;
break;
case HUD_STAT_TEXT:
- e->text = lua_tostring(L, 4);
+ e->text = luaL_checkstring(L, 4);
value = &e->text;
break;
case HUD_STAT_NUMBER:
- e->number = lua_tonumber(L, 4);
+ e->number = luaL_checknumber(L, 4);
value = &e->number;
break;
case HUD_STAT_ITEM:
- e->item = lua_tonumber(L, 4);
+ e->item = luaL_checknumber(L, 4);
value = &e->item;
break;
case HUD_STAT_DIR:
- e->dir = lua_tonumber(L, 4);
+ e->dir = luaL_checknumber(L, 4);
value = &e->dir;
break;
case HUD_STAT_ALIGN: