HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

initializer problem

07-19-2009, 09:10 PM#1
Silvenon
Well, for some reason my initializer isn't getting called, but it was getting called before....anyways, it's really weird. Here's the code if it's of any help:

Expand JASS:

I think it was a stupid idea to post this here, because obviously nobody will know the solution. It may be an issue with the JNGP 5d...

EDIT: My library initializers are working, but the scope initializers aren't. Arghrgfetwhagsgsh.

EDIT2: Same problem with 5b. This sucks so hard.

I tried this:

Collapse JASS:
scope Test initializer Init
    private function Init takes nothing returns nothing
        call BJDebugMsg("init")
    endfunction
endscope

Doesn't work. I tried this:

Collapse JASS:
library Test initializer Init
    private function Init takes nothing returns nothing
        call BJDebugMsg("init")
    endfunction
endlibrary

Does work.
07-19-2009, 10:41 PM#2
Anitarf
Maybe your scope initialization is hitting the op limit or doing something else that crashes the thread; try disabling other scopes to confirm whether this is the issue.
07-20-2009, 09:07 AM#3
Silvenon
All the other scopes are already disabled. I only have tons of system libraries.

I just remembered what I did that disabled the scope initializers to fire. I wanted to pan the camera to a certain point, but I didn't want game camera, so I created a camerasetup that views the terrain from above, not from an angle. Then I created a Cam (camerasetup) global and I've assigned it the gg_cam variable. After that I did the modifications here.....all in all, this is how it was before it stopped working:

Collapse JASS:
scope SpellTreeSystem initializer Init

    globals
        private constant real X = -60
        private constant real Y = -60
        
        // ...
    endglobals
    
    // ...
    // ...
    
    private function LockCamera takes nothing returns nothing
        call PanCameraTo(X, Y)
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local image i = CreateImageEx(ICON_TEST_PATH, ICON_TEST_X, ICON_TEST_Y, X, Y)
        local Trackable T
        
        call BJDebugMsg("init")
        
        call TriggerRegisterTimerEvent(t, 0.035, true)
        call TriggerAddAction(t, function LockCamera)
        
        set T = Trackable.create(Player(0), X, Y, 0)
        
        call T.onHit(TrackableHit)
        
        set TT = Table.create()
        set TT[0] = T
        
        set t = null
    endfunction

endscope

And this is now. Here's the separate init library:

Collapse JASS:
library MapInit initializer Init
    
    globals
        // ...
        camerasetup Cam = null
        // ...
    endglobals
    
    function Init takes nothing returns nothing
        // ...
        set Cam = gg_cam_Camera_001
        // ...
    endfunction
    
endlibrary

I don't have a clue why I made it a library and not a scope. Anyways, here's the non-working version:

Collapse JASS:
scope SpellTreeSystem initializer Init
    
    globals
        private real X
        private real Y
        
        // ...
    endglobals
    
    // ...
    // ...
    
    private function LockCamera takes nothing returns nothing
        call CameraSetupApply(Cam, true, false)
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local image i = CreateImageEx(ICON_TEST_PATH, ICON_TEST_X, ICON_TEST_Y, X, Y)
        local Trackable T
        
        call BJDebugMsg("init")
        
        call TriggerRegisterTimerEvent(t, 0.035, true)
        call TriggerAddAction(t, function LockCamera)
        
        //set X = CameraSetupGetDestPositionX(Cam)
        //set Y = CameraSetupGetDestPositionY(Cam)
        
        set T = Trackable.create(Player(0), X, Y, 0)
        
        call T.onHit(TrackableHit)
        
        set TT = Table.create()
        set TT[0] = T
        
        set t = null
    endfunction
    
endscope

And that's about it. That gotta be the most unsexy bug ever.
07-20-2009, 09:19 AM#4
Silvenon
Nvm, don't bother over it, I made a workaround.

One side question, I don't want to open a new thread. Will this work?

Collapse JASS:
function interface int takes Data returns nothing

struct Data
    // some methods here take int as an argument
endstruct

If not, is there another way to make that possible?
07-20-2009, 12:08 PM#5
Blubb-Tec
Quote:
Originally Posted by Silvenon
Nvm, don't bother over it, I made a workaround.

One side question, I don't want to open a new thread. Will this work?

Collapse JASS:
function interface int takes Data returns nothing

struct Data
    // some methods here take int as an argument
endstruct

If not, is there another way to make that possible?

you might have to use private keyword int before you declare the struct, to make it work.`
07-20-2009, 12:23 PM#6
Anitarf
Quote:
Originally Posted by Blubb-Tec
you might have to use private keyword int before you declare the struct, to make it work.`
No, in fact, chances are that doing that would make it stop working. Don't suggest things if you don't understand how or why they are used.
07-20-2009, 04:17 PM#7
Blubb-Tec
Quote:
Originally Posted by Anitarf
No, in fact, chances are that doing that would make it stop working. Don't suggest things if you don't understand how or why they are used.

ok, if that's the case, then i guess i totally misunderstood things there.
from what i understood, keyword works like a forward declaration, but i've only seen it being used in certain cases, and i thought this was one of them.

well, it would be nice if you could clear me up about how/why keyword is used.
07-20-2009, 07:13 PM#8
Anitarf
You're right, "forward declaration" is a good description, I guess, it allows code that comes before an identifier is declared to know whether that identifier is private or public. If you know that, then why would you suggest it here when the function interface is obviously declared before the struct, so if it were private (which it isn't) the struct would already know that. I suppose what you meant to say is "private keyword Data before you declare the function interface" instead of "private keyword int before you declare the struct", but again, the struct isn't private to begin with.
07-20-2009, 07:45 PM#9
Blubb-Tec
Quote:
Originally Posted by Anitarf
You're right, "forward declaration" is a good description, I guess, it allows code that comes before an identifier is declared to know whether that identifier is private or public. If you know that, then why would you suggest it here when the function interface is obviously declared before the struct, so if it were private (which it isn't) the struct would already know that. I suppose what you meant to say is "private keyword Data before you declare the function interface" instead of "private keyword int before you declare the struct", but again, the struct isn't private to begin with.

aye, you're totally right, and the case you mentioned there was actually the case i was having in mind, and i just confused the two cases. Thanks for the informative reply :)
but are you sure keyword has only to be used when the identifier is either private or public, and that keyword is not necessary in cases where something is neither private nor public(keyword doesn't work without being declared either, anyway)?
07-20-2009, 09:53 PM#10
Silvenon
I tried using having:

Collapse JASS:
library Lib

    private keyword Data

    function interface Int takes Data dat returns nothing

    struct Data
        // some methods here...
    endstruct

endlibrary

// ...somewhere else...

scope Blah

    private function Blah takes Data dat returns nothing
        // using "." sintax...
    endfunction

endscope

And I get errors in the Blah function that Data is not the type that allows "." sintax. But I don't think that's the real problem, because vJass can be so complicated that the compiler is pretty much helpless.
07-20-2009, 10:19 PM#11
Anitarf
As noted, the private keyword statement marks the "Data" identifier as being private, thus it's as if it didn't exist outside of Lib, so it also doesn't show up on the compiler's list of things that support . syntax.
07-21-2009, 12:08 AM#12
Blubb-Tec
try public keyword Data (you might have to scope-prefix it in that case, e.g. MyScope_Data and so on, outside its original scope..)