| 07-28-2008, 12:09 PM | #1 |
Hi guys, don't undertstand. Currently I have 2 problems with some code, and I don't understand why. Please can yo tell me why this loops won't work ? JASS:
set udg_User = GetTriggerUnit()
set x = bootomLeftX()
set y = bootomLeftY()
//call setCamera()
//here we create a line of icons
set positionX = x
set positionY = y
set rows = 0
loop
exitwhen(rows == 20)
set udg_Icons[rows] = CreateDestructable(blueBag(), positionX, positionY, 180, 0.3, 1)
call SetDestructableInvulnerable(udg_Icons[rows], true)
set positionX = positionX + 25
set rows = rows + 1
endloop
set positionX = x
set positionY = y + 25
set rows = 21
loop
exitwhen(rows == 40)
set udg_Icons[rows] = CreateDestructable(blueBag(), positionX, positionY, 180, 0.3, 1)
call SetDestructableInvulnerable(udg_Icons[rows], true)
set positionX = positionX + 25
set rows = rows + 1
endloop
set positionX = x
set positionY = y + 50
set rows = 41
loop
exitwhen(rows == 59)
set udg_Icons[rows] = CreateDestructable(blueBag(), positionX, positionY, 180, 0.3, 1)
call SetDestructableInvulnerable(udg_Icons[rows], true)
set positionX = positionX + 25
set rows = rows + 1
endloop
This whould Create 3 rows each one with 20 units. However, it creates row onw with 18, rwo two 19 and row three with 20 and I make no idea why ... Also, please note why do these loops don't work ? JASS:
set udg_User = GetTriggerUnit()
set x = bootomLeftX()
set y = bootomLeftY()
//call setCamera()
//here we create a line of icons
set positionX = x
set positionY = y
set rows = 0
set columns = 0
loop
exitwhen(rows == 3)
loop
exitwhen(columns == 20)
set udg_Icons[columns] = CreateDestructable(blueBag(), positionX, positionY, 180, 0.3, 1)
call SetDestructableInvulnerable(udg_Icons[columns], true)
set positionX = positionX + 25
set columns = columns + 1
endloop
set positionY = positionY + 25
set rows = rows + 1
endloop
This also SHOULD create 3 lines with 20 units each one, but it conly creates 1 line instead. Can some one help me please ? I will give +rep =S |
| 07-28-2008, 12:43 PM | #2 | ||
For the first one: Just try to follow the loop, your first loop is right: you start with row=0 and create units till row=20, so there are units created at 0,1,2,3,...,19 =>20 Units, in the next one you start with 21 and loop until it reaches 40 so: 21,22,...,39 =>19 units and the last one is: 41,42,...,58 =>18 units. So just adjust the set row= before the loop and the exitwhen in the last loop. So:
In the second one you just forget to set columns to 0 again. There is also a problem if you want to use udg_Icons later on.
|
| 07-28-2008, 03:45 PM | #3 | ||
Quote:
Strange is that if I let that loop alone it will work fine ... Ok I will test this code. Quote:
And yeah, I will need udg_Icons a lot, it will be one of the main, if not the most important thing to the interface ! besides I would like to get them referenced by followed numbers, so setting columns to zero is really something I don't want because it will over write the previous values =S Is there another solution for this code ??? I will test both codes, still thx for your help.I can only hope that at least 1 of them works fine =S |
| 07-28-2008, 05:05 PM | #4 | |||
Quote:
Quote:
|
| 07-29-2008, 02:05 PM | #5 |
Mmm, Your first option did well for me. I will use it due it's simplicity. Thx for your help and time. Keep doing a good job helping people. +rep -> you earned it well. |
