• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece!🔗 Click here to enter!

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