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

Lua TFS(0.4) - local config issue

Lava Titan

Developer
Joined
Jul 25, 2009
Messages
1,529
Solutions
1
Reaction score
85
Location
Portugal
Hello, I'm trying to create a dynamic upgrading script, and I'm having an issue related to config, the script works fine if all the up-grader ID's are different but if I want one item to upgrade 2 different items it messes up which item I'm talking about, so I wonder if someone has any idea how can I workaround this :p


This is my current script: (ignore the var "effectX") it's not being used yet

Lua:
local config = {
    [8298] = {upgradeFrom = 2306, upgradeTo = 2272, effectX = CONST_ANI_EARTH},
    [8298] = {upgradeFrom = 2272, upgradeTo = 2296, effectX = CONST_ANI_EARTH},
    [8299] = {upgradeFrom = 2272, upgradeTo = 2296, effectX = CONST_ANI_EARTH},
}

function onUse(cid, item, fromPosition, itemEx, toPosition)

    local upgraderId = config[item.itemid]

    if upgraderId then
        if itemEx.itemid == upgraderId.upgradeFrom then
            doTransformItem(itemEx.uid, upgraderId.upgradeTo)
        else
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, getItemNameById(item.itemid).." does not upgrade "..getItemNameById(itemEx.itemid))
        end
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, item.itemid.." is not an upgrader, check actions.xml")
    end
    return true
end
 
you shouldn't even have any problem with this
from what it looks like, it should work correctly
you have two separate upgrader ids, 8298 and 8299
both of which take a base id of 2272 and upgrades it to 2296
are you wanting to have 1 upgrade id to be able to upgrade multiple sets of ids?
maybe this thing i wrote a long time ago can help, there's a 0.4 version too
Action - [TFS 0.4/1.2] Tier upgrading system
 
Back
Top