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

2 tiles to remove stone issue

sirluumi

New Member
Joined
Jun 12, 2020
Messages
3
Reaction score
0
Im trying to script a quest where 2 players have to stand on different tiles in order to remove a stone. I made it so if no player is on any tiles, there's a big crystal blocking the way. If 1 player stands on a tile, it transforms to a smaller one. When the 2nd player stands on the other tile, the small crystal will disappear. I can't seem to get the if item:getId(smallcrystal) and item:getId(bigcrystal) to trigger. onStepOut works just fine since I haven't worked on that part yet.

Any ideas on how to get the if functions to trigger? Currently not getting any error messages

Tibia 8.6
TFS 1.3

Lua:
function onStepIn(cid, item, frompos, item2, topos)

stonepos = {x=133, y=157, z=7, stackpos=1}
getpos = getThingfromPos(stonepos)
text = "Need 1 more player"
texttwo = "Stone placed"
local bigcrystal = Tile(Position(133, 157, 7)):getItemById(8636)
local smallcrystal = Tile(Position(133, 157, 7)):getItemById(8640)

    if item.uid == 64120 then
        if item:getId(smallcrystal) == 8640 then
            doRemoveItem(getpos.uid,1)
            doTransformItem(item.uid,item.itemid-1)
            doCreatureSay(cid, text, TALKTYPE_ORANGE_1)
        else if item:getId(bigcrystal) == 8636 then
            doTransformItem(getpos.uid,getpos.itemid+4)
            doTransformItem(item.uid,item.itemid-1)
            doCreatureSay(cid, text, TALKTYPE_ORANGE_1)
        else
        doPlayerSendCancel(cid,"Not possible.")
        end
        end
    else
    doPlayerSendCancel(cid,"Not possible.")
    end
end

function onStepOut(cid, item, frompos, item2, topos)

    if item.uid == 64120 then
        doCreateItem(8635,1,stonepos)
        doTransformItem(item.uid,item.itemid+1)
        doCreatureSay(cid, texttwo, TALKTYPE_ORANGE_1)
    else
    doPlayerSendCancel(cid,"Sorry not possible.")
    end
end
 
The code structure is a bit strange.

Start here:
Print "bigcrystal" and "smallcrystal" immediately after they are set
Print "item.uid" immediately before:
Lua:
if item.uid == 64120 then
Print "bigcrystal" and "smallcrystal" immediately following the code above

BTW: In general, if you don't get an error message, and you don't get a visible effect you expect in your code, it's quite likely to be an issue with the conditions (if statements), or the values you're testing.
You use "item.uid, "item.itemid", and "item.getId". If they do the same thing, use exactly one form, not three.
If they're not identical, you won't be able to debug your code by eye.
 
Last edited:
Back
Top