HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Troubleshooting needed--returning 18 codes instead of 12

08-20-2004, 11:42 PM#1
Taelrie
I was wondering if you guys could troubleshoot a code. This is part of the save code im making, but its supposed to return 12 letter (2 for each item) but for some reason it returns 18. Technically it shouldn't be jass, the only reason it is so I could move the +1 for the variable in the loop code into the then instead of at the end, and thus I am not that good at reading jass (only have done basic java and that isn't much of a base.) anybody see the problem?
Code:
(the first part is in the GUI but thats just so you can understand what it used in the JASS part.)

First trigger (again GUI, I know this works)
Set TempB=1
For Each (Integer B) from 1 to 6, do (Actions)
    Loop - Actions
        If (All conditions are True) then do (Then Actions) else do (Else Actions)
             If - Conditions
                 (Item carried by Blood Mage 0000 <gen> [I will change this with a unit variable, but since I made this on a different map it is rep. by Blood Mage] in slot (Integer B)) Equal to No Item
       Then - Actions
              Set PasswordParts (the string with code) = (PasswordParts + TempD[1])(Each array in TempD has a code, for example TempD[1] is AA, then tempD[2] is AB, and so on)
              Set Password_Loop = (Password_Loop + 1)
        Else - Actions
               Trigger - Run ItemLoop <gen> (checking conditions) (this is the jass code)



ItemLoop (trigger 2, in JASS)

function Trig_ItemLoop_Func001Func001C takes nothing returns boolean
    if ( not ( GetItemTypeId(UnitItemInSlotBJ(gg_unit_Hblm_0000, ( udg_password_loop - 6 ))) == udg_Item//This is the var. where I set the items used for this code\\[udg_TempB] ) ) then
        return false
    endif
    return true
endfunction

function Trig_ItemLoop_Actions takes nothing returns nothing
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 2
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        if ( Trig_ItemLoop_Func001Func001C() ) then
            set udg_PasswordParts = ( udg_PasswordParts + udg_TempD[udg_TempB] )
            set udg_password_loop = ( udg_password_loop + 1 )
            set udg_TempB = 1
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        else
            set udg_TempB = ( udg_TempB + 1 )
        endif
    endloop
endfunction

//===========================================================================
function InitTrig_ItemLoop takes nothing returns nothing
    set gg_trg_ItemLoop = CreateTrigger(  )
    call TriggerAddAction( gg_trg_ItemLoop, function Trig_ItemLoop_Actions )
endfunction

I imagine this is probably Grossly obvious but my mind works in strange ways, I can fix a code that is broken in every way in 2 minutes then spend 3 hours fixing something as simple as a difference of order because I just can't see it. Anyway help ^_^ .
08-21-2004, 12:18 AM#2
Daytranno
I am not a jass god by far, but,

exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd

So for the loop to exit, bj_forLoopAIndex needs to be greater than bj_forLoopAIndexEnd so if they are equal at 2, then the action repeats and leaves you with 3. Maybe you should exit when they are equal rather than when LoopAIndex is greater? LoopAIndex will have to equal 3 for the loop to exit because you put:

set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = 2

And that number being 3 may be what's screwing you up. I would give that a shot first. YMMV.

-- Daytranno
08-21-2004, 02:09 AM#3
Taelrie
*sigh* didn't work. I don't understand it, ive gone over everything and it should work. Everything else does, including the spell code, and I based the spell code off of the item code. not only that but it WAS working earlier, its really baffling. I know it has something to do with those two triggers since those are the only ones I use thats in relation to the items, so this is really pissing me off.
08-21-2004, 02:59 AM#4
Taelrie
wow the irony astounds even me. turns out it WAS a difference of order! o_O . not to mention it took me 5 hours to figure it out (2 of those hours was just staring at the screen and hitting the keyboard in annoyance tho). Anyway turns out that the loop code for the A variable setting was 0-25 instead of 1-26, its amazing how much agony the little things can do, anyway works fine now.