Knuckle Cracker

Creeper World 4 => Making Maps, Units, and Scripts => Topic started by: Crimson King on March 01, 2021, 08:35:33 PM

Title: Help converting a scipt from crpl to 4rpl
Post by: Crimson King on March 01, 2021, 08:35:33 PM
I have this working code in a CW3 map that I would like to use in a CW4 map. The one change that I know needs to be made to accommodate the 20 levels of terrain is to change the 10 in the multiplication line to a 5. Terrain with a height of 1 should stay a height of 1 and void needs to stay 2146. The script also needs to run on a regular basis so that any changes to terrain are reflected by the override height.

once
MapHeight ->X
MapWidth ->Y
endonce

<-X 0 do
<-Y 0 do
I J GetTerrain ->A
<-A 1 neq if
<-A 2 pow ->B
<-B 10 mul ->C
I J <-C SetTerrainOverride
else
I J 1 SetTerrainOverride
endif
loop
1 Delay
loop
Title: Re: Help converting a scipt from crpl to 4rpl
Post by: GoodMorning on March 02, 2021, 04:25:42 AM
Assuming that you're not planning for void to be terraformed:

GetGameUpdateCount 30 mod eq0 if # Once per second
MapHeight 0 do
MapWidth 0 do
I J dup2 GetTerrain dup 1 gt if
2 pow 5 mul SetTerrainOverride
else
2 mul 1 sub SetTerrainOverride
endif
loop
loop
endif
Title: Re: Help converting a scipt from crpl to 4rpl
Post by: Crimson King on March 02, 2021, 06:59:34 PM
Thank you for the code.

Are the MapHeight and MapWidth commands supported in 4rpl or does one need to use GetMapSize and store the returned values to variables?
Title: Re: Help converting a scipt from crpl to 4rpl
Post by: Karsten75 on March 02, 2021, 07:06:01 PM
 use GetMapSize and store the returned values to variables.

You can find all the commands here:

https://knucklecracker.com/wiki/doku.php?id=4rpl:start