[vJass] Error - "Function redeclared"

Carl-Fredrik

New Member
Reaction score
51
Hey again... the second trigger I made worked on first try (Yay!), the second one is causing a mess though.

First one:

JASS:
scope Revive initializer Init
function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == false
endfunction

function Actions takes nothing returns nothing
    local location UnitLoc = GetUnitLoc(GetTriggerUnit())
    call PolledWait(10)
    call CreateNUnitsAtLoc( 1, GetUnitTypeId(GetTriggerUnit()), GetOwningPlayer(GetTriggerUnit()), UnitLoc, bj_UNIT_FACING )
    set UnitLoc = null
    call RemoveLocation (UnitLoc)
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
endfunction
endscope


Second one:

JASS:
scope ReviveHeroes initializer Init
function Conditions takes nothing returns boolean
    return IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) == true
endfunction

function Actions takes nothing returns nothing
    local location HeroLoc = GetUnitLoc(GetTriggerUnit())
    call PolledWait(10)
    call ReviveHeroLoc(GetTriggerUnit(), HeroLoc, true)
    set HeroLoc = null
    call RemoveLocation (HeroLoc)
endfunction

//===========================================================================
function Init takes nothing returns nothing
    local trigger trig = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( trig, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( trig, Condition( function Conditions ) )
    call TriggerAddAction( trig, function Actions )
endfunction
endscope



Seems like I can't use the same name for the Conditions / Actions / Initializer in each trigger... I thought I could, so I just had to ask, do I have to name them different each time??

Thanks in advance!

// Carl-Fredrik
 

Romek

Super Moderator
Reaction score
963
use
JASS:
private function name takes nothing returns nothing
// or
public function name takes nothing returns nothing


to make the function uncallable by another trigger/function.
(or make it require the scopename_prefix in 'public's case)
 

Builder Bob

Live free or don't
Reaction score
249
your init triggers must be named
JASS:
public function InitTrig takes nothing returns nothing

if you want them to be run on map init.
Also make sure the scope name is the exact same (case sensitive) as your trigger name. (the name in the list to the left)
 
Reaction score
456
> public function InitTrig takes nothing returns nothing
It's better to use initializer and a private function named Init or so. This way the actual triggers name does not matter a shit.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top