Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: cpaca on January 03, 2016, 06:24:54 PM

Title: CRPL making CRPL making CRPL error
Post by: cpaca on January 03, 2016, 06:24:54 PM
I don't know what's wrong. Here's the code: (Green text means it works, red means it does not)

This is called CreatorNest2
$Delay:30

CreateUnit("CRPLCORE" CurrentX CurrentY) ->PlaceHolder
AddScriptToUnit(<-PlaceHolder "CreatorNest1.crpl")
<-Delay Delay
if (GetQueuedMoveCount 0 eq)
QueueMove(RandCoords 1)
endif


This is called CreatorNest1
CreateUnit("CRPLCORE" CurrentX CurrentY) ->Unit
AddScriptToUnit(<-Unit "Flying.crpl")
<-SpawnAmount 1 subtract ->SpawnAmount
if(<-SpawnAmount 0 lt)
destroy(self 2)
endif
30 Delay

Can't figure out what is wrong with it. It will not spawn the "Flying" Unit.
Here's the code for the Flying unit (Haven't tested it, occupied with CreatorNest1)
#variables are $<Variablename>:<DefaultValue>
# <-<variablename> to input a current variable
# <variablename>-> to export a new variable
$output:1
$SelfDestructionTimer:100
$Speed:1.0

do
if (GetQueuedMoveCount 0 eq)
QueueMove(RandCoords <-Speed)
end
place CurrentCoords <-output AddCreeper
<-SelfDestructionTimer 1 subtract ->SelfDestructionTimer
If <-SelfDestructionTimer is <=0 then
Destroy(Self 2)
endif
loop

I also double-checked the caps-sensitivity before you yell at me! Noting this cause otherwise someone will be all  8) and ask about case sensitivity!
Title: Re: CRPL making CRPL making CRPL error
Post by: GameGibu on January 03, 2016, 08:33:02 PM
are you sure that the units are not underneath the spawner? That happened to me today while debugging my own scripts, as my cannonball cores weren't moving, but they were being spawned.

If nothing seems to work, try rewriting that section of code without referencing the old version. That's worked for me 10/5 times.

Best of luck,fellow CRPL scripter!  ;D ;D
-GameGibu
Title: Re: CRPL making CRPL making CRPL error
Post by: Builder17 on January 04, 2016, 03:53:21 AM
You don't set spawn amount of CreatorNest1 anywhere?

And should this be endif in FlyingUnit script?
And place isn't command in FlyingUnit.
You want eq instead is in FlyingUnit script.
<=0 should be changed into lte.
And in CRPL then isn't used.  :o
Using loop in FlyingUnit seems to be unnecessary.




Title: Re: CRPL making CRPL making CRPL error
Post by: cpaca on January 04, 2016, 10:42:17 AM
The create new CRPL and give it a code command is directly from teknotiss, gibu. But thanks for the assistance.

I'm more used to lua, so i made those mistakes builder17. I'll try the fixes soon. (I got to go sleep)


Months later edit: Just going to make 5 creatornest 2's. The creatornest1's suicide after spawning 5 things was my intent, but it works my way too.