<- [[crpl:crplreference|CRPL reference]] <- [[crpl:crplreference#utility_commands|Utility Commands]] ===== Distance ===== ^Arguments^Result^Notation^ |Two sets of coordinates x1,y1 x2,y2| |''x1 y1 x2 y2-- f1 ''| === Description === Calculates the distance between two map points (x1,y1) to (x2,y2) and pushes the resulting floating point number to the stack. === Examples === #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