Sorry to have to ask another probably stupid question but how can I get something to repeat a number of times?
UPDATE: I worked it out. Ignore me.
For those who would ask because they are equally stupid as I, I used the Do and Loop command.
UPDATE: Turns out I haven't worked it out. My brain is currently dying.
$payload:10
$sporeHealth:10
if (<-fire)
@GetUnitTypeCount("REACTOR") ->reactorCount
do(reactorCount 0)
# add code to select target coordinates
CreateSpore(CurrentCoords <-targetX <-targetY <-sporeHealth <-payload)
loop
endif
:GetUnitTypeCount
->unitType
0 ->count
do (GetUnitCountInRange(0 0 9999) 0)
->unitUID
if (GetUnitType(<-unitUID) eq(<-unitType))
<-count add(1) ->count
endif
loop
<-count
This should do the trick.
Quote from: eduran on October 30, 2013, 07:41:18 PM
bunch of code
This should do the trick.
What you've done looks good but still doesn't work. I think my issues are in the "if (<-fire)" line. fire is probably the criteria for launching spores that I haven't set yet. I'll sort that out now. Thanks for lending a hand.
UPDATE: I now have this.
$payload:10
$sporeHealth:10
if ((<-fire) eq(1))
@GetUnitTypeCount("REACTOR") ->reactorCount
do(<-reactorCount 0)
CreateSpore(CurrentCoords RandUnitCoords <-sporeHealth <-payload)
loop
0 ->fire
endif
90 delay
1 ->fire
:GetUnitTypeCount
->unitType
0 ->count
do (GetUnitCountInRange(0 0 9999) 0)
->unitUID
if (GetUnitType(<-unitUID) eq(<-unitType))
<-count add(1) ->count
endif
loop
<-count
Doesn't work. I have no idea what's going on anymore.
Quote from: Clean0nion on October 30, 2013, 07:55:32 PM
Quote from: eduran on October 30, 2013, 07:41:18 PM
bunch of code
This should do the trick.
What you've done looks good but still doesn't work. I think my issues are in the "if (<-fire)" line. fire is probably the criteria for launching spores that I haven't set yet. I'll sort that out now. Thanks for lending a hand.
UPDATE: I now have this.
-snip-
Doesn't work. I have no idea what's going on anymore.
Try this:
$payload:10
$sporeHealth:10
@GetUnitTypeCount("REACTOR") ->reactorCount
do(<-reactorCount dup mul 0)
CreateSpore(CurrentCoords RandUnitCoords <-sporeHealth <-payload)
loop
90 delay
:GetUnitTypeCount
->unitType
0 ->count
do (GetUnitCountInRange(0 0 9999) 0)
->unitUID
if (GetUnitType(<-unitUID) eq(<-unitType))
<-count add(1) ->count
endif
loop
<-count
It also uses the square of the number of reactors. You probably will want to increase the 90-frame delay (3 seconds), though.
Delay makes your entire CRPL Core pause at that spot until the delay time is up. If it's doing other things besides just firing those spores, you may want to use a timer instead of a delay.
$InitialDelay:3600
$WaveInterval:900
once
SetTimer0 (<-InitialDelay) # Sets up the initial delay
endonce
if (eq0(GetTimer0)) # do this only when the timer hits zero
# Fire your spores here
SetTimer0 (<-WaveInterval) # reset the timer for the next interval
endif
# Do other stuff
Quote from: Grayzzur on October 30, 2013, 10:19:37 PM
Delay makes your entire CRPL Core pause at that spot until the delay time is up. If it's doing other things besides just firing those spores, you may want to use a timer instead of a delay.
$InitialDelay:3600
$WaveInterval:900
once
SetTimer0 (<-InitialDelay) # Sets up the initial delay
endonce
if (eq0(GetTimer0)) # do this only when the timer hits zero
# Fire your spores here
SetTimer0 (<-WaveInterval) # reset the timer for the next interval
endif
# Do other stuff
Thanks. I'll test this out later.