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

Opening a secret passage using 2 torches

kokokoko

Veteran OT User
Joined
Feb 4, 2008
Messages
921
Reaction score
257
I want it to do this: When you click on a wall torch with either actionid 2501 or 2502, it checks if the transformed torch will be the same as the other one(they have to match after being clicked). If they do match, open the path(transform the secret wall to a door).

Errors: 0

Problem: The 2 wall torches go lit and unlit when clicking on them, but the wall doesn't turn into a door.

scripts/custom/open_braindeath.lua:
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

torch1 = getThingfromPos({x=1286, y=1257, z=9})
torch2 = getThingfromPos({x=1286, y=1261, z=9})

wall = getThingfromPos({x=1286, y=1259, z=9, stackpos=1})
magic = {x=1286, y=1259, z=9}

if item.actionid == 2501 then
	if item.itemid == 2060 and torch2.itemid == 2061 then
		doTransformItem(wall.uid, 3441)
			effect(magic, 2)
		end

elseif item.actionid == 2502 then
	if item.itemid == 2061 and torch1.itemid == 2060 then
		doTransformItem(wall.uid, 3374)
			effect(magic, 2)
	end
end

if item.itemid == 2060 then
doTransformItem(item.uid, item.itemid+1)
	else
		doTransformItem(item.uid, item.itemid-1)
				end

	return TRUE
end

actions.xml:
Code:
	<action actionid="2501" script="custom/open_braindeath.lua"/>
	<action actionid="2502" script="custom/open_braindeath.lua"/>

Thanks in advance,
//Kokokoko
 
If I understood you corretly
Code:
local positions = {
	wall = {x=1286, y=1259, z=9},
	torches = {
		{x=1286, y=1257, z=9},
		{x=1286, y=1261, z=9}
	}
}

local TORCH_OFF = 2060
local TORCH_ON = 2061

local WALL_OPEN = 3441
local WALL_CLOSED = 3374

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == TORCH_OFF) then
		item.itemid = TORCH_ON
        else
		item.itemid = TORCH_OFF
	end
	doTransformItem(item.uid, item.itemid)

	for _, pos in pairs(positions.torches) do
		local tmp = getTileItemById(pos, item.itemid)
		if(tmp.itemid == 0) then
			return TRUE
		end
	end

	local getWall = getTileItemById(config.wall, WALL_OPEN)
	if(getWall.uid > 0) then
		doTransformItem(getWall.uid, WALL_CLOSED)
	else
		getWall = getTileItemById(config.wall, WALL_CLOSED)
		if(getWall.uid > 0) then
			doTransformItem(getWall.uid, WALL_OPEN)
		end
	end

	doSendMagicEffect(config.wall, 2)
	return TRUE
end

~~ not tested ~~
 
Hehe, sorry if it was a little unclear. I'll test that script in a minute, thank you!

Edit:

The first walltorch(x:1286,y:1257,z:9) can be turned on/off. When doing that, this happens:
I turn it on. Nothing happens.
I turn it off, and the wall transforms correctly.

But it is supposed to do this:
If the torch you click on doesnt have the same itemid as the other torch, there's 2 options:
1. If the other torch has itemid 2060, remove the wall.
2. If the other torch has itemid 2061, create the wall.

Also, nothing happens when i 'use' the second walltorch. There's no errors in the console.

Script as of now:
Code:
local positions = {
	wall = {x=1286, y=1259, z=9},
	torches = {
		{x=1286, y=1257, z=9},
		{x=1286, y=1261, z=9}
	}
}

local TORCH_OFF = 2060
local TORCH_ON = 2061

local WALL_OPEN = 3441
local WALL_CLOSED = 3374

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == TORCH_OFF) then
		item.itemid = TORCH_ON
        else
		item.itemid = TORCH_OFF
	end
	doTransformItem(item.uid, item.itemid)

	for _, pos in pairs(positions.torches) do
		local tmp = getTileItemById(pos, item.itemid)
		if(tmp.itemid == 0) then
			return TRUE
		end
	end

	local getWall = getTileItemById(positions.wall, WALL_OPEN)
	if(getWall.uid > 0) then
		doTransformItem(getWall.uid, WALL_CLOSED)
	else
		getWall = getTileItemById(positions.wall, WALL_CLOSED)
		if(getWall.uid > 0) then
			doTransformItem(getWall.uid, WALL_OPEN)
		end
	end

	doSendMagicEffect(positions.wall, 2)
	return TRUE
end

Edit2: After clicking the torch x times, the server crashed o_O
 
Last edited:
ah you mean something like - now I understood a bit all you said

Currently its working that after click in any torch it checks if both torches have same state (For example - both on) then if there are doors - transform it to wall, otherwise create doors.

So you want to one torch will be like switch, and second for executing that switch? For example first torch if off, and if you use second torch then wall will be closed. Then you can go to torch 1 and turn it on. Now if you use 2 torch then wall will be opened?

lol its really complicated thing to describe xd
 
Yea i know, it's so hard to describe :p

I think you understood now xD

if i click on torch 1/2:
Check if torch1/2.itemid+1 == torch1/2.itemid
if it is, then open wall
also check if torch1/2.itemid-1 == torch1/2.itemid
If it is, then close wall

Does that make it clear? :p
 
Back
Top