User Tools

Site Tools


crpl:docs:distance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
crpl:docs:distance [2014/10/01 15:02] – external edit 127.0.0.1crpl:docs:distance [2024/05/13 14:45] (current) kaiden
Line 1: Line 1:
-~~DISCUSSION~~ 
 <- [[crpl:crplreference|CRPL reference]] <- [[crpl:crplreference#utility_commands|Utility Commands]] <- [[crpl:crplreference|CRPL reference]] <- [[crpl:crplreference#utility_commands|Utility Commands]]
 =====  Distance  ===== =====  Distance  =====
Line 10: Line 9:
 Calculates the distance between two map points (x1,y1) to (x2,y2) and pushes the resulting floating point number to the stack. Calculates the distance between two map points (x1,y1) to (x2,y2) and pushes the resulting floating point number to the stack.
 === Examples === === Examples ===
-<code>example goes here</code> +<code> 
 + 
 +#Terrain modification script to build a circular pyramid. 
 +#Keep in mind modifying terrain on a large scale like this can lag the game badly for a short moment, so not recommended to do this mid-level unless you slow the loops. 
 + 
 +$radius:30 
 +$stepWidth:3.0 
 +$min:1 
 +$max:10 
 + 
 +once 
 + CurrentX ->centerX  
 + CurrentY ->centerY 
 + do (<-radius add(1) <-radius mul(-1)) 
 + do (<-radius add(1) <-radius mul(-1)) 
 + <-centerX add(I) ->x 
 + <-centerY add(J) ->y 
 + distance(CurrentCoords <-x <-y) ->dist 
 + #Finds what height to set terrain to. Step width divides the height and as a result makes each pyramid step wider. Also rounds up the current value. 
 + ceil(<-radius sub(<-dist) div(<-stepWidth)) ->height 
 + #Caps the terrain to a minimum of 1 and a maximum of 10. Interestingly, the maximum can be set to above its current value if you want a volcano formation. 
 + min(<-max max(<-height <-min)) ->height 
 + SetTerrain(<-x <-y <-height) 
 + loop 
 + loop 
 +endonce 
 +</code> 
  
  
crpl/docs/distance.1412190170.txt.gz · Last modified: 2015/03/19 17:52 (external edit)