does anyone know why is this not working, ability work normaly and cast this script...

Does anyone know why this abilty wont spawn units, It does not show any errors problem is somewhere here...

function spawn( keys )

local caster = keys.caster

local spellName = keys.SpellName

Timers:CreateTimer(5, function() if caster:HasAbility(spawner7) then local unit = CreateUnitByName("miligun", position, true, caster , caster , caster:GetTeamNumber()) end return 1.0
end) end

Comments

  • Posts: 182

    you must be getting errors with that code. spawner7 is undefined, it needs to be a string.

    caster:HasAbility("spawner7") 
    

    position is also undefined.

    you should really read the tutorials https://moddota.com/forums/discussion/135/beginners-guide-to-dota-scripting

  • edited January 9 Posts: 12

    I read that many times look:

    function spfootman( event )

    local target = event.target
    
    local spellName = event.SpellName
    
    local repeat_interval = 2 -- Rerun this timer every *repeat_interval* game-time seconds
    
    local start_after = 1 -- Start this timer *start_after* game-time seconds later
    
    
        --if    target:HasAbility(spellName) then
        Timers:CreateTimer(start_after, function()
        SpawnCreeps()
        return repeat_interval
    end)
    --end
    

    end

    function SpawnCreeps()
    
        local point = Entities:FindByName( nil, "spawner22"):GetAbsOrigin()
        local unit = CreateUnitByName("footman", point, true, nil, nil, DOTA_TEAM_NEUTRALS)
    end     
    

    this is working normaly, but if i remove '--' on 'if' and 'end' as u can see then it wont work and yeah i did define ability ;

    "RunScript"

    { "ScriptFile" "spawn_footman.lua" "Function" "spfootman" "SpellName" "spawn_footman" }