This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
crpl:docs:distance [2013/01/14 19:07] – created chani | crpl:docs:distance [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | TODO | + | <- [[crpl: |
+ | ===== Distance | ||
+ | |||
+ | ^Arguments^Result^Notation^ | ||
+ | |Two sets of coordinates x1,y1 x2,y2| |'' | ||
+ | |||
+ | |||
+ | === 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: | ||
+ | $stepWidth: | ||
+ | $min:1 | ||
+ | $max:10 | ||
+ | |||
+ | once | ||
+ | CurrentX -> | ||
+ | CurrentY -> | ||
+ | do (< | ||
+ | do (< | ||
+ | < | ||
+ | < | ||
+ | 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(< | ||
+ | #Caps the terrain to a minimum of 1 and a maximum of 10. Interestingly, | ||
+ | min(< | ||
+ | SetTerrain(< | ||
+ | loop | ||
+ | loop | ||
+ | endonce | ||
+ | </ | ||
+ |