• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lever drawbridge (another of QuaS script);

Evan

A splendid one to behold
Senator
Premium User
Joined
May 6, 2009
Messages
7,018
Solutions
1
Reaction score
1,040
Location
United States
QuaS, nothing seems to work! :D
Anyways, I am using your script for the rats drawbridge with levers.

Here is my picture for better detailing:
a099tu.png


lavalever.lua:
PHP:
 -- rook lever by QuaS~
local posi3 = {x=1114, y=1017, z=7} --
poss = {
[1] = {x=1114, y=1020, z=7},
[2] = {x=1114, y=1019, z=7},
[3] = {x=1114, y=1018, z=7},
[4] = {x=1115, y=1020, z=7},
[5] = {x=1115, y=1019, z=7},
[6] = {x=1115, y=1018, z=7}
}
 
local lever = {
[1] = {x=1113, y=1021, z=7},
[2] = {x=1116, y=1017, z=7}
}
local itemids = 5770
function onUse(cid, item, fromPosition, itemEx, toPosition)
        if item.itemid == 1945 then
                doCreateItem(itemids,poss[2])
                if getTileItemById(poss[1],4645).itemid ~= nil then
                        doTransformItem(getTileItemById(poss[1],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(598,poss[2])
                doCreateItem(598,poss[5])
                doCreateItem(4810,poss[1])
                doCreateItem(4810,poss[4])
                doCreateItem(4808,poss[3])
                doCreateItem(4808,poss[6])
                doTransformItem(item.uid,item.itemid-1)
                doTransformItem(getTileItemById(lever[b],1946).uid,1945)
        end
        return TRUE
end

actions.xml:
PHP:
<action actionid="27727" script="other/lavalever.lua" />

ERROR:
[12/01/2011 19:00:45] Lua Script Error: [Action Interface]
[12/01/2011 19:00:45] data/actions/scripts/other/lavalever.lua:onUse

[12/01/2011 19:00:45] luaDoTransformItem(). Item not found

[12/01/2011 19:00:46] Lua Script Error: [Action Interface]
[12/01/2011 19:00:46] data/actions/scripts/other/lavalever.lua:onUse

[12/01/2011 19:00:46] data/actions/scripts/other/lavalever.lua:44: attempt to call global 'getThingFromPos' (a nil value)
[12/01/2011 19:00:46] stack traceback:
[12/01/2011 19:00:46] data/actions/scripts/other/lavalever.lua:44: in function <data/actions/scripts/other/lavalever.lua:17>


What happens ingame with this error:
The lever pulls and just creates a drawbridge tile on POS2, but the lever gets stuck (will not go back).
 
eh
LUA:
 -- rook lever by QuaS~
local posi3 = {x=1114, y=1017, z=7} -- 
local poss = {
	[1] = {{x=1114, y=1020, z=7}, border = 0, newGround = 0, oldGround = 0},
	[2] = {{x=1114, y=1019, z=7}, border = 0 newGround = 0, oldGround = 0},
	[3] = {{x=1114, y=1018, z=7}, border = 0 newGround = 0, oldGround = 0},
	[4] = {{x=1115, y=1020, z=7}, border = 0 newGround = 0, oldGround = 0},
	[5] = {{x=1115, y=1019, z=7}, border = 0 newGround = 0, oldGround = 0},
	[6] = {{x=1115, y=1018, z=7}, border = 0 newGround = 0, oldGround = 0}
}
local lever = {
	[1] = {x=1113, y=1021, z=7},
	[2] = {x=1116, y=1017, z=7}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1945 then
		local tempItem;
		for _,ground in pairs(poss) do
			if(ground.border>0)then
				tempItem = getTileItemById(ground[1],ground.border);
				if(tempItem.uid > 0)then
					doRemoveItem(tempItem.uid);
				end
			end
			doCreateItem(ground.newGround,ground[1]);
		end
		local leverOne, leverTwo;
		for i=1,#lever do
			if lever[i].x == fromPosition.x then
				leverOne = getTileItemById(lever[i], 1945);
				leverTwo = (i == 2) and getTileItemById(lever[1], 1945) or getTileItemById(lever[2], 1945);
			end
		end
		doTransformItem(leverOne.uid,item.itemid+1)
		doTransformItem(leverOTwo.uid,1946)
		
	elseif item.itemid == 1946 then
		for _,ground in pairs(poss) do
			doRelocate(ground[1], posi3);
			doCreateItem(ground.oldGround,ground[1]);
			if(ground.border>0)then
				tempItem = getTileItemById(ground[1],ground.border);
				if(tempItem.uid < 1)then
					doCreateItem(ground.border,ground[1]);
				end
			end
			
		end
		local leverOne, leverTwo;
		for i=1,#lever do
			if lever[i].x == fromPosition.x then
				leverOne = getTileItemById(lever[i], 1945);
				leverTwo = (i == 2) and getTileItemById(lever[1], 1945) or getTileItemById(lever[2], 1945);
			end
		end
		doTransformItem(leverOne.uid,item.itemid-1)
		doTransformItem(leverOTwo.uid,1945)
	end
	return TRUE
end
 
I don't know what it is, but I haven't deeply looked into the error, but here it is:

[13/01/2011 22:43:47] Lua Script Error: [Action Interface]
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:onUse

[13/01/2011 22:43:47] luaDoCreateItem(). Item not found

[13/01/2011 22:43:47] Lua Script Error: [Action Interface]
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:onUse

[13/01/2011 22:43:47] luaDoCreateItem(). Item not found

[13/01/2011 22:43:47] Lua Script Error: [Action Interface]
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:onUse

[13/01/2011 22:43:47] luaDoCreateItem(). Item not found

[13/01/2011 22:43:47] Lua Script Error: [Action Interface]
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:onUse

[13/01/2011 22:43:47] luaDoCreateItem(). Item not found

[13/01/2011 22:43:47] Lua Script Error: [Action Interface]
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:onUse

[13/01/2011 22:43:47] luaDoCreateItem(). Item not found

[13/01/2011 22:43:47] Lua Script Error: [Action Interface]
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:onUse

[13/01/2011 22:43:47] luaDoCreateItem(). Item not found

[13/01/2011 22:43:47] Lua Script Error: [Action Interface]
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:onUse

[13/01/2011 22:43:47] data/global.lua:705: attempt to call global 'getThingFromPos' (a nil value)
[13/01/2011 22:43:47] stack traceback:
[13/01/2011 22:43:47] data/global.lua:705: in function 'getTileItemById'
[13/01/2011 22:43:47] data/actions/scripts/other/matrixlever.lua:31: in function <data/actions/scripts/other/matrixlever.lua:16>
 
Okay, no problem, I'm just frustrated that there's no 8.62 or 8.7 version of 0.3 distro, only 8.54.
 
Remove function getTileItemById from global.lua to let it use the one from sources.
LUA:
local t = {
	{{x=1114, y=1020, z=7}, border = 4810, newGround = 5768, oldGround = 598},
	{{x=1114, y=1019, z=7}, newGround = 1284, oldGround = 598},
	{{x=1114, y=1018, z=7}, border = 4808, newGround = 5769, oldGround = 598},
	{{x=1115, y=1020, z=7}, border = 4810, newGround = 5768, oldGround = 598},
	{{x=1115, y=1019, z=7}, newGround = 1284, oldGround = 598},
	{{x=1115, y=1018, z=7}, border = 4808, newGround = 5769, oldGround = 598}
}
local relocate = {x=1114, y=1017, z=7}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local k = item.itemid == 1945
	for _, v in ipairs(t) do
		if not k then
			doRelocate(v[1], relocate)
		end
		doCreateItem(k and v.newGround or v.oldGround, 1, v[1])
		if v.border then
			if k then
				doRemoveItem(getTileItemById(v[1], v.border).uid)
			else
				doCreateItem(v.border, 1, v[1])
			end
		end
	end
	doTransformItem(27727, k and 1946 or 1945)
	doTransformItem(27728, k and 1946 or 1945)
	return true
end
Set unique id of levers to 27727 and 27728 (the other one)
 
Back
Top