'Nothing' Function

_whelp

New Member
Reaction score
54
When I test this function it does nothing.
How do I fix it?
JASS:

function init_CreateUnitsForPlayers takes nothing returns nothing
    local rect array spawn
    local destructable array cage 
    local integer a = 0
    local integer b = 0
    local integer c = 0
    local real array angle
    local real array cagex
    local real array cagey
    local real x
    local real y
    
    loop
        exitwhen a == bj_MAX_PLAYER_SLOTS
        if(a == 0) then
            set spawn[a] = gg_rct_PlayerSpawnRegion1
        elseif(a == 1) then
            set spawn[a] = gg_rct_PlayerSpawnRegion2
        endif
        if(a == 2) then
            set spawn[a] = gg_rct_PlayerSpawnRegion3
        elseif(a == 3) then 
            set spawn[a] = gg_rct_PlayerSpawnRegion4
        endif
        if(a == 4) then 
            set spawn[a] = gg_rct_PlayerSpawnRegion5
        elseif(a == 1) then
            set spawn[a] = gg_rct_PlayerSpawnRegion6
        endif
        set a = a + 1
    endloop
    
    loop
        exitwhen b == bj_MAX_PLAYER_SLOTS
        set x = GetRectCenterX(spawn<b>)
        set y = GetRectCenterY(spawn<b>)
        loop
            exitwhen c == bj_MAX_PLAYER_SLOTS
            if(c == 0) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            elseif(c == 1) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            endif
            if(c == 2) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            elseif(c == 3) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            endif
            if(c == 4) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            elseif(c == 5) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            endif
        endloop
        set angle<b> = bj_RADTODEG * Atan2(cagey<b> - y, cagex<b> - x)      
        call CreateUnit(Player(b), &#039;h000&#039;, x, y, angle<b>)
        set b = b + 1
    endloop
    loop
        exitwhen a == 0
        if(a != bj_MAX_PLAYER_SLOTS) then
            set b = 0
            set c = 0
            set cage[a] = null
            set angle[a] = 0
            set cagex[a] = 0
            set cagey[a] = 0
            set x = 0
            set y = 0
            set spawn[a] = null
        endif
        set a = a - 1
    endloop
endfunction
</b></b></b></b></b></b>
 

Vestras

Retired
Reaction score
249
Is that the whole trigger? Maybe try naming the function InitTrig_blahblah where blahblah is your trigger name.
 

_whelp

New Member
Reaction score
54
here you go...
Trigger:
  • Init
    • Events
      • Time - Elapsed game time is 0.20 seconds
    • Conditions
    • Actions
      • Custom script: call init_CreateUnitsForPlayers()
 

Azlier

Old World Ghost
Reaction score
461
JASS:
loop
            exitwhen c == bj_MAX_PLAYER_SLOTS
            if(c == 0) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            elseif(c == 1) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            endif
            if(c == 2) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            elseif(c == 3) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            endif
            if(c == 4) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            elseif(c == 5) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            endif
            //And you are increasing c by one... where?
        endloop
 

chobibo

Level 1 Crypt Lord
Reaction score
48
JASS:
loop
            exitwhen c == bj_MAX_PLAYER_SLOTS
            if(c == 0) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            elseif(c == 1) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            endif
            if(c == 2) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            elseif(c == 3) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            endif
            if(c == 4) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            elseif(c == 5) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            endif
            //And you are increasing c by one... where?
            set c=c+1
        endloop
 

_whelp

New Member
Reaction score
54
JASS:
loop
            exitwhen c == bj_MAX_PLAYER_SLOTS
            if(c == 0) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            elseif(c == 1) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
            endif
            if(c == 2) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            elseif(c == 3) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
            endif
            if(c == 4) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            elseif(c == 5) then
                set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
                set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
            endif
            //And you are increasing c by one... where?
            set c=c+1
        endloop

thats what i did and it still had no effect

And if I syntax check it in JassNewgen or whatever, it says gg_dest_LOcg_0010 and the others aren't variables or something...
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Your methods are.... interesting. Try going through and optimizing your code a little bit.

Just a quick look:

JASS:
    loop
        exitwhen a == bj_MAX_PLAYER_SLOTS
        if(a == 0) then
            set spawn[a] = gg_rct_PlayerSpawnRegion1
        elseif(a == 1) then
            set spawn[a] = gg_rct_PlayerSpawnRegion2
        endif
        if(a == 2) then
            set spawn[a] = gg_rct_PlayerSpawnRegion3
        elseif(a == 3) then 
            set spawn[a] = gg_rct_PlayerSpawnRegion4
        endif
        if(a == 4) then 
            set spawn[a] = gg_rct_PlayerSpawnRegion5
        elseif(a == 1) then // Shouldn&#039;t this be 5?
            set spawn[a] = gg_rct_PlayerSpawnRegion6
        endif
        set a = a + 1
    endloop


Can be made simpler by doing this:

JASS:
set spawn[0] = gg_rct_PlayerSpawnRegion1
set spawn[1] = gg_rct_PlayerSpawnRegion2
set spawn[2] = gg_rct_PlayerSpawnRegion3
set spawn[3] = gg_rct_PlayerSpawnRegion4
set spawn[4] = gg_rct_PlayerSpawnRegion5
set spawn[1] = gg_rct_PlayerSpawnRegion6


What you put just makes it harder to read, slower, and confusing.
 

_whelp

New Member
Reaction score
54
Okay, but when I test the map, WE gives me the 'Expected a name' error for these lines.
JASS:

set cagex[1] = GetDestructableX(gg_dest_LOcg_0008)
set cagey[2] = GetDestructableY(gg_dest_LOcg_0008)
set cagex[3] = GetDestructableX(gg_dest_LOcg_0009)
set cagey[4] = GetDestructableY(gg_dest_LOcg_0009)            
set cagex[5] = GetDestructableX(gg_dest_LOcg_0010)
set cagey[6] = GetDestructableY(gg_dest_LOcg_0010)


(I changed some of the code... in this part...)
JASS:

loop
    exitwhen c == bj_MAX_PLAYER_SLOTS
    if(c == 0) then
        set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
        set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
    elseif(c == 1) then
        set cagex[c] = GetDestructableX(gg_dest_LOcg_0008)
        set cagey[c] = GetDestructableY(gg_dest_LOcg_0008)
    endif
    if(c == 2) then
        set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
        set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
    elseif(c == 3) then
        set cagex[c] = GetDestructableX(gg_dest_LOcg_0009)
        set cagey[c] = GetDestructableY(gg_dest_LOcg_0009)
    endif
    if(c == 4) then
        set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
        set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
    elseif(c == 5) then
        set cagex[c] = GetDestructableX(gg_dest_LOcg_0010)
        set cagey[c] = GetDestructableY(gg_dest_LOcg_0010)
    endif
    set c = c + 1
endloop
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Try this. You need jass newgen...

JASS:
scope CreateUnitsForPlayers initializer init

private function Act takes nothing returns nothing
    local rect array spawn
    local destructable array cage 
    local integer a = 0
    local integer b = 0
    local integer c = 0
    local real array angle
    local real array cagex
    local real array cagey
    local real x
    local real y
    
    set spawn[0] = gg_rct_PlayerSpawnRegion1
    set spawn[1] = gg_rct_PlayerSpawnRegion2
    set spawn[2] = gg_rct_PlayerSpawnRegion3
    set spawn[3] = gg_rct_PlayerSpawnRegion4
    set spawn[4] = gg_rct_PlayerSpawnRegion5
    set spawn[5] = gg_rct_PlayerSpawnRegion6

    set cagex[0] = GetDestructableX(gg_dest_LOcg_0008)
    set cagey[0] = GetDestructableY(gg_dest_LOcg_0008)
    set cagex[1] = GetDestructableX(gg_dest_LOcg_0008)
    set cagey[1] = GetDestructableY(gg_dest_LOcg_0008)
    set cagex[2] = GetDestructableX(gg_dest_LOcg_0009)
    set cagey[2] = GetDestructableY(gg_dest_LOcg_0009)
    set cagex[3] = GetDestructableX(gg_dest_LOcg_0009)
    set cagey[3] = GetDestructableY(gg_dest_LOcg_0009)
    set cagex[4] = GetDestructableX(gg_dest_LOcg_0010)
    set cagey[4] = GetDestructableY(gg_dest_LOcg_0010)
    set cagex[5] = GetDestructableX(gg_dest_LOcg_0010)
    set cagey[5] = GetDestructableY(gg_dest_LOcg_0010)
    
    call BJDebugMsg(&quot;Spawn loop reached&quot;)
    loop
        set x = GetRectCenterX(spawn<b>)
        set y = GetRectCenterY(spawn<b>)
        set angle<b> = bj_RADTODEG * Atan2(cagey<b> - y, cagex<b> - x)      
        call CreateUnit(Player(b), &#039;h000&#039;, x, y, angle<b>)
        call BJDebugMsg(&quot;Unit spawned&quot;)
        exitwhen b &gt;= bj_MAX_PLAYER_SLOTS
        set b = b + 1
    endloop
    
    loop
        exitwhen a == 0
        if(a != bj_MAX_PLAYER_SLOTS) then
            set b = 0
            set c = 0
            set cage[a] = null
            set angle[a] = 0
            set cagex[a] = 0
            set cagey[a] = 0
            set x = 0
            set y = 0
            set spawn[a] = null
        endif
        set a = a - 1
    endloop
endfunction

private function init takes nothing returns nothing
local trigger t = CreateTrigger()
    call TriggerRegisterTimerEvent(t,0.20,false)
    call TriggerAddAction(t,function Act)
set t = null
endfunction
endscope</b></b></b></b></b></b>
 

_whelp

New Member
Reaction score
54
Damn it... everything I tried doesn't seem to work. :( WE keeps giving me crappy and annoying errors. Errr......
 

Ryuu

I am back with Chocolate (:
Reaction score
64
You might consider rewriting the code.
It's a little messy and .. (to me, at least) unreadable.
 
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