Fix tpt.element(<something not a string or number>) returning 1

This commit is contained in:
jacob1
2013-08-08 22:45:08 -04:00
parent 73544bd069
commit ab6a0c2072

View File

@@ -713,7 +713,8 @@ int luatpt_getelement(lua_State *l)
} }
else else
{ {
char* name = (char*)luaL_optstring(l, 1, "dust"); luaL_checktype(l, 1, LUA_TSTRING);
char* name = (char*)luaL_optstring(l, 1, "");
if ((t = luacon_ci->GetParticleType(name))==-1) if ((t = luacon_ci->GetParticleType(name))==-1)
return luaL_error(l, "Unrecognised element '%s'", name); return luaL_error(l, "Unrecognised element '%s'", name);
lua_pushinteger(l, t); lua_pushinteger(l, t);