36 lines
1.6 KiB
Scheme
36 lines
1.6 KiB
Scheme
|
; This is a janky set of routines to make building stairs easier.
|
||
|
; More than anything it's just here to show off our fancy scripting
|
||
|
; capabilities. I suppose if you bound this to some keyboard shortcut
|
||
|
; it'd be a good time saver though :)
|
||
|
(progn
|
||
|
; CONFIG:
|
||
|
(define AXIS X)
|
||
|
(define STAIR_SIZE 0.25)
|
||
|
(define (lerp start end percent)
|
||
|
(+ start (* percent (- end start))))
|
||
|
(define (build-stairs-x sx sy sw sl step height-a height-b)
|
||
|
(do ((i 0 (+1 i)))
|
||
|
((>= i (/ sw step)) (print "done"))
|
||
|
(let* ((points (((+ (* i step) sx) sy)
|
||
|
((+ (* i step) sx) (+ sy sl))
|
||
|
((+ (* i step) sx step) (+ sy sl))
|
||
|
((+ (* i step) sx step) sy)))
|
||
|
(floor-height (lerp height-a height-b (/ i (/ sw step))))
|
||
|
(ceiling-height (+ 4 floor-height)))
|
||
|
(make-sector-from-points floor-height ceiling-height points))))
|
||
|
(define (build-stairs-y sx sy sw sl step height-a height-b)
|
||
|
(do ((i 0 (+1 i)))
|
||
|
((>= i (/ sl step)) (print "done"))
|
||
|
(let* ((points ((sx (+ (* i step) sy))
|
||
|
((- sx sw) (+ (* i step) sy))
|
||
|
((- sx sw) (+ (* i step) sy step))
|
||
|
(sx (+ (* i step) sy step))))
|
||
|
(floor-height (lerp height-a height-b (/ i (/ sl step))))
|
||
|
(ceiling-height (+ 4 floor-height)))
|
||
|
(make-sector-from-points floor-height ceiling-height points))))
|
||
|
(fill-selection
|
||
|
(lambda (x1 y1 x2 y2 nh1 nh2 dir)
|
||
|
(if (= AXIS X)
|
||
|
(build-stairs-x x1 y1 (abs (- x2 x1)) (abs (- y2 y1)) STAIR_SIZE nh1 nh2)
|
||
|
(build-stairs-y x2 y2 (abs (- x2 x1)) (abs (- y2 y1)) STAIR_SIZE nh1 nh2)))))
|