Help with Terrain Code

Started by Nicant, June 11, 2016, 11:04:34 PM

Previous topic - Next topic

Nicant

Hello, i need help! I was using this code to convert Level 10 terrain to level 1000. The Problem is when i used the code the entire map got converted into level 1000 terrain! The code moves throughout the entire map and changes the terrain level.

Here is the code:

# InfiniteWall.crpl
# Created on: 5/24/2016 5:56:33 PM
# ------------------------------------------

$add1:0
$add2:1
$1:249
$2:0
$Ok:0

once
OperateWhilePaused(True)
249 0 2 QueueMove
endonce

CurrentCoords GetTerrain 10 if
CurrentCoords 1000 SetTerrainOverride
endif

<-Ok eq0 if
CurrentX <-1 eq if
CurrentY <-add1 eq if
<-1 <-add2 2 QueueMove
60 Delay
<-2 <-add2 2 QueueMove
<-add1 1 add ->add1
<-add2 1 add ->add2
249 ->1
0 ->2
1 ->Ok
endif
endif
endif

<-Ok 1 eq if
CurrentX <-2 eq if
CurrentY <-add1 eq if
<-2 <-add2 2 QueueMove
60 Delay
<-1 <-add2 2 QueueMove
<-add1 1 add ->add1
<-add2 1 add ->add2
249 ->1
0 ->2
0 ->Ok
endif
endif
endif












#Below this is just a model for code above

#CurrentX 249 eq if
#CurrentY 0 eq if
#249 1 2 QueueMove
#30 Delay
#0 1 2 QueueMove
#endif
#endif

#CurrentX 0 eq if
#CurrentY 1 eq if
#0 2 2 QueueMove
#30 Delay
#249 2 2 QueueMove
#endif
#endif

#CurrentX 249 eq if
#CurrentY 2 eq if
#249 3 2 QueueMove
#30 Delay
#0 3 2 QueueMove
#endif
#endif

#CurrentX 0 eq if
#CurrentY 3 eq if
#0 4 2 QueueMove
#30 Delay
#249 4 2 QueueMove
#endif
#endif


Any help will be greatly appreciated and will be asked if they want credit for helping me on the map that i am making!
CW4 hype!!

planetfall

CurrentCoords GetTerrain 10 eq if
Pretty sure I'm supposed to be banned, someone might want to get on that.

Quote from: GoodMorning on December 01, 2016, 05:58:30 PM"Build a ladder to the moon" is simple as a sentence, but actually doing it is not.

GoodMorning

Having run the code, do you want:

once
  1 OperateWhilePaused
  Self CONST_CREATEPZ 0 SetUnitAttribute
  2 ->Speed # Keep below 8, or locations will be missed.
 
  Self CONST_COORDX 0 SetUnitAttribute
  Self CONST_COORDY 0 SetUnitAttribute
 
  MapHeight 0 do
    I 2 mod eq0 if #Alternate directions
      MapWidth 1 sub I <-Speed QueueMove
      MapWidth 1 sub I 1 add <-Speed QueueMove #Next row
    else
      0 I <-Speed QueueMove
      0 I 1 add <-Speed QueueMove #Next row
    endif
  loop
endonce

CurrentCoords GetTerrain 10 eq if
  CurrentCoords 1000 SetTerrainOverride
else
  CurrentCoords -1 SetTerrainOverride
endif

GetQueuedMoveCount eq0 if
  Self 0 Destroy
endif #Clean up after yourself.


You could also use loops to set the terrain, without dragging around a Core.
A narrative is a lightly-marked path to another reality.

Nicant

#3
Quote from: planetfall on June 11, 2016, 11:58:09 PM
CurrentCoords GetTerrain 10 eq if
Ohhhhhhhh. That's what it was! Completely forgot that! XD Face-Palming so much right now. Do you want to be credited for helping me with the map?



Quote from: GoodMorning on June 12, 2016, 02:47:37 AM
Having run the code, do you want:

once
  1 OperateWhilePaused
  Self CONST_CREATEPZ 0 SetUnitAttribute
  2 ->Speed # Keep below 8, or locations will be missed.
 
  Self CONST_COORDX 0 SetUnitAttribute
  Self CONST_COORDY 0 SetUnitAttribute
 
  MapHeight 0 do
    I 2 mod eq0 if #Alternate directions
      MapWidth 1 sub I <-Speed QueueMove
      MapWidth 1 sub I 1 add <-Speed QueueMove #Next row
    else
      0 I <-Speed QueueMove
      0 I 1 add <-Speed QueueMove #Next row
    endif
  loop
endonce

CurrentCoords GetTerrain 10 eq if
  CurrentCoords 1000 SetTerrainOverride
else
  CurrentCoords -1 SetTerrainOverride
endif

GetQueuedMoveCount eq0 if
  Self 0 Destroy
endif #Clean up after yourself.


You could also use loops to set the terrain, without dragging around a Core.


Yeah, i knew there was some other way to change the terrain than dragging the core, but i had already made this code. As you have seen above, my problem was a missing "eq". The mistake was so small i did not even notice. Thanks for the help though! Do you want to be credited for helping me with the map?
Edit: Just Used your code, it is a lot better than my code! :)
CW4 hype!!

GoodMorning

Don't waste time crediting me, make a great map, and the play is the thing.
A narrative is a lightly-marked path to another reality.