Help converting a scipt from crpl to 4rpl

Started by Crimson King, March 01, 2021, 08:35:33 PM

Previous topic - Next topic

Crimson King

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

GoodMorning

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
A narrative is a lightly-marked path to another reality.

Crimson King

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?

Karsten75

#3
 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