• 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 1.1 onAddItem

sircurse

Curseria RTG - TFS 1.1
Joined
Nov 12, 2007
Messages
107
Reaction score
2
Location
Brazil
Twitch
curseofcourse
Hi,

This function was working before upgrade to 1.1, do anyone know if it was removed? (onAddItem)
It was being used for the HOTA quest.

Curse.
 
I saw the dough script, I think it is because I was using it with a actionid, it may works with item instead actionid, the problem of using a itemid instead a actionid is that will be hard to manage it, since I have a .lua for each quest.

Have you tried with a actionid?

That is how I have it set:
Code:
<movevent event="AddItem" tileitem="1" actionid="13101" script="quests/ancient_tombs_quest.lua"/>

Actually the actionid was set on the basin, and was fine till the update.

Curse.
 
I imagine you would just use this in the script:
Code:
if tileitem:getAttribute(ITEM_ATTRIBUTE_ACTIONID) == xxxx then
and keep movements.xml the way it is for dough or something:
Code:
<movevent event="AddItem" tileitem="1" itemid="1786" script="dough.lua"/>
 
But that is the problem, the basin can be used for other quests, if I use the itemid of the basin pointing to HOTA quest, it will always call this .lua, if I need another quest to use the coal basin I will have to edit on HOTA quest, or I will need a coalbasin.lua script dedicated, and all the quests that I use it will need that script.

It is not easy to manage, I would like to skip working that way to have every single quest centralized to this own script. better to fix bugs, making upgrades, etc...

Curse.
 
I just tested it using itemid 1787 (oven - off) with actionid 5000 and it worked.
Code:
<movevent event="AddItem" tileitem="1" actionid="5000" script="dough.lua"/>
 
Can you share your function? Mine is that and is not working.

Code:
function onAddItem(moveitem, tileitem, position)
local coin = config[tileitem.actionid]
i = getTopCreature(coin.FROMPOS).uid

if tileitem:getAttribute(ITEM_ATTRIBUTE_ACTIONID) >= 13101 and tileitem:getAttribute(ITEM_ATTRIBUTE_ACTIONID) <= 13108 and moveitem.itemid == 2159 then
    if(isPlayer(i) == TRUE) then
        doRemoveItem(moveitem.uid, 1)
        doSendMagicEffect(position, 15)
        doSendMagicEffect(coin.FROMPOS, CONST_ME_TELEPORT)
        doTeleportThing(getPlayer.uid, coin.TOPOS, FALSE)
        doSendMagicEffect(coin.TOPOS, CONST_ME_TELEPORT)
    end
end
    return true
end
 
This works for me with the dough. I am using TFS 1.2 though, and my old TFS 1.1 builds no longer work because I've since updated my datapack. So I don't know if this works the same in TFS 1.1

Code:
<movevent event="AddItem" tileitem="1" actionid="5000" script="dough.lua"/>

Code:
function onAddItem(moveitem, tileitem, position)
    if moveitem:getId() == 2693 then
        moveitem:transform(2689)
        position:sendMagicEffect(CONST_ME_HITBYFIRE)
    elseif moveitem:getId() == 6277 then
        moveitem:transform(2687, 12)
        position:sendMagicEffect(CONST_ME_HITBYFIRE)
    end
    return true
end
 
I re-write the code and for some reason it has been fixed.

Code:
function onAddItem(moveitem, tileitem, position)
coin = config[tileitem:getActionId()]
player = getTopCreature(coin.FROMPOS).uid

    if tileitem:getActionId() >= 13101 and tileitem:getActionId() <= 13108 then
            if(isPlayer(player) == TRUE) and moveitem:getId() == 2159 then
                doRemoveItem(moveitem.uid, 1)
                position:sendMagicEffect(16)
                doSendMagicEffect(coin.FROMPOS, 11)
                doTeleportThing(player, coin.TOPOS, FALSE)
                doSendMagicEffect(coin.TOPOS, 11)
            end
    end
    return true
end
 

Similar threads

Back
Top