Er, sou meio newbie quanto a runas. Como exatamente elas funcionam? São actions? No código delas, é necessário setar o exhaust/remover o item, ou isso já é configurado na tag da mesma? Se puder me explicar (: (ps: um exemplo de script também seria de grande ajuda)
Pra todo caso, fiz uma action básica que cumpre seus requisitos. Se quiser, você pode adaptá-la para o formato de um código de runa.
local function isWalkable(pos, creature, proj, pz)-- by Nord
if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
if getTopCreature(pos).uid > 0 and creature then return false end
if getTileInfo(pos).protection and pz then return false, true end
local n = not proj and 3 or 2
for i = 0, 255 do
pos.stackpos = i
local tile = getTileThingByPos(pos)
if tile.itemid ~= 0 and not isCreature(tile.uid) then
if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
return false
end
end
end
return true
end
function onUse(cid, item, fromPosition, item2, toPosition)
local effect = xxx --Efeito.
local exh = xxx --Exhaust, em segundos.
if isCreature(item2.uid) and not isNpc(item2.uid) then
if getPlayerStorageValue(cid, 1870) > os.time() then
local msg = "Wait %d seconds to use this rune again."
return doPlayerSendCancel(cid, msg:format(getPlayerStorageValue(cid, 1870) - os.time()))
end
local positions = {
[0] = {x = getThingPos(cid).x, y = getThingPos(cid).y - 1, z = getThingPos(cid).z},
[1] = {x = getThingPos(cid).x + 1, y = getThingPos(cid).y, z = getThingPos(cid).z},
[2] = {x = getThingPos(cid).x, y = getThingPos(cid).y + 1, z = getThingPos(cid).z},
[3] = {x = getThingPos(cid).x - 1, y = getThingPos(cid).y, z = getThingPos(cid).z},
}
local lookdir = getCreatureLookDirection(cid)
local newPosition = positions[lookdir]
if not isWalkable(newPosition) then
newPosition = getClosestFreeTile(cid, getThingPos(cid))
end
if newPosition then
doTeleportThing(item2.uid, newPosition)
doSendMagicEffect(newPosition, effect)
doSendMagicEffect(toPosition, effect)
setPlayerStorageValue(cid, 1870, os.time() + exh)
else
return doPlayerSendCancel(cid, "Couldn't execute the rune.")
end
else
return doPlayerSendCancel(cid, "Use this rune only on creatures.")
end
return true
end