function onCastSpell(cid, var)
doTeleportThing(cid,getClosestFreeTile(cid, getCreaturePosition(getCreatureTarget(cid))))
return true
end
[15/06/2012 17:15:20] [Error - Spell Interface]
[15/06/2012 17:15:20] data/spells/scripts/players/swift lux.lua:onCastSpell
[15/06/2012 17:15:20] Description:
[15/06/2012 17:15:20] data/spells/scripts/players/swift lux.lua:28: attempt to index local 'aux' (a nil value)
[15/06/2012 17:15:20] stack traceback:
[15/06/2012 17:15:20] data/spells/scripts/players/swift lux.lua:28: in function <data/spells/scripts/players/swift lux.lua:8>
function onCastSpell(cid, var)
local pos = getCreaturePosition(getCreatureTarget(cid))
for x = -1, 1, 1 do
for y = -1, 1, 1 do
local pos2 = pos
pos2.x = pos2.x + x
pos2.y = pos2.y + y
if isWalkable(pos2) then
doTeleportThing(cid, pos2)
return true
end
end
end
doTeleportThing(cid, pos)
return true
end
function isWalkable(cid,pos)
pos.stackpos = 253
if doTileQueryAdd(cid, pos) == 1 and getTilePzInfo(pos) == FALSE and isCreature(getThingFromPos(pos).uid) == FALSE then
return TRUE
end
return FALSE
end
function isWalkable(cid, pos)
pos.stackpos = 0
if getTileThingByPos(pos).uid ~= 0 then
local n = getTileInfo(pos)
if n.protection == false and n.house == false and getTopCreature(pos).uid == 0 and doTileQueryAdd(cid, pos) == RETURNVALUE_NOERROR then
return true
end
end
end
function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
local pos = getCreaturePosition(target)
local closest = getClosestFreeTile(cid, pos, false, false)
if(isPlayer(cid)) then
if(isWalkable(cid, closest)) then
doTeleportThing(cid, closest, true)
doSendMagicEffect(closest, CONST_ME_TELEPORT)
else
doPlayerSendCancel(cid, "There is no space to teleport to your target.")
return false
end
end
return true
end