Tony's Secret Codes

Started by TonyP2000, December 18, 2012, 09:06:20 PM

Previous topic - Next topic

TonyP2000

Here is where I will post some some of my best codes, as well as when they mean and how they work. Be free to discuss and comment.

Here is my first "big one". I Modified V's last example code on his CRPL Docs page to give it a delay as well as a couple other tricks. I did not actually copy and paste it but actually tried to build the code from scratch using the CRPL page as reference. It really helped me get use to some of the syntax and this whole thing is making much more sense now.

Quote
# Set Timer to 200 frames
# Once timer runs out, wonder around the map at a fast pace while dropping D, D Growth, Creeper, 20 Runners
# The second the timer runs out, launch 5 Spores, do not repeat

# Set timer to 200 frames
Once
   200 delay
EndOnce

#Once timer hits 0 than launch 5 spores once
Once
5 0 do
CurrentCoords RandCoords 1 20 CreateSpore
loop
Endonce

#Start moving in random direction
GetQueuedMoveCount eq0 if
   RandCoords 7 QueueMove
EndIf

#Leave a trail of Growth, D, and and Creeper
CurrentCoords 10 AddCreeper

#Create Some D and some Growth
CurrentY 2 add CurrentY 1 sub do
   CurrentX 2 add CurrentX 1 sub do
      I J true SetDigitalisGrowth
      I J 1 SetDigitalis
   Loop
Loop

# Leave exactly 20 runners after 10 frames and replace the second one is killed
# First Set Timer1
GetTimer1 eq0 if
   # Check how many runners are on the feild
   GetRunnerCount 20 lt if
      CurrentCoords 20 10 10 CreateRunner
      1 SetTimer1
   Endif
Endif

So what does it do?

  • It first has a 200 frame delay before it activates
  • After delay ends, the tower launches 5 spores to random locations on the map
  • The next set is to start moving around the map at a speed of 7
  • As it moves, it leaves a trail of Creeper, D and D growth area
  • It also sends out a "burst" of 20 runners without any delay

This code could be used for creating a countdown to when a map becomes unwinnable. Since the tower will be moving too fast and leaving a mess behind it, the player cannot build anything.

BONUS

Just for fun's sake, here is a code that allows a tower to move around the map leaving a trail of walls.

Quote
# Make A wall as the tower moves to a random location

# Get it to move around the map
GetQueuedMoveCount eq0 if
   RandCoords 0.5 QueueMove
Endif

# Make a wall
CurrentCoords 1 SetWall
/quote]
Vote Tony!

knucracker

Very nice.  Cool to see two once/endonce blocks used in the same script.
In your final block where you create the Runners, you can probably leave out the Timer stuff.  Since you are creating them very fast, you don't need the timer to delay things.