• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

vJASS - Initialisers

Status
Not open for further replies.
Level 17
Joined
Feb 11, 2011
Messages
1,860
Hello guys,

I've been conducting experiments in order to find out the order that initialisers are placed in the map script. I suppose everyone else already knows this, but I didn't :wink: (it's been causing some issues for me so I wanted to check)

While checking, I discovered something interesting. First, the code:

JASS:
library LibraryTest initializer OnInit_Lib

    private struct Funny
    
        private static method onInit takes nothing returns nothing
            call BJDebugMsg("Library - struct onInit")
        endmethod
    
    endstruct

    private module InitLibModule
    
        private static method onInit takes nothing returns nothing
            call BJDebugMsg("Library - struct module onInit")
        endmethod
    
    endmodule
    
    private struct InitLibStruct
    
        implement InitLibModule
    
    endstruct

    private function OnInit_Lib takes nothing returns nothing
        call BJDebugMsg("Library - initialiser function")
    endfunction

endlibrary
JASS:
scope ScopeTest initializer OnInit

    private struct Foo
    
        private static method onInit takes nothing returns nothing
            call BJDebugMsg("Scope - struct onInit")
        endmethod
    
    endstruct

    private module InitModule
    
        private static method onInit takes nothing returns nothing
            call BJDebugMsg("Scope - struct module onInit")
        endmethod
    
    endmodule
    
    private struct InitStruct
    
        implement InitModule
    
    endstruct
    
    private function OnInit takes nothing returns nothing
        call BJDebugMsg("Scope - initialiser function")
    endfunction

endscope
When I run the map, this is the result (which I kind of expected):

68284966.jpg


I noticed that something weird happens with these lines:
call BJDebugMsg("Library - struct module onInit")
call BJDebugMsg("Scope - struct module onInit")

I was just wondering why this happens. Could someone enlighten me?

Also, are there any other initialisers I am missing out?

Thanks,

Mr_Bean
 
It just means that JassHelper isn't properly searching when its compiling the map. Pretty much all the functions in structs/methods/modules end up renamed. Since you declare onInit, it looks for "onInit" and appends the appropriate prefix. It apparently doesn't ignore strings.

This is an interesting find, but shouldn't matter since you won't normally print out "onInit" unless it is a sandbox map or if you are printing errors.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
It just means that JassHelper isn't properly searching when its compiling the map. Pretty much all the functions in structs/methods/modules end up renamed. Since you declare onInit, it looks for "onInit" and appends the appropriate prefix. It apparently doesn't ignore strings.

Hmmm, I thought this may be the case :wink:

This is an interesting find, but shouldn't matter since you won't normally print out "onInit" unless it is a sandbox map or if you are printing errors.

Yup, I'm not worried about it, just thought that it shouldn't happen.
 
Status
Not open for further replies.
Top