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

[Request] Rat Bridge (Rook)

ond

Veteran OT User
Joined
Mar 24, 2008
Messages
2,775
Solutions
25
Reaction score
483
Location
Sweden
Hello, I need help with a script. It has to work like real tibia's.

I want, when you pull the lever, the bridge (2 SQM) dissapear and get replaced by ground borders [id 4799 and id 4797]

And here is the tricky part. If someone stand on the bridge or there is an item lying on it when someone pulls it, the shall be moved position.x-1 and position.x-2 (Depending on if they are on the left or right side of the bridge. Here is a screenshot to explain even further:


rat.jpg


I hope someone can take some time and help me, I think this script can get to be used by more people!
 
Not tested
Code:
function onUse(cid, item, frompos, itemEx, topos)
local bridgePos = {{x=110, y=111, z=8}, {x=111, y=111, z=8}}
local newPos = {x=109, y=111, z=8}
	if item.itemid == 1945 then
		for i, v in ipairs(bridgePos) do
			doRelocate(v[i], newPos)
		end
		doCreateItem(bridgePos[1], 4799)
		doCreateItem(bridgePos[2], 4797)
	else
		doCreateItem(bridgePos[1], 1284)
		doCreateItem(bridgePos[2], 1284)
	end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end
 
Lua:
local posi3 =  {x=301, y=287, z=8} --
poss = {
[1] = {x=299, y=287, z=8},
[2] = {x=298, y=287, z=8},
[3] = {x=300, y=287, z=8}
}

local lever = {
[1] = {x=297, y=286, z=8},
[2] = {x=303, y=286, z=8}
}
local itemids = 5770
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == 1945 then
                doCreateItem(itemids,poss[1])
                if getTileItemById(poss[2],4645).itemid ~= nil then
                        doTransformItem(getTileItemById(poss[2],4645).uid,itemids)
                end
                if getTileItemById(poss[3],4647).itemid > 0 then
                        doTransformItem(getTileItemById(poss[3],4647).uid,itemids)
                end
                for i=1,#lever do
                        if lever[i].x == fromPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doTransformItem(item.uid,item.itemid+1)
                doTransformItem(getTileItemById(lever[b],1945).uid,1946)
        elseif item.itemid == 1946 then
                for p = 1,#poss do
                doRelocate(poss[p], posi3)
                end
                for z =1,#poss do
                                poss[z].stackpos = 254
                                if getThingFromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingFromPos(poss[z]).uid)
                                end
                                poss[z].stackpos = 1
                                if getThingFromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingFromPos(poss[z]).uid)
                                end

                end
                for i=1,#lever do
                        if lever[i].x == toPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doCreateItem(4616,poss[1])
                doCreateItem(351,poss[2])
                doCreateItem(351,poss[3])
                doCreateItem(4645,poss[2])
                doCreateItem(4647,poss[3])
                doTransformItem(item.uid,item.itemid-1)
                doTransformItem(getTileItemById(lever[b],1946).uid,1945)
        end
        return TRUE
end
 
Not tested
Code:
function onUse(cid, item, frompos, itemEx, topos)
local bridgePos = {{x=110, y=111, z=8}, {x=111, y=111, z=8}}
local newPos = {x=109, y=111, z=8}
	if item.itemid == 1945 then
		for i, v in ipairs(bridgePos) do
			doRelocate(v[i], newPos)
		end
		doCreateItem(bridgePos[1], 4799)
		doCreateItem(bridgePos[2], 4797)
	else
		doCreateItem(bridgePos[1], 1284)
		doCreateItem(bridgePos[2], 1284)
	end
return doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
end

Ehh, the drawbridge is 3 sqm, 1 start, 1 on the water and 1 end.
 
Lua:
local posi3 =  {x=301, y=287, z=8} --
poss = {
[1] = {x=299, y=287, z=8},
[2] = {x=298, y=287, z=8},
[3] = {x=300, y=287, z=8}
}

local lever = {
[1] = {x=297, y=286, z=8},
[2] = {x=303, y=286, z=8}
}
local itemids = 5770
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == 1945 then
                doCreateItem(itemids,poss[1])
                if getTileItemById(poss[2],4645).itemid ~= nil then
                        doTransformItem(getTileItemById(poss[2],4645).uid,itemids)
                end
                if getTileItemById(poss[3],4647).itemid > 0 then
                        doTransformItem(getTileItemById(poss[3],4647).uid,itemids)
                end
                for i=1,#lever do
                        if lever[i].x == fromPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doTransformItem(item.uid,item.itemid+1)
                doTransformItem(getTileItemById(lever[b],1945).uid,1946)
        elseif item.itemid == 1946 then
                for p = 1,#poss do
                doRelocate(poss[p], posi3)
                end
                for z =1,#poss do
                                poss[z].stackpos = 254
                                if getThingFromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingFromPos(poss[z]).uid)
                                end
                                poss[z].stackpos = 1
                                if getThingFromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingFromPos(poss[z]).uid)
                                end

                end
                for i=1,#lever do
                        if lever[i].x == toPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doCreateItem(4616,poss[1])
                doCreateItem(351,poss[2])
                doCreateItem(351,poss[3])
                doCreateItem(4645,poss[2])
                doCreateItem(4647,poss[3])
                doTransformItem(item.uid,item.itemid-1)
                doTransformItem(getTileItemById(lever[b],1946).uid,1945)
        end
        return TRUE
end

Could you, or someone explain how this script works?
 
Oh yes, btw, I'm using Avesta 0.6.3 = less features. Doesn't have doRelocate for example
 
Lua:
local posi3 =  {x=301, y=287, z=8} --
poss = {
[1] = {x=299, y=287, z=8},
[2] = {x=298, y=287, z=8},
[3] = {x=300, y=287, z=8}
}

local lever = {
[1] = {x=297, y=286, z=8},
[2] = {x=303, y=286, z=8}
}
local itemids = 5770
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == 1945 then
                doCreateItem(itemids,poss[1])
                if getTileItemById(poss[2],4645).itemid ~= nil then
                        doTransformItem(getTileItemById(poss[2],4645).uid,itemids)
                end
                if getTileItemById(poss[3],4647).itemid > 0 then
                        doTransformItem(getTileItemById(poss[3],4647).uid,itemids)
                end
                for i=1,#lever do
                        if lever[i].x == fromPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doTransformItem(item.uid,item.itemid+1)
                doTransformItem(getTileItemById(lever[b],1945).uid,1946)
        elseif item.itemid == 1946 then
                for p = 1,#poss do
                doRelocate(poss[p], posi3)
                end
                for z =1,#poss do
                                poss[z].stackpos = 254
                                if getThingFromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingFromPos(poss[z]).uid)
                                end
                                poss[z].stackpos = 1
                                if getThingFromPos(poss[z]).itemid > 1000 then
                                        doRemoveItem(getThingFromPos(poss[z]).uid)
                                end

                end
                for i=1,#lever do
                        if lever[i].x == toPosition.x then
                                o = i
                        end
                end
                if o == 1 then
                        b = 2
                else
                        b = 1
                end
                doCreateItem(4616,poss[1])
                doCreateItem(351,poss[2])
                doCreateItem(351,poss[3])
                doCreateItem(4645,poss[2])
                doCreateItem(4647,poss[3])
                doTransformItem(item.uid,item.itemid-1)
                doTransformItem(getTileItemById(lever[b],1946).uid,1945)
        end
        return TRUE
end
http://otland.net/f81/rookgard-rats-lever-50534/#post507355
 
Back
Top