• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action [RELEASE] PoI - 16 levers (in order!) TFS 0.3.4pl2 [Optimized?]

jerryb1988

Member
Joined
Mar 10, 2008
Messages
79
Reaction score
5
Well, I couldn't seem to find a good solid PoI script anywhere. The one I've been using had a separate folder and a file for all the 16 levers and it was messy. What I did was combine all this into one simple .lua file. This is only part one of many I'm going to try and make. I don't create many scripts myself and I'd like to give back to the community for all they have given me so here's my script:

USAGE: Map editor
1st lever = Uniqueid 3001
2nd lever = Uniqueid 3002
..
16th lever = Uniqueid 3016

Actions.xml
Code:
<action fromuid="3001" touid="3016" event="script" value="quests/poi/16levers.lua"/>

actions/scripts/poi/16levers.lua
Code:
-- PoI 16 levers script. Used for the 16 levers you must flip in order after the vocation walls.
-- Created by jerryb1988 from otland.net

local levers = {
	[3001] = {x=31697, y=31964, z=11, stackpos=1}, --Bridge lever flipped?
	[3002] = {x=31770, y=31958, z=12, stackpos=1}, --1st lever flipped?
	[3003] = {x=31787, y=31952, z=14, stackpos=1}, --2nd lever flipped?
	[3004] = {x=31738, y=31976, z=14, stackpos=1}, --3rd lever flipped?
	[3005] = {x=31785, y=31973, z=15, stackpos=1}, --4th lever flipped?
	[3006] = {x=31783, y=31954, z=12, stackpos=1}, --5th lever flipped?
	[3007] = {x=31742, y=31942, z=12, stackpos=1}, --6th lever flipped?
	[3008] = {x=31783, y=31979, z=13, stackpos=1}, --7th lever flipped?
	[3009] = {x=31749, y=31983, z=14, stackpos=1}, --8th lever flipped?
	[3010] = {x=31739, y=31983, z=12, stackpos=1}, --9th lever flipped?
	[3011] = {x=31743, y=31956, z=13, stackpos=1}, --10th lever flipped?
	[3012] = {x=31782, y=31961, z=13, stackpos=1}, --11th lever flipped?
	[3013] = {x=31770, y=31989, z=13, stackpos=1}, --12th lever flipped?
	[3014] = {x=31746, y=31990, z=13, stackpos=1}, --13th lever flipped?
	[3015] = {x=31756, y=31988, z=13, stackpos=1}, --14th lever flipped?
	[3016] = {x=31770, y=31978, z=14, stackpos=1}  --15th lever flipped?
}
local stonepositions = {
	{x=31747, y=31957, z=12, stackpos=1}, -- stone 1 to remove after flipping lever 16
	{x=31748, y=31957, z=12, stackpos=1} -- stone 2 to remove after flipping lever 16
}

function onUse(cid, item, frompos, item2, topos)
	
	if (item.uid > 3000 and item.uid < 3017) and item.itemid == 1945 then -- if its our uniqueid's above and lever is <- (NOT flipped)
		if getThingFromPos(levers[item.uid]).itemid == 1946 then -- checks if the previous lever is -> (flipped)
			if item.uid == 3016 and item.itemid == 1945 then -- check if its last lever
				doPlayerSendTextMessage(cid,22, "You flipped all the levers! Continue on!")
				for i = 1, #stonepositions do
					doRemoveItem(getThingFromPos(stonepositions[i]).uid, 1) -- removes the stone(s) from the position(s) in stonepositions array
					doSendMagicEffect(stonepositions[i], 4) -- sends animation effect to removed stone(s) (change the # 4 for different animation)
				end
			else -- if its not the last lever
				doPlayerSendTextMessage(cid,22, "You flipped lever "..(item.uid - 3000)..". Now find the next one!") -- tells the player what lever they flipped
			end
			doTransformItem(item.uid,item.itemid+1) -- "flip" the lever ->
		else
			doPlayerSendCancel(cid,"Previous lever not flipped. Levers must be flipped in order.") -- if previous lever is NOT flipped
		end
	elseif item.itemid == 1946 then -- if the lever was flipped already
		doTransformItem(item.uid,item.itemid-1) -- flip it back
	else
		doPlayerSendCancel(cid,"Sorry, not possible.") -- error control
	end

	return TRUE
end

KNOWN BUGS: After you flip the 16th lever, if someone flips it back the stones don't appear (it's not coded to) and if they flip it again it will say this in console:
Lua Script Error: [Action Interface]
data/actions/scripts/quests/poi2/16levers.lua:eek:nUse

luaDoRemoveItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/quests/poi2/16levers.lua:eek:nUse

luaDoRemoveItem(). Item not found
 
Last edited:
would be nice if someone could rewrite it and make full working :p
 
I'm using this, for me it works fine enough, you can also improve this to transform item back onEvent with time 15 (?) minutes.
Code:
<action actionid="xxx1" event="script" value="quests/poi/16levers1.lua" />
Lua:
function onUse(cid, item, frompos, item2, topos)
 
if item.actionid == xxx1 then

leverpos1 = {x=2920, y=2330, z=11, stackpos=1}
lever1 = getThingfromPos(leverpos1)
leverpos2 = {x=2937, y=2324, z=13, stackpos=1}
lever2 = getThingfromPos(leverpos2)
leverpos3 = {x=2889, y=2348, z=13, stackpos=1}
lever3 = getThingfromPos(leverpos3)
leverpos4 = {x=2935, y=2345, z=14, stackpos=1}
lever4 = getThingfromPos(leverpos4)
leverpos5 = {x=2933, y=2326, z=11, stackpos=1}
lever5 = getThingfromPos(leverpos5)
leverpos6 = {x=2890, y=2315, z=11, stackpos=1}
lever6 = getThingfromPos(leverpos6)
leverpos7 = {x=2933, y=2351, z=12, stackpos=1}
lever7 = getThingfromPos(leverpos7)

wallpos = {x=2897, y=2329, z=11, stackpos=1}
wall = getThingfromPos(wallpos)

if item.itemid == 1945 then
    doTransformItem(item.uid,1946)
  elseif item.itemid == 1946 then
    doTransformItem(item.uid,1945)
end

if (item.actionid == xxx1 and lever1.itemid == 1946 and lever2.itemid == 1946 and lever3.itemid == 1946 and lever4.itemid == 1946 and lever5.itemid == 1946 and wall.itemid == 0) then
doCreateItem(1304,1,wallpos)
elseif (item.actionid == 7068 and lever1.itemid == 1946 and lever2.itemid == 1946 and lever3.itemid == 1946 and lever4.itemid == 1946 and lever5.itemid == 1946 and wall.itemid == 1304) then
doRemoveItem(wall.uid,1)
else 
doPlayerSendCancel(cid,"Sorry, not possible.") 
end 
end
return true
end
Code:
<action actionid="xxx2" event="script" value="quests/poi/16levers2.lua" />
Lua:
function onUse(cid, item, frompos, item2, topos)
 
if item.actionid == xxx2 then

leverpos1 = {x=2889, y=2355, z=11, stackpos=1}
lever1 = getThingfromPos(leverpos1)
leverpos2 = {x=2893, y=2328, z=12, stackpos=1}
lever2 = getThingfromPos(leverpos2)
leverpos3 = {x=2932, y=2333, z=12, stackpos=1}
lever3 = getThingfromPos(leverpos3)
leverpos4 = {x=2920, y=2361, z=12, stackpos=1}
lever4 = getThingfromPos(leverpos4)
leverpos5 = {x=2896, y=2362, z=12, stackpos=1}
lever5 = getThingfromPos(leverpos5)
leverpos6 = {x=2906, y=2360, z=12, stackpos=1}
lever6 = getThingfromPos(leverpos6)
leverpos7 = {x=2920, y=2350, z=13, stackpos=1}
lever7 = getThingfromPos(leverpos7)

wallpos = {x=2898, y=2329, z=11, stackpos=1}
wall = getThingfromPos(wallpos)

if item.itemid == 1945 then
    doTransformItem(item.uid,1946)
  elseif item.itemid == 1946 then
    doTransformItem(item.uid,1945)
end

if (item.actionid == xxx2 and lever1.itemid == 1946 and lever2.itemid == 1946 and lever3.itemid == 1946 and lever4.itemid == 1946 and lever5.itemid == 1946 and wall.itemid == 0) then
doCreateItem(1304,1,wallpos)
elseif (item.actionid == 7067 and lever1.itemid == 1946 and lever2.itemid == 1946 and lever3.itemid == 1946 and lever4.itemid == 1946 and lever5.itemid == 1946 and wall.itemid == 1304) then
doRemoveItem(wall.uid,1)
else 
doPlayerSendCancel(cid,"Sorry, not possible.") 
end 
end
return true
end
__________________
klekSu.png

You are welcome on kleksoria.com!
Please visit new open tibia forum with it's own ots list. otservers.net!
 
Last edited:
The scripts are great, but it would be better if the stones appeared 15 minutes later, and all levers too.

I have this script, you pull all levers in the right order, and on the last lever, a timer starts. When the time is up, all levers return to 1945 and stones appear and you have to do all over again.

I will release scripts from time to time when i fell like it. But now, since ppl seems to want this... I release script for all 16 levers.
 
double post, sorry. If neccessary, mod please remove THIS post.
 
Back
Top