Need some help with first CRPL Unit

Started by SUPER GOD, May 12, 2015, 11:17:24 AM

Previous topic - Next topic

SUPER GOD

Hi, was wondering what's wrong with my code. I'm new to CRPL and RPL in general and worse, I'm used to other forms of programming, so stack language is kinda confusing, at least for now. ::) This is my code. I also use functions a lot, just to structure it for me.
# CRPL 001.crpl
# Created on: 5/12/2015 3:55:13 PM
# ------------------------------------------
#A Nexus type unit that Moves Randomly, Leaves Inactive Digitalis and creeper
#On direction change, leaves Emitter/Tower/Nest and creeper burst
#When destroyed, spawns 5 spores and more creeper

once
RandCoords 3 QueueMove
endonce

@Creeper
@CreateDigitalis
GetQueuedMoveCount eq0 if
@Move
@CreeperBurst
@CreateStructure
endif
30 Delay

:Move
RandCoords 3 QueueMove

:Creeper
CurrentCoords 5 AddCreeper

:CreateDigitalis
CurrentCoords true SetDigitalisGrowth

:CreateStructure
RandInt 3 mod ->iUnitType
<-iUnitType 0 eq if
"EMITTER" ->sUnitType
endif
<-iUnitType 1 eq if
"SPORETOWER" ->sUnitType
endif
<-iUnitType 2 eq if
"RUNNERNEST" ->sUnitType
endif
<-sUnitType CurrentCoords CreateUnit

:CreeperBurst
CurrentCoords 25 AddCreeper

:destroyed
CurrentCoords 100 AddCreeper
5 0 do
CurrentCoords RandUnitCoords 1 20 CreateSpore
loop

J

Instead of 'randInt 3 mod' you should use '0 3 RandInt'. RandInt takes two arguments to define the min and max of what it returns.
If it does anything at all (I can't find any other errors (yet)), it will help a lot to tell us what it does exactly and what should be fixed. For the digitalis to be notable the delay should be decreased and ideally the adjacent cells should also be covered in digitalis. Which should then be:
0 3 do
0 3 do
CurrentX I add CurrentY J add true SetDigitalisGrowth
loop
loop

SUPER GOD

#2
Ahh, thank you very much. If I did 0 2 RandInt it'll produce either a 0, 1 or 2 correct?

Edit: Nvrm, I found out that 0 3 RandInt picks from 0-2 and 0 2 Randint pick from 0-1; One under maximum.