• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

getCreatureStorageList

ConAn Edujawa

Member
Joined
Feb 23, 2015
Messages
457
Reaction score
17
what this functions do ?
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:
As far as I can understand getStorageList() returns a table of key, value pairs containing global storage values.

Same seems to be applying to getCreatureStorageList(cid) but specifically meant for getting a table of key, value pairs containing player storage values.

Run this somewhere to test it :
Lua:
print("getStorageList()")
for k, t in pairs(getStorageList()) do
    for i, v in pairs(t) do
        print(i .. " " .. v)
    end
end

print("\ngetCreatureStorageList()")
for k, t in pairs(getCreatureStorageList(cid)) do
    for i, v in pairs(t) do
        print(i .. " " .. v)
    end
end
 

Similar threads

Replies
2
Views
547
Back
Top