Jfrye
Mapper, trying to learn scripting
TFS 1.1 CLIENT VERSION 10.77
I have managed to get this script working for the most part. It will create the bridge, but it will
not remove the bridge.
Pull the lever, bridge pops up. Pull lever again, and nothing happens. The switch moves back and forth, but nothing. No errors in the console or anything, just nothing happens.
Also, IF possible how do I make both levers move at the same time? So I pull one lever and they both move. Both levers have actionID 6000
This is the original code that I started with. https://otland.net/threads/rookgard-rats-lever.50534/#post507355
I have managed to get this script working for the most part. It will create the bridge, but it will
not remove the bridge.
Pull the lever, bridge pops up. Pull lever again, and nothing happens. The switch moves back and forth, but nothing. No errors in the console or anything, just nothing happens.
Also, IF possible how do I make both levers move at the same time? So I pull one lever and they both move. Both levers have actionID 6000
Code:
local posi3 = {x=2385, y=332, z=8} --
poss = {
[1] = {x=2382, y=332, z=8},
[2] = {x=2383, y=332, z=8},
[3] = {x=2384, y=332, z=8}
}
local lever = {
[1] = {x=2378, y=329, z=8},
[2] = {x=2386, y=331, z=8}
}
local itemids = 5770
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 1945 then
doTransformItem(itemids,poss[2])
if getTileItemById(poss[1],7666).itemid ~= nil then
doTransformItem(getTileItemById(poss[1],7666).uid,itemids)
end
if getTileItemById(poss[2],13548).itemid ~= nil then
doTransformItem(getTileItemById(poss[2],13548).uid,itemids)
end
if getTileItemById(poss[3],7834).itemid > 0 then
doTransformItem(getTileItemById(poss[3],7834).uid,itemids)
end
for i=1,#lever do
if lever.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,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 getTileItemById(poss[z]).itemid > 1000 then
doRemoveItem(getTileItemById(poss[z]).uid)
end
poss[z].stackpos = 1
if getTileItemById(poss[z]).itemid > 1000 then
doRemoveItem(getTileItemById(poss[z]).uid)
end
end
for i=1,#lever do
if lever.x == toPosition.x then
o = i
end
end
if o == 1 then
b = 2
else
b = 1
end
doTransformItem(13548,poss[2])
doTransformItem(13548,poss[1])
doTransformItem(13548,poss[3])
doTransformItem(7666,poss[1])
doTransformItem(7834,poss[3])
doTransformItem(item.uid,item.itemid-1)
doTransformItem(getTileItemById(lever,1946).uid,1945)
end
return TRUE
end
This is the original code that I started with. https://otland.net/threads/rookgard-rats-lever.50534/#post507355
Last edited: