• 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!

C++ TFS 0.3.6 item attributes in TFS1.3?

TomCrusher

Jeg er ingenting
Premium User
Joined
Dec 31, 2008
Messages
663
Reaction score
18
Location
Norway
Hello,

I tried to give items own attribute in TFS 1.3 but not success there can use only pre defined attributes or I'm blind. :)
It was possible in old version TFS by function doItemSetAttrribute(uid, key, value) have tried in TFS 1.3 do the same by thing:setAttribute("nick", "Buller") without any succes.
In TFS 0.3.6 you could give items attributes that was stored in database it seems to be removed in TFS 1.3
Is there somebody who know the piece of source to do this possible in TFS 1.3? I tried to write somethink by using of boost::any but seems I'm too old to coding in new modern times.
 
OP
OP
TomCrusher

TomCrusher

Jeg er ingenting
Premium User
Joined
Dec 31, 2008
Messages
663
Reaction score
18
Location
Norway
More that way:
Lua:
int32_t LuaInterface::luaDoItemSetAttribute(lua_State* L)
{
    //doItemSetAttribute(uid, key, value)
    boost::any value;
    if(lua_isnumber(L, -1))
    {
        float tmp = popFloatNumber(L);
        if(std::floor(tmp) < tmp)
            value = tmp;
        else
            value = (int32_t)tmp;
    }
    else if(lua_isboolean(L, -1))
        value = popBoolean(L);
    else if(lua_isstring(L, -1))
        value = popString(L);
    else
    {
        lua_pop(L, 1);
        errorEx("Invalid data type");

        lua_pushboolean(L, false);
        return 1;
    }

    std::string key = popString(L);
    ScriptEnviroment* env = getEnv();

    Item* item = env->getItemByUID(popNumber(L));
    if(!item)
    {
        errorEx(getError(LUA_ERROR_ITEM_NOT_FOUND));
        lua_pushboolean(L, false);
        return 1;
    }

    if(value.type() == typeid(int32_t))
    {
        if(key == "uid")
        {
            int32_t tmp = boost::any_cast<int32_t>(value);
            if(tmp < 1000 || tmp > 0xFFFF)
            {
                errorEx("Value for protected key \"uid\" must be in range of 1000 to 65535");
                lua_pushboolean(L, false);
                return 1;
            }

            item->setUniqueId(tmp);
        }       
        else if(key == "aid")
            item->setActionId(boost::any_cast<int32_t>(value));
        else
            item->setAttribute(key, boost::any_cast<int32_t>(value));
    }
    else
        item->setAttribute(key, value);

    lua_pushboolean(L, true);
    return 1;
}
 

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,557
Solutions
119
Reaction score
1,863
Evil what about this? are u guys willing to add those attributes in the new tfs or what o.0
Code:
increasemeleevalue
increasemeleepercent
increasemagicvalue
increasemagicpercent
increasehealingvalue
increasehealingpercent
Read what the pr does and please change your avatar, people confuse me with you.
 
Top