• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Does this work?

Status
Not open for further replies.
Level 12
Joined
Nov 3, 2013
Messages
989
Why doesn't this work?

I'm saving numbers from 0 and up to later let me use combinations of unit handles & ability raw codes as parent keys.

I don't have the data so I wanted it to be a bit dynamic to just let me fill in the raw codes later.

edit: removed useless stuff and updated with indents and removed empty comments.

JASS:
function Trig_buildSys_store_loops_Copy_2_Actions takes nothing returns nothing
    local integer i = 0
    local integer j
    local integer a = 0
    local integer h = 1
    local integer aId
    // unit handle id
    set udg_buildSys_init_unit[0] = gg_unit_o001_0001
    set udg_buildSys_init_unit[1] = gg_unit_o001_0002
    // ability raw codes
    set udg_buildSys_init_abilityId[0] = 'A000'
    set udg_buildSys_init_abilityId[1] = 'A001'
    set udg_buildSys_init_abilityId[2] = 'A002'
    // ----------------------------------
    loop
        exitwhen udg_buildSys_init_abilityId[a] == 0
        set a = a +1
    endloop
    call DisplayTextToForce( GetPlayersAll(), (I2S(a) ) )
    loop
        exitwhen h == 0
        set h = GetHandleId( udg_buildSys_init_unit[i] )
        call DisplayTextToForce( GetPlayersAll(), (I2S(h) ) )
        set j = 0
        set aId = 1
        loop
            exitwhen aId == 0
            set aId =  udg_buildSys_init_abilityId[i]
            call DisplayTextToForce( GetPlayersAll(), (I2S(aId) ) )
            call SaveInteger(udg_hash_buildSys, h, aId, i * a + j)
            set j = j +1
        endloop
        set i = i +1
    endloop
endfunction

//===========================================================================
function InitTrig_buildSys_store_loops_Copy_2 takes nothing returns nothing
    set gg_trg_buildSys_store_loops_Copy_2 = CreateTrigger(  )
    call TriggerAddAction( gg_trg_buildSys_store_loops_Copy_2, function Trig_buildSys_store_loops_Copy_2_Actions )
endfunction
 
Last edited:
Level 19
Joined
Aug 8, 2007
Messages
2,765
JASS:
    // ------------------------------------------------------------------
    loop
    exitwhen aId == 0
will crash.

you also have no event

also... comments are for commenting... indents are for seperating loops.
 
Level 12
Joined
Nov 3, 2013
Messages
989
you also have no event

also... comments are for commenting... indents are for seperating loops.

Event is in another trigger, and well the comments are remnants from the GUI custom script (The custom text colors are really annoying for me too look at so it's not until after posting inside
JASS:
 tags that I can actually see with the white background.

[quote="Arhowk, post: 2636078"][code=jass]
    loop
    exitwhen aId == 0
will crash.
[/QUOTE]
The exitwhen h == 0 might abort the execution of the thread since h has no initial value.

Well it's not crashing, Instead it's being completely ignored because no messages are being shown ingame. The problem persists after giving both variables initial values.

Also why did this part work when it's the same as the rest?
JASS:
loop
    exitwhen udg_buildSys_init_abilityId[a] == 0
    set a = a +1
    endloop
 
Level 12
Joined
Nov 3, 2013
Messages
989
Now the initial value of h and aId are 0. Then you have exitwhen h == 0 and exitwhen aId == 0. Maybe load another value to h and aId and only then use exitwhen.

You don't need aId != 0 and h != 0, exitwhen takes care of those.

And indent the code properly.

I've updated it and now the loop isn't exited until j is at 4542.

aId which should be the ability raw codes has 1093677104 as it's value in the last loop (there's too much so the log can't fit the previous loops)

And it's pretty weird since I've only got 2 unit handles and 3 ability raw codes put in atm...
 
Status
Not open for further replies.
Top