is it possible for us to make a new terrain in a void using CPRL??
yes (http://knucklecracker.com/wiki/doku.php?id=crpl:crplreference#terrain_and_wall_commands)
can you give me the script?
Simply use the SetTerrain command, works fine no matter if the cell was void or terrain before calling the command.
set terrain is x1 y1 n1 – right?
so if we take 52,83 and height is 5
then
52 83 5 -
??
x y height SetTerrain
52 83 5 SetTerrain
oh wow,so the "-" is the place to put command
and what should i use ,when i put a unit on the core,the other command will active? use if ?
CurrentCoords 0 GetUnitCountInRange neq0 if
52 83 5 SetTerrain
100000 delay
endif
Using warp notation:
if (GetUnitCountInRange(CurrentCoords 0) neq0)
SetTerrain(52 83 5)
delay(100000)
endif
I'm looking at creating a script that can raise or lower terrain by 1 level in square big enough for a single unit. What I'd like it to do is have it pick random coords and raise or lower the terrain if the height is not equal to 5. How would I go about this?
I believe this should do the trick, though I haven't tested it.
terrange is the range from the current coordinates of the CRPL tower
terrlevel is the level to set the terrain to
the code for the loop to set the terrain in a 3x3 is taken from Virgil's example code on the 'SetDigitalis' page on the wiki link (http://knucklecracker.com/wiki/doku.php?id=crpl:docs:setdigitalis)
# Choose random coordinates in a specified range of current coordinates
# Set terrain in 3x3 square around chosen coordinates to 5 height
#------------------------------------------------------------------
$terrange:10
$terrlevel:5
CurrentCoords <-terrange RandCoordsInRange ->randCoords
<-randCoords ->randX ->randY
<-randY 2 add <-RandY 1 sub do
<-randX 2 add <-randX 1 sub do
I J <-terrlevel SetTerrain
Loop
Loop
That shouldn't work. Change:
CurrentCoords <-terrange RandCoordsInRange ->randCoords
<-randCoords ->randX ->randY
to:
CurrentCoords <-terrange RandCoordsInRange ->randY ->randX
It works but it doesn't. It picks a random location and it changes the terrain height but it doesn't do a 3x3 square. I get columns drawn from the top of the map to the random coords.
Then change:
<-randY 2 add <-RandY 1 sub do
<-randX 2 add <-randX 1 sub do
I J <-terrlevel SetTerrain
Loop
Loop
to:
<-RandX <-RandY <-terrlevel SetTerrain
<-RandX <-RandY 1 sub <-terrlevel SetTerrain
<-RandX <-RandY 1 add <-terrlevel SetTerrain
<-RandX 1 sub <-RandY <-terrlevel SetTerrain
<-RandX 1 sub <-RandY 1 sub <-terrlevel SetTerrain
<-RandX 1 sub <-RandY 1 add <-terrlevel SetTerrain
<-RandX 1 add <-RandY <-terrlevel SetTerrain
<-RandX 1 add <-RandY 1 sub <-terrlevel SetTerrain
<-RandX 1 add <-RandY 1 add <-terrlevel SetTerrain
Crimson King kept talking in my ear so I took a stab at one of his ideas:
$terrange:20
CurrentCoords <-terrange RandCoordsInRange ->randY ->randX
<-randX <-randY GetTerrain ->terrlevel
0 2 RandInt ->updown
<-updown 0 eq if
-1 ->updown
endif
<-terrlevel <-updown add ->terrlevel
<-terrlevel 1 max ->terrlevel
<-randX <-randY <-terrlevel SetTerrain
<-randX 1 add <-randY <-terrlevel SetTerrain
<-randX 2 add <-randY <-terrlevel SetTerrain
<-randX <-randY 1 add <-terrlevel SetTerrain
<-randX 1 add <-randY 1 add <-terrlevel SetTerrain
<-randX 2 add <-randY 1 add <-terrlevel SetTerrain
<-randX <-randY 2 add <-terrlevel SetTerrain
<-randX 1 add <-randY 2 add <-terrlevel SetTerrain
<-randX 2 add <-randY 2 add <-terrlevel SetTerrain
20 delay
Picks a random cell within $terrange, and sets the terrain height of a 3x3 cell to +1 or -1 of the random cell's height. I used upper left instead of center though (I unrolled the the loop before I saw your latest post J). Not that it matters much.
If you replace your replacement with mine it should take the center cell.
Quote from: J on October 19, 2013, 02:38:21 PM
Then change:
<-randY 2 add <-RandY 1 sub do
<-randX 2 add <-randX 1 sub do
I J <-terrlevel SetTerrain
Loop
Loop
to:
<-RandX <-RandY <-terrlevel SetTerrain
<-RandX <-RandY 1 sub <-terrlevel SetTerrain
<-RandX <-RandY 1 add <-terrlevel SetTerrain
<-RandX 1 sub <-RandY <-terrlevel SetTerrain
<-RandX 1 sub <-RandY 1 sub <-terrlevel SetTerrain
<-RandX 1 sub <-RandY 1 add <-terrlevel SetTerrain
<-RandX 1 add <-RandY <-terrlevel SetTerrain
<-RandX 1 add <-RandY 1 sub <-terrlevel SetTerrain
<-RandX 1 add <-RandY 1 add <-terrlevel SetTerrain
No, change
<-randY 2 add <-RandY 1 sub do
<-randX 2 add <-randX 1 sub do
I J <-terrlevel SetTerrain
Loop
Loop
to
<-randY 2 add <-randY 1 sub do
<-randX 2 add <-randX 1 sub do
I J <-terrlevel SetTerrain
Loop
Loop
as randY is defined, but RandY isn't.
Capitals will get you every time, hah.
Thanks everybody for the help with the code. I think I have it pretty close to what I am looking for it to do at this point.