new wild rune tfs 1.x

vexler222

Member
Joined
Apr 22, 2012
Messages
559
Solutions
9
Reaction score
20
Hi, can someone help me with this rune? How to block create a new wild in a tree or others like a table/counter/barrel..
Now i maked, block for some ID's but i can't add all trees id to this script, now when i try spawn this wild on tree i got error

Code:
Lua Script Error: [Scripts Interface]
C:\Users\ChrisPC\Desktop\CustomOT\data\scripts\spells\super_wild.lua:callback
...ChrisPC\Desktop\CustomOT\data\scripts\spells\super_wild.lua:53: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
        [C]: at 0x7ff667d2ff20
        [C]: in function 'pairs'
        ...ChrisPC\Desktop\CustomOT\data\scripts\spells\super_wild.lua:53: in function <...ChrisPC\Desktop\CustomOT\data\scripts\spells\super_wild.lua:38>

Code:
local config = {
    name = "Super Wild Rune",
    runeId = 2272, -- id of the rune you are going to use
    charges = 3,
    rebirth = 0,
    level = 1,
    magicLevel = 0,
    cooldown = 2000,
    groupCooldown = 2000,
    seconds = 10,
    itemId = 5392, -- id of the item that will be created in the destination position
    colour = TEXTCOLOR_MAYABLUE
}

local function startCooldownText(seconds, position, toPos)
    if seconds > 0 then
        local spectators = Game.getSpectators(position, false, true, 7, 7, 7, 7)
        if #spectators > 0 then
            Game.sendAnimatedText(seconds, position, TEXTCOLOR_MAYABLUE)
        end
        addEvent(startCooldownText, 1000, seconds - 1, position, toPos)
    else
        local tile = Tile(position)
        if tile then
            local item = tile:getItemById(config.itemId)
            if item then
                item:remove()
            end
        end
    end
end

local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)

local rune = Spell(SPELL_RUNE)

function rune.onCastSpell(player, variant, isHotkey)
    local position = variant:getPosition()
    local tile = Tile(position)
    local toPos = Position(position) - Position(0, 0, 1)
    local toTile = Tile(toPos)

    if Tile(position):getItemById(5392) or Tile(position):getItemById(430) then
        local ppos = player:getPosition()
        player:sendCancelMessage('There is not enough room.')
        ppos:sendMagicEffect(3)
        return true
    end

    for i, creature in pairs(tile:getCreatures()) do
        local ppos = player:getPosition()
        player:sendCancelMessage('There is not enough room.')
        ppos:sendMagicEffect(3)
        return true
    end

    if combat:execute(player, variant) then
        if tile then
            if not toTile then
                Game.createTile(toPos)
            end

            Game.createItem(config.itemId, 1, position)
            startCooldownText(config.seconds, position, toPos)
        end
        return true
    end
    return false
end

rune:level(config.level)
rune:groupCooldown(config.groupCooldown)
rune:isBlocking()
rune:runeId(config.runeId)
rune:charges(config.charges)
rune:allowFarUse(true)
rune:cooldown(config.cooldown)
rune:id(86)
rune:magicLevel(config.magicLevel)
rune:name(config.name)
rune:group("attack")
rune:register()
 
Solution
Try adding
Lua:
if not tile:isWalkable() then
    -- unable to walk here, so assume that spell cannot be cast here.
    player:sendCancelMessage("There is not enough room.")
    return false
end

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,036
Solutions
493
Reaction score
4,207
Try adding
Lua:
if not tile:isWalkable() then
    -- unable to walk here, so assume that spell cannot be cast here.
    player:sendCancelMessage("There is not enough room.")
    return false
end
 
Solution
OP
OP
vexler222

vexler222

Member
Joined
Apr 22, 2012
Messages
559
Solutions
9
Reaction score
20
Try adding
Lua:
if not tile:isWalkable() then
    -- unable to walk here, so assume that spell cannot be cast here.
    player:sendCancelMessage("There is not enough room.")
    return false
end

yea, thats it! Im looked for something like this, but i didn't know is a "IsWalkable", i thiking about something like "isGround" :D

Thanks bro
 

Xikini

I whore myself out for likes
Support Team
Joined
Nov 17, 2010
Messages
6,036
Solutions
493
Reaction score
4,207
yea, thats it! Im looked for something like this, but i didn't know is a "IsWalkable", i thiking about something like "isGround" :D

Thanks bro
Lot's of fun and useful functions in data/lib/core

For this one specifically it's in core/tile.lua
 
Top