This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| crpl:docs:distance [2013/01/18 18:18] – grauniad | crpl:docs:distance [2025/02/14 14:57] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ~~DISCUSSION~~ | ||
| <- [[crpl: | <- [[crpl: | ||
| ===== 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 === | ||
| - | < | + | < |
| + | |||
| + | #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 | ||
| + | </ | ||