HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Scope Problem

04-26-2009, 03:44 PM#1
Uzaku
Hi,
I've got a problem with scopes.
First i wrote a funtion SummonShield in a trigger.
Later i wrote a function RemoveShield in another trigger, and because i need those functions
at some other places too, I createt a new Trigger at the top, cleared him and copied my functions in a scope in that trigger.

Here is the trigger:
Collapse JASS:
scope 

function SummonShield takes unit who returns nothing
    local unit temp = CreateUnit(GetOwningPlayer(who), DefPos, GetUnitX(who), GetUnitY(who), GetUnitFacing(who))
    local effect Effekt1 = AddSpecialEffectTarget("Abilities\\Spells\\Human\\MagicSentry\\MagicSentryCaster.mdl", temp, "overhead")
    local effect Effekt2 = AddSpecialEffectTarget("Abilities\\Spells\\Human\\DevotionAura\\DevotionAura.mdl", temp, "origin")
    local effect Effekt3 = AddSpecialEffectTarget("Abilities\\Spells\\Human\\ManaShield\\ManaShieldCaster.mdl", temp, "origin")
        
    call SetEffekt1(temp, Effekt1)
    call SetEffekt2(temp, Effekt2)
    call SetEffekt3(temp, Effekt3)
    
    call SetDefPosforUnit(who, temp)
    call SetUnitforDefPos(temp, who)
    
    set Effekt1 = null
    set Effekt2 = null
    set Effekt3 = null
    set temp = null
    set who = null
    
endfunction

function RemoveShield takes unit who returns nothing
    local unit dp = GetDefPosforUnit(who)
    call ResetUnitforDefPos(dp)
    
    call DestroyEffect(GetEffekt1(who))
    call DestroyEffect(GetEffekt2(who))
    call DestroyEffect(GetEffekt3(who))
    call RemoveUnit(dp)
    
    call ResetEffekt1(who)
    call ResetEffekt2(who)
    call ResetEffekt3(who)
    call ResetDefPosforUnit(who)
    
    set dp = null
    
endfunction

endscope

The result is an error: undeclared function SummonShield and undeclared function RemoveShield. But Why??
I also tried to give a name to the scope also no effekt. Did i get something wrong with scopes ? I thought they are like librarys with the exeption not to push the code to the top, like i need here, because the code must be under the header

greetings Uzaku
04-26-2009, 05:08 PM#2
Vexorian
Quote:
Did i get something wrong with scopes ?
The lack of name is one thing, I am also a little unable to see what you are using the scope for as nothing in there is public/private and you don't use a initializer either.

Since SummonShield is not ever called in the code you posted, I guess you call it from some other place, it is never guaranteed this other code will actually be placed bellow this scope, so maybe that's the problem.

perhaps if you changed the scope to a library and you gave it a name...
04-26-2009, 05:39 PM#3
Uzaku
The Reason i used Scope, is that i wanted to have the possibility to define these functions in an own trigger, which would not be seen, with only the functions in it, if i dont use scope or library. But i cant use library because that would place it about the Header, and i need it under the header. Whether the scope's got a name or not has no effect

You are right, the code of the scope is below all other triggers, can i change that?
04-26-2009, 06:25 PM#4
Vexorian
Quote:
i need it under the header
No, you don't.

Quote:
You are right, the code of the scope is below all other triggers, can i change that?
With a library.

If your code in the header needs to use these functions, then just turn the header into a library that requires your new library.