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

SOLVED [remove]

tompan

Member
Joined
Dec 13, 2008
Messages
646
Reaction score
23
Location
Sweden
i get this error in my console when i open the door..

Is it because i miss the fuction "direction" or what?

Can you make it like it push you inside the door?

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/doors/gateofexp_closed.lua:onUse

data/actions/scripts/doors/gateofexp_closed.lua:42: attempt to call global 'getD
irectionTo' (a nil value)
stack traceback:
        data/actions/scripts/doors/gateofexp_closed.lua:42: in function <data/ac
tions/scripts/doors/gateofexp_closed.lua:5>

same with quest doors..
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/doors/questdoor_closed.lua:onUse

data/actions/scripts/doors/questdoor_closed.lua:22: attempt to call global 'getD
irectionTo' (a nil value)
stack traceback:
        data/actions/scripts/doors/questdoor_closed.lua:22: in function <data/ac
tions/scripts/doors/questdoor_closed.lua:3>


level door script.
Code:
-- ActionIDs:
function onUse(cid, item, frompos, item2, topos)
	local isLevelDoor = (item.actionid >= 1001 and item.actionid <= 1999)
	local isVocationDoor = (item.actionid >= 2001 and item.actionid <= 2008)

	if not(isLevelDoor or isVocationDoor) then
		-- Make it a normal door
		doTransformItem(item.uid, item.itemid+1)
		return TRUE
	end

	local canEnter = true
	if(isLevelDoor and getPlayerLevel(cid) < (item.actionid-1000)) then
		canEnter = false
	end

	if(isVocationDoor) then
		local doorVoc = item.actionid-2000
		if (doorVoc == 1 and not(isSorcerer(cid))) or
		   (doorVoc == 2 and not(isDruid(cid)))    or
		   (doorVoc == 3 and not(isPaladin(cid)))  or
		   (doorVoc == 4 and not(isKnight(cid)))   or
		   (doorVoc ~= getPlayerVocation(cid))     then
			canEnter = false
		end
	end

	if not(canEnter or getPlayerAccess(cid) == 0) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Only the worthy may pass.")
		return TRUE
	end

	doTransformItem(item.uid, item.itemid+1)
	local canGo = (queryTileAddThing(cid, frompos, bit.bor(2, 4)) == RETURNVALUE_NOERROR) --Veryfies if the player can go, ignoring blocking things
	if not(canGo) then
		return FALSE
	end

	local dir = getDirectionTo(getPlayerPosition(cid), frompos)
	doMoveCreature(cid, dir)
	return TRUE
end

quest door script:

Code:
-- Player with storage value of the item's actionid set to 1 can open

function onUse(cid, item, frompos, item2, topos)
	if(item.actionid == 0) then
		-- Make it a normal door
		doTransformItem(item.uid, item.itemid+1)
		return TRUE
	end

	local canEnter = (getPlayerStorageValue(cid, item.actionid) == 1)
	if not(canEnter) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "The door is sealed against unwanted intruders.")
		return TRUE
	end

	doTransformItem(item.uid, item.itemid+1)
	local canGo = (queryTileAddThing(cid, frompos, bit.bor(2, 4)) == RETURNVALUE_NOERROR) --Veryfies if the player can go, ignoring blocking things
	if not(canGo) then
		return FALSE
	end

	local dir = getDirectionTo(getPlayerPosition(cid), frompos)
	doMoveCreature(cid, dir)
	return TRUE
end
 
Last edited:
Code:
function getDirectionTo(pos1, pos2)
	local dir = NORTH
	if(pos1.x > pos2.x) then
		dir = WEST
		if(pos1.y > pos2.y) then
			dir = NORTHWEST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHWEST
		end
	elseif(pos1.x < pos2.x) then
		dir = EAST
		if(pos1.y > pos2.y) then
			dir = NORTHEAST
		elseif(pos1.y < pos2.y) then
			dir = SOUTHEAST
		end
	else
		if(pos1.y > pos2.y) then
			dir = NORTH
		elseif(pos1.y < pos2.y) then
			dir = SOUTH
		end
	end
	return dir
end

Add that in ur functions.lua or in global.lua /\ support's avesta


King Regards jeffry,
 
Back
Top