Why wont this run on init?

AdamGriffith

You can change this now in User CP.
Reaction score
69
JASS:
scope Trees initializer Init

globals
    private real X
endglobals

public function Loop takes nothing returns nothing
    local destructable d
    local real MaxY = GetRectMaxY(bj_mapInitialPlayableArea)
    local real y = GetRectMinY(bj_mapInitialPlayableArea)
    loop
        exitwhen y > MaxY
        set d = CreateDestructable('LTlt', X, y, GetRandomReal(0.0, 360.0), 1.0, -1)
        set d = null
        set y = y + 128.0
    endloop
endfunction

private function Actions takes nothing returns nothing
    local real MaxX = GetRectMaxX(bj_mapInitialPlayableArea)
    set X = GetRectMinX(bj_mapInitialPlayableArea)
    loop
        exitwhen X > MaxX
        call ExecuteFunc("Trees_Loop")
        set X = X + 128.0
    endloop            
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t, 0.0, false)
    call TriggerAddAction(t, function Actions)
endfunction

endscope


Thanks,
Adam

+rep to helpers
 

AdamGriffith

You can change this now in User CP.
Reaction score
69
I added in that event because it wouldnt work at Init.
When you tested did it have the event in it?

I was wondering if it was possible to have all the trees there as soon as the map loads.
So the minimap displays them.
 
Reaction score
333
I basically just copy pasted your code into a test map. Maybe the initialization thread is crashing?
 

Romek

Super Moderator
Reaction score
964
You're probably hitting the OP limit with loops like that.
Split the loops into even smaller functions, and use funcname.execute(arg1, arg2) to call them where necessary.
 

Sooda

Diversity enchants
Reaction score
318
I guess you have to make sure in Trigger Editor boxes 'Run At Map Initialization' and 'Enable This Trigger' are checked. Then you even don't need Action function nor local trigger created and can do all actions in Init function.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top