getHouseTiles(houseId)
Function return table with positions of house tiles or boolean false if house does not exist.
Code for 0.3.6, change LuaScriptInterface to '0.4 code for LUA functions' and it will work.
luascript.h
[CPP]static int32_t luaGetHouseTiles(lua_State* L);[/CPP]
luascript.cpp
[CPP]
//getHouseTiles(houseId)
lua_register(m_luaState, "getHouseTiles", LuaScriptInterface::luaGetHouseTiles);
[/CPP]
luascript.cpp
[CPP]
int32_t LuaScriptInterface::luaGetHouseTiles(lua_State* L)
{
//getHouseTiles(houseId)
if(House* house = Houses::getInstance()->getHouse(popNumber(L)))
{
uint32_t i = 1;
lua_newtable(L);
for(HouseTileList::iterator houseTile = house->getHouseTileBegin(); houseTile != house->getHouseTileEnd(); ++houseTile)
{
lua_pushnumber(L, i);
Tile* tile = *houseTile;
pushPosition(L, tile->getPosition(), 0);
pushTable(L);
++i;
}
}
else
{
errorEx(getError(LUA_ERROR_HOUSE_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
[/CPP]
Function return table with positions of house tiles or boolean false if house does not exist.
Code for 0.3.6, change LuaScriptInterface to '0.4 code for LUA functions' and it will work.
luascript.h
[CPP]static int32_t luaGetHouseTiles(lua_State* L);[/CPP]
luascript.cpp
[CPP]
//getHouseTiles(houseId)
lua_register(m_luaState, "getHouseTiles", LuaScriptInterface::luaGetHouseTiles);
[/CPP]
luascript.cpp
[CPP]
int32_t LuaScriptInterface::luaGetHouseTiles(lua_State* L)
{
//getHouseTiles(houseId)
if(House* house = Houses::getInstance()->getHouse(popNumber(L)))
{
uint32_t i = 1;
lua_newtable(L);
for(HouseTileList::iterator houseTile = house->getHouseTileBegin(); houseTile != house->getHouseTileEnd(); ++houseTile)
{
lua_pushnumber(L, i);
Tile* tile = *houseTile;
pushPosition(L, tile->getPosition(), 0);
pushTable(L);
++i;
}
}
else
{
errorEx(getError(LUA_ERROR_HOUSE_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
[/CPP]