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

I need help with this spell.

Cadyan

Well-Known Member
Joined
Mar 30, 2008
Messages
844
Reaction score
63
This code should allow a player to teleport 2 squares forward, if the specified square is not a PZ or House Tile.
There is no error in the server log, but when I cast the spell, it ALWAYS says "You cannot do that." in orange writing.
How can I edit this script to work properly? I also do NOT want players to teleport onto walls, or trees, so if someone could edit it a bit further for me that would be nice.
+++rep for help
The script was made by me. I am using Mystic Spirit 9.6.


Code:
function onCastSpell(cid, var)

	local DIREC = getPlayerLookDir(cid)
	local PPOS = getPlayerPosition(cid)
	local NEWPOS1 = {x = PPOS.x, y = PPOS.y - 2, z = PPOS.z, stackpos = 255}
	local NEWPOS2 = {x = PPOS.x + 2, y = PPOS.y, z = PPOS.z, stackpos = 255}
	local NEWPOS3 = {x = PPOS.x, y = PPOS.y + 2, z = PPOS.z, stackpos = 255}
	local NEWPOS4 = {x = PPOS.x - 2, y = PPOS.y, z = PPOS.z, stackpos = 255}

	if DIREC == 0 then
		if getTilePzInfo(NEWPOS1) == 0 and getTileHouseInfo(NEWPOS1) == 0 then
			doTeleportThing(cid, NEWPOS1, FALSE)
			doCreatureSay(cid, "Blink Up!", TALKTYPE_ORANGE_1)
		else 
			doCreatureSay(cid, "You cannot do that.", TALKTYPE_ORANGE_1)
	end
end

	if DIREC == 1 then
		if getTilePzInfo(NEWPOS2) == 0 and getTileHouseInfo(NEWPOS2) == 0 then
			doTeleportThing(cid, NEWPOS2, FALSE)
			doCreatureSay(cid, "Blink Right!", TALKTYPE_ORANGE_1)
		else 
			doCreatureSay(cid, "You cannot do that.", TALKTYPE_ORANGE_1)
	end
end

	if DIREC == 2 then
		if getTilePzInfo(NEWPOS3) == 0 and getTileHouseInfo(NEWPOS3) == 0 then
			doTeleportThing(cid, NEWPOS3, FALSE)
			doCreatureSay(cid, "Blink Down!", TALKTYPE_ORANGE_1)
		else 
			doCreatureSay(cid, "You cannot do that.", TALKTYPE_ORANGE_1)
	end
end

	if DIREC == 3 then
		if getTilePzInfo(NEWPOS4) == 0 and getTileHouseInfo(NEWPOS4) == 0 then
			doTeleportThing(cid, NEWPOS4, FALSE)
			doCreatureSay(cid, "Blink Left!", TALKTYPE_ORANGE_1)
		else 
			doCreatureSay(cid, "You cannot do that.", TALKTYPE_ORANGE_1)
	end
end

return TRUE
end
 
Last edited:
LUA:
function canAddThing(pos)
    local tile = getTileThingByPos({x=pos.x, y=pos.y, z=pos.z, stackpos=0})
    return tile.uid ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not getTilePzInfo(pos) and not getTileInfo(pos).house
end


function onCastSpell(cid, var)	
	local PPOS = getThingPos(cid)
	local NEWPOS = {
			[0] = {x = PPOS.x, y = PPOS.y - 2, z = PPOS.z},
			[1] = {x = PPOS.x + 2, y = PPOS.y, z = PPOS.z},
			[2] = {x = PPOS.x, y = PPOS.y + 2, z = PPOS.z},
			[3] = {x = PPOS.x - 2, y = PPOS.y, z = PPOS.z}
		}
	local DIREC = NEWPOS[getCreatureLookDirection(cid)]
	if canAddThing(DIREC) then
		doTeleportThing(cid, DIREC, false)
		doCreatureSay(cid, "Blink Up!", TALKTYPE_ORANGE_1)
	else 
		doCreatureSay(cid, "You cannot do that.", TALKTYPE_ORANGE_1)
	end
	return true
end
 
[02/03/2013 02:42:13] Lua Script Error: [Spell Interface]
[02/03/2013 02:42:14] data/spells/scripts/demon/blink.lua: onCastSpell
[02/03/2013 02:42:14] data/spells/scripts/demon/blink.lua:15: attempt to call global 'getCreatureLookDirection' (a nil value)
[02/03/2013 02:42:14] stack traceback:
[02/03/2013 02:42:14] [C]: in function 'getCreatureLookDirection'
[02/03/2013 02:42:14] data/spells/scripts/demon/blink.lua:15: in function <data/spells/scripts/demon/blink.lua:7>

By the way, I am using Mystic Spirit 9.6.
 
Back
Top