ConAn Edujawa
Member
- Joined
- Feb 23, 2015
- Messages
- 457
- Reaction score
- 17
what this functions do ?
0.4
0.4
Lua:
int32_t LuaInterface::luaGetStorageList(lua_State* L)
{
//getStorageList()
ScriptEnviroment* env = getEnv();
StorageMap::const_iterator it = env->getStorageBegin();
lua_newtable(L);
for(uint32_t i = 1; it != env->getStorageEnd(); ++i, ++it)
{
lua_pushnumber(L, i);
lua_pushstring(L, it->first.c_str());
pushTable(L);
}
return 1;
}
int32_t LuaInterface::luaGetCreatureStorageList(lua_State* L)
{
//getCreatureStorageList(cid)
ScriptEnviroment* env = getEnv();
if(Creature* creature = env->getCreatureByUID(popNumber(L)))
{
StorageMap::const_iterator it = creature->getStorageBegin();
lua_newtable(L);
for(uint32_t i = 1; it != creature->getStorageEnd(); ++i, ++it)
{
lua_pushnumber(L, i);
lua_pushstring(L, it->first.c_str());
pushTable(L);
}
}
else
{
errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
Last edited: