HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

A problem with a trigger containing lots of arrays.

07-22-2006, 07:24 AM#1
James1654
Trigger:
rocks
Collapse Events
Player - Player 1 (Red) types a chat message containing -rocks as An exact match
Conditions
Collapse Actions
Set int[5] = (int[5] + 1)
Set rockpoints[int[5]] = (Center of Region 002 <gen>)
Destructible - Create a Rock Chunks at rockpoints[int[5]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Set rocks[int[5]] = (Last created destructible)
Collapse For each (Integer A) from 1 to 50, do (Actions)
Collapse Loop - Actions
Set int[5] = (int[5] + 1)
Set rockpoints[int[5]] = (rockpoints[(int[5] - 1)] offset by (45.00, 0.00))
Destructible - Create a Rock Chunks at rockpoints[int[5]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Set rocksdown[6] = rockpoints[int[5]]
Custom script: call RemoveLocation( udg_rockpoints[udg_int[5] -1] )
Wait 0.01 seconds
Collapse For each (Integer B) from 1 to 50, do (Actions)
Collapse Loop - Actions
Set int[6] = (int[6] + 1)
Set rocksdown[6] = (rocksdown[(int[6] - 1)] offset by (0.00, -45.00))
Destructible - Create a Rock Chunks at rocksdown[int[6]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Custom script: call RemoveLocation( udg_rocksdown[udg_int[5] -1] )
Wait 0.01 seconds
Wait 0.01 seconds
Set int[6] = 0


Right, theoretically, this should create 2500 rocks in a split second. But instead, all that happens is 2 rocks spawn, sitting next to each other. What do I need to do to fix this problem?
07-22-2006, 10:23 AM#2
Fireeye
That because you used a wait command in a Loop, that won't work in GUI.
You have to write it in Jass.
BTW: It creates 2551 Rocks not 2500. (1+50+50²)
07-22-2006, 11:12 AM#3
The)TideHunter(
You can have waits in loops, but its asking for trouble.
07-22-2006, 11:22 AM#4
iNfraNe
The cause is probably another trigger changing integer A, since that variable is global and can be changed during triggersleeps.
07-22-2006, 12:03 PM#5
The)TideHunter(
Yea i probally is.
Use should use a local int and a custom loop, rather than Integer A.
07-22-2006, 12:05 PM#6
James1654
Thats ironic, I added the wait conditions to try and make it more stable O.o . I will convert it to jass, remove waits, and create an archive of the original trigger.

P.S: thanks for the help, fireeye, i will add rep for ya
07-22-2006, 01:00 PM#7
James1654
Guys, the trigger still aint working. It only creates the top row, and only 34 in that row, not the full 50. Can anyone please help? I will give rep.

Trigger:
rocks
Collapse Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Collapse Actions
Set int[6] = 0
Set int[5] = (int[5] + 1)
Set rockpoints[int[5]] = (Center of Region 002 <gen>)
Destructible - Create a Rock Chunks at rockpoints[int[5]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Set rocks[int[5]] = (Last created destructible)
Collapse For each (Integer A) from 1 to 50, do (Actions)
Collapse Loop - Actions
Set int[5] = (int[5] + 1)
Set rockpoints[int[5]] = (rockpoints[(int[5] - 1)] offset by (45.00, 0.00))
Destructible - Create a Rock Chunks at rockpoints[int[5]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Set rocksdown[6] = rockpoints[int[5]]
Custom script: call RemoveLocation( udg_rockpoints[udg_int[5] -1] )
Collapse For each (Integer B) from 1 to 50, do (Actions)
Collapse Loop - Actions
Set int[6] = (int[6] + 1)
Set rocksdown[6] = (rocksdown[(int[6] - 1)] offset by (0.00, -45.00))
Destructible - Create a Rock Chunks at rocksdown[int[6]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Custom script: call RemoveLocation( udg_rocksdown[udg_int[5] -1] )
Set int[6] = 0

EDIT:

Jass version:

Collapse JASS:
rocks
    Events
        Player - Player 1 (Red) skips a cinematic sequence
    Conditions
    Actions
        Set int[6] = 0
        Set int[5] = (int[5] + 1)
        Set rockpoints[int[5]] = (Center of Region 002 <gen>)
        Destructible - Create a Rock Chunks at rockpoints[int[5]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
        Set rocks[int[5]] = (Last created destructible)
        For each (Integer A) from 1 to 50, do (Actions)
            Loop - Actions
                Set int[5] = (int[5] + 1)
                Set rockpoints[int[5]] = (rockpoints[(int[5] - 1)] offset by (45.00, 0.00))
                Destructible - Create a Rock Chunks at rockpoints[int[5]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
                Set rocksdown[6] = rockpoints[int[5]]
                Custom script:   call RemoveLocation( udg_rockpoints[udg_int[5] -1] )
                For each (Integer B) from 1 to 50, do (Actions)
                    Loop - Actions
                        Set int[6] = (int[6] + 1)
                        Set rocksdown[6] = (rocksdown[(int[6] - 1)] offset by (0.00, -45.00))
                        Destructible - Create a Rock Chunks at rocksdown[int[6]] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
                        Custom script:   call RemoveLocation( udg_rocksdown[udg_int[5] -1] )
                Set int[6] = 0
07-22-2006, 01:14 PM#8
Vexorian
why is your JASS version in GUI?
07-22-2006, 01:24 PM#9
Fireeye
You want to create a field of stones in cube form, right?
If yes, why do you use such a complex trigger, i've created a trigger (the map is attached) which creates 2500 Stones in a cube form, it's really simple.
Uhm, but i forgot to destroy the points, but the leak is minimal, because i don't use any array.
Attached Files
File type: w3xCreateStones.w3x (12.3 KB)
07-22-2006, 01:45 PM#10
James1654
Quote:
Originally Posted by Vexorian
why is your JASS version in GUI?

hehe, woops, that looks kinda weird, lol. I guess I acidently did copy as text instead of convert to jass :P

ah, kk, thx fireeye, i guess i did too complicated actions on my trigger. Rep given.


EDIT: Is there some sort of maximum on how high the integers can go? It aint adding any more then about 25 colums, and i set integer a as 1-300 .

Trigger:
rock
Collapse Events
Map initialization
Conditions
Collapse Actions
Set rockpoints[1] = (Center of Region 002 <gen>)
Collapse For each (Integer A) from 1 to 300, do (Actions)
Collapse Loop - Actions
Set rockpoints[1] = (rockpoints[1] offset by (45.00, 0.00))
Destructible - Create a Rock Chunks at rockpoints[1] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Set rockpoints[2] = (rockpoints[1] offset by (0.00, -45.00))
Custom script: call RemoveLocation(udg_locations[1])
Collapse For each (Integer B) from 1 to 195, do (Actions)
Collapse Loop - Actions
Destructible - Create a Rock Chunks at rockpoints[2] facing (Random angle) with scale 0.40 and variation (Random integer number between 0 and 5)
Set rockpoints[2] = (rockpoints[2] offset by (0.00, -45.00))
Custom script: call RemoveLocation (udg_locations[2])

EDIT:

Jass version:

Collapse JASS:
function Trig_rock_Actions takes nothing returns nothing
    set udg_rockpoints[1] = GetRectCenter(gg_rct_Region_002)
    set bj_forLoopAIndex = 1
    set bj_forLoopAIndexEnd = 300
    loop
        exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
        set udg_rockpoints[1] = OffsetLocation(udg_rockpoints[1], 45.00, 0)
        call CreateDestructableLoc( 'LTrc', udg_rockpoints[1], GetRandomDirectionDeg(), 0.40, GetRandomInt(0, 5) )
        set udg_rockpoints[2] = OffsetLocation(udg_rockpoints[1], 0.00, -45.00)
        call RemoveLocation(udg_locations[1])
        set bj_forLoopBIndex = 1
        set bj_forLoopBIndexEnd = 193
        loop
            exitwhen bj_forLoopBIndex > bj_forLoopBIndexEnd
            call CreateDestructableLoc( 'LTrc', udg_rockpoints[2], GetRandomDirectionDeg(), 0.40, GetRandomInt(0, 5) )
            set udg_rockpoints[2] = OffsetLocation(udg_rockpoints[2], 0.00, -45.00)
            set bj_forLoopBIndex = bj_forLoopBIndex + 1
        endloop
        call RemoveLocation (udg_locations[2])
        set bj_forLoopAIndex = bj_forLoopAIndex + 1
    endloop
endfunction

//===========================================================================
function InitTrig_rock takes nothing returns nothing
    set gg_trg_rock = CreateTrigger(  )
    call TriggerAddAction( gg_trg_rock, function Trig_rock_Actions )
endfunction
07-22-2006, 02:36 PM#11
iNfraNe
There's is a thing called the thread limit. The function will stop after a certain amount of data is handled.

You can fix this by letting the destructable creation be done in another trigger and running that trigger 2500 times. (or by using ExecuteFunc)
07-22-2006, 04:21 PM#12
James1654
String limit . . . yes, i thought it might be that, becauswe when i was looking at a maze generator, he had the problem. I dont think WEU fixes it either. Ok, I will try the running the action another few times, but can you also tell me more about this "execute function" thing?]

edit: rep given
07-22-2006, 05:13 PM#13
The)TideHunter(
String limit and thread limit are very different, a thread is something like a trigger, but the thing that runs the trigger.
Its very complicated, its to do with programming, while strings are characters.