Help converting a scipt from crpl to 4rpl

Crimson King · 437

Crimson King

  • Jr. Member
  • **
    • Posts: 65
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.

Code: [Select]
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

  • Community Guild
  • *****
    • Posts: 3452
  • (Pusillanimous)
Reply #1 on: March 02, 2021, 04:25:42 am
Assuming that you're not planning for void to be terraformed:
Code: [Select]
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

  • Jr. Member
  • **
    • Posts: 65
Reply #2 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?



Karsten75

  • Hero Member
  • *****
    • Posts: 7117
Reply #3 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
« Last Edit: March 02, 2021, 07:07:34 pm by Karsten75 »

'If you want to live a happy life, tie it to a goal, not to people or things.'

Albert Einstein
(1879-1955)