| 07-19-2009, 09:10 PM | #1 |
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: JASS:scope SpellTreeSystem initializer Init globals private real X private real Y private constant real UPG_RAD = 64 private constant integer UPG_COUNT = 4 private constant string UPG_SFX = "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" private Table TT endglobals private function HighlightEffect takes Trackable T returns nothing call DestroyEffect(AddSpecialEffect(UPG_SFX, T.x, T.y)) endfunction private function TrackableHit takes Trackable T returns nothing local Trackable array Tar local real a local real x local real y local integer i = 1 loop exitwhen i > UPG_COUNT set a = GetSplitAngle(bj_PI/2, bj_PI/6, UPG_COUNT, i) set x = T.x + UPG_RAD * Cos(a) set y = T.y + UPG_RAD * Sin(a) call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\SpiritOfVengeanceMissile\\SpiritOfVengeanceMissile.mdl", x, y)) set Tar[i] = Trackable.create(Player(0), x, y, 0) call Tar[i].onHit(HighlightEffect) set TT[i] = Tar[i] set i = i + 1 endloop endfunction 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 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: JASS:scope Test initializer Init private function Init takes nothing returns nothing call BJDebugMsg("init") endfunction endscope Doesn't work. I tried this: 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 |
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 |
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: 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: 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: 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 |
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? 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 | |
Quote:
you might have to use private keyword int before you declare the struct, to make it work.` |
| 07-20-2009, 12:23 PM | #6 | |
Quote:
|
| 07-20-2009, 04:17 PM | #7 | |
Quote:
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 |
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 | |
Quote:
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 |
I tried using having: 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 |
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 |
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..) |
