I'm trying to scan every cell on a map and put 500 terrain override on level 10 terrain, but
my script is just making the game lag.
once
MapWidth ->xc
MapHeight ->yc
MapHeight ->mh
MapWidth ->mw
endonce
<-mw 1 add 0 do
MapHeight ->yc
<-mh 1 add 0 do
<-xc <-yc GetTerrain ->lop
<-lop 10 eq if
<-xc <-xy 500 SetTerrainOverride
endif
<-yc 1 min
loop
<-xc 1 min
loop
Any help?
Well, looking through your code, you're leaving stuff on the stack needlessly, unless I'm missing something.
Entirely untested, but this is all you should have to do with the loops...
MapHeight 0 do
MapWidth 0 do
I J GetTerrain 10 eq if
I J 500 SetTerrainOverride
endif
loop
loop
Checking every cell on the map every game frame is bound to slow things down.
Options to reduce lag off the top of my head:
-Only run it once (and disable terps and mass artifacts)
-Set a delay so it only runs every so often
EDIT: Whoops, do loops compare at the end of the loop, so the limit should just be the width/height. Fixed.
Thank you! I'm not that good with CRPL yet. This will really help.