static MapNode readnode(lua_State *L, int index, INodeDefManager *ndef)
{
lua_getfield(L, index, "name");
- const char *name = lua_tostring(L, -1);
+ const char *name = luaL_checkstring(L, -1);
lua_pop(L, 1);
u8 param1;
lua_getfield(L, index, "param1");
while(lua_next(L, table) != 0){
// key at index -2 and value at index -1
luaL_checktype(L, -1, LUA_TSTRING);
- std::string itemstring = lua_tostring(L, -1);
+ std::string itemstring = luaL_checkstring(L, -1);
items.push_back(itemstring);
// removes value, keeps key for next iteration
lua_pop(L, 1);
NodeMetadata *meta = getmeta(ref);
if(meta == NULL) return 0;
// Do it
- std::string text = lua_tostring(L, 2);
+ std::string text = luaL_checkstring(L, 2);
meta->setText(text);
reportMetadataChange(ref);
return 0;
NodeMetadata *meta = getmeta(ref);
if(meta == NULL) return 0;
// Do it
- std::string text = lua_tostring(L, 2);
+ std::string text = luaL_checkstring(L, 2);
meta->setInfoText(text);
reportMetadataChange(ref);
return 0;
if(meta == NULL) return 0;
// Do it
Inventory *inv = meta->getInventory();
- const char *name = lua_tostring(L, 2);
+ const char *name = luaL_checkstring(L, 2);
inventory_set_list_from_lua(inv, name, L, 3,
ref->m_env->getGameDef());
reportMetadataChange(ref);
if(meta == NULL) return 0;
// Do it
Inventory *inv = meta->getInventory();
- const char *name = lua_tostring(L, 2);
+ const char *name = luaL_checkstring(L, 2);
inventory_get_list_to_lua(inv, name, L);
return 1;
}
NodeMetadata *meta = getmeta(ref);
if(meta == NULL) return 0;
// Do it
- std::string text = lua_tostring(L, 2);
+ std::string text = luaL_checkstring(L, 2);
meta->setInventoryDrawSpec(text);
reportMetadataChange(ref);
return 0;
NodeMetadata *meta = getmeta(ref);
if(meta == NULL) return 0;
// Do it
- std::string name = lua_tostring(L, 2);
+ std::string name = luaL_checkstring(L, 2);
size_t len = 0;
const char *s = lua_tolstring(L, 3, &len);
std::string str(s, len);
NodeMetadata *meta = getmeta(ref);
if(meta == NULL) return 0;
// Do it
- std::string name = lua_tostring(L, 2);
+ std::string name = luaL_checkstring(L, 2);
std::string str = meta->getString(name);
lua_pushlstring(L, str.c_str(), str.size());
return 1;
ServerActiveObject *co = getobject(ref);
if(co == NULL) return 0;
// itemstring
- const char *itemstring = lua_tostring(L, 2);
+ const char *itemstring = luaL_checkstring(L, 2);
infostream<<"ObjectRef::l_add_to_inventory(): id="<<co->getId()
<<" itemstring=\""<<itemstring<<"\""<<std::endl;
// Do it
ServerActiveObject *co = getobject(ref);
if(co == NULL) return 0;
// itemstring
- const char *itemstring = lua_tostring(L, 2);
+ const char *itemstring = luaL_checkstring(L, 2);
infostream<<"ObjectRef::l_add_to_inventory_later(): id="<<co->getId()
<<" itemstring=\""<<itemstring<<"\""<<std::endl;
// Do it
LuaEntitySAO *co = getluaobject(ref);
if(co == NULL) return 0;
// Do it
- std::string mod = lua_tostring(L, 2);
+ std::string mod = luaL_checkstring(L, 2);
co->setTextureMod(mod);
return 0;
}
ObjectRef *ref = checkobject(L, 1);
ServerRemotePlayer *player = getplayer(ref);
if(player == NULL) return 0;
- const char *name = lua_tostring(L, 2);
+ const char *name = luaL_checkstring(L, 2);
// Do it
inventory_set_list_from_lua(&player->inventory, name, L, 3,
player->getEnv()->getGameDef(), PLAYER_INVENTORY_SIZE);
ObjectRef *ref = checkobject(L, 1);
ServerRemotePlayer *player = getplayer(ref);
if(player == NULL) return 0;
- const char *name = lua_tostring(L, 2);
+ const char *name = luaL_checkstring(L, 2);
// Do it
inventory_get_list_to_lua(&player->inventory, name, L);
return 1;
// pos
v3f pos = readFloatPos(L, 2);
// content
- const char *name = lua_tostring(L, 3);
+ const char *name = luaL_checkstring(L, 3);
// Do it
ServerActiveObject *obj = new LuaEntitySAO(env, pos, name, "");
env->addActiveObject(obj);
// pos
v3f pos = readFloatPos(L, 2);
// inventorystring
- const char *inventorystring = lua_tostring(L, 3);
+ const char *inventorystring = luaL_checkstring(L, 3);
// Do it
ServerActiveObject *obj = new ItemSAO(env, pos, inventorystring);
env->addActiveObject(obj);
ServerEnvironment *env = o->m_env;
if(env == NULL) return 0;
// Do it
- const char *name = lua_tostring(L, 2);
+ const char *name = luaL_checkstring(L, 2);
ServerRemotePlayer *player =
static_cast<ServerRemotePlayer*>(env->getPlayer(name));
if(player == NULL){