• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Scopes and Librarys question

Status
Not open for further replies.
Level 12
Joined
Dec 10, 2008
Messages
850
Ok, so I've been getting back into making spells and such, but I need to "refresh" abit of my memory, since I can't seem to find anything that really answers this.

Now, I know scopes don't let functions outside the scope use anything enclosed in scopes, but can functions inside a scope acsses functions inside librarys and share these functions with other triggers? If so it would be like calling any other functions, right? Or would that require a certain phrase or other things?

Could I also declare globals and use them for other spells? like one big block for 3-4 spells that share them?

I need this for using a few shared functions and structs with other spells, and making customizing spells easier with only one place to change details for mutiple spells.

Thanks to whomever helps (and rep)
 
Level 4
Joined
May 17, 2005
Messages
94
Now, I know scopes don't let functions outside the scope use anything enclosed in scopes,
Sure they do, unless said function is a 'private' function. The only requirement is the basic JASS one of one function being about another.

but can functions inside a scope acsses functions inside librarys and share these functions with other triggers? If so it would be like calling any other functions, right? Or would that require a certain phrase or other things?
I'm not entirely sure what you mean. Functions within scopes can certainly access any regular or public functions in any libraries all they want, since all libraries wind up above scopes. Not sure what you mean by 'sharing with other triggers.'

Could I also declare globals and use them for other spells? like one big block for 3-4 spells that share them?
Globals are global. Unless a global within something is private, it can be used elsewhere.
 
Level 10
Joined
Aug 19, 2008
Messages
491
JASS:
scope MyScope
    private function MyFunc1 takes nothing returns nothing
        //Actions
    endfunction

    public function MyFunc2 takes nothing returns nothing
        //Actions
    endfunction

    function MyFunc3 takes nothing returns nothing
        //Actions
    endfunction


    function TestCaller takes nothing returns nothing
        call MyFunc1() //compiles
        call MyFunc2() //compiles
        call MyFunc3() //compiles
    endfunction
endscope

scope MySecondScope
    function TestCaller takes nothing returns nothing
        call MyFunc1() //Does not compile; MyFunc1 is private and can't
                       //be accessed from another function
                       //Unless MyFunc1 was declared as a private function in this scope aswell
        call MyFunc2() //Does not compile; you have to use the scope's preffix
                       //for it (cause it's public):
                       call MyScope_MyFunc2()

        call MyFunc3() //compiles; it's neither private nor public
    endfunction
endscope

//Same goes for private/public globals
 
Status
Not open for further replies.
Top