feat: add more fail-safes
This commit is contained in:
parent
03213c3ab7
commit
8e07f8adc9
1 changed files with 44 additions and 34 deletions
78
code.fnl
78
code.fnl
|
@ -1,45 +1,55 @@
|
||||||
(local depth 60)
|
(local depth 60)
|
||||||
(local cable-dir "left")
|
(local cable-dir :left)
|
||||||
(local outputs {
|
(local outputs {:right 1
|
||||||
:right 1
|
:left 2
|
||||||
:left 2
|
:up 4
|
||||||
:up 4
|
:down 8
|
||||||
:down 8
|
:break 16
|
||||||
:break 16
|
:rejuv 32
|
||||||
:rejuv 32})
|
:error 64
|
||||||
|
:check 128})
|
||||||
|
|
||||||
(fn pulse-signal [output]
|
(fn pulse-signal [output]
|
||||||
(local id (. outputs output))
|
(local id (. outputs output))
|
||||||
|
|
||||||
(redstone.setBundledOutput cable-dir id)
|
(redstone.setBundledOutput cable-dir id)
|
||||||
(os.sleep 1)
|
(os.sleep 1)
|
||||||
(redstone.setBundledOutput cable-dir 0)
|
(redstone.setBundledOutput cable-dir 0)
|
||||||
(os.sleep 1))
|
(os.sleep 1))
|
||||||
|
|
||||||
|
(fn check-gantry []
|
||||||
|
(print "Checking gantry position")
|
||||||
|
(redstone.setBundledOutput cable-dir (. outputs :break))
|
||||||
|
(os.sleep 2)
|
||||||
|
(when (not (= (redstone.getBundledInput cable-dir)
|
||||||
|
(+ (. outputs :break) (. outputs :check))))
|
||||||
|
(error "Incorrect gantry position!")))
|
||||||
|
|
||||||
(print "Moving gantry into chunk")
|
(fn run []
|
||||||
(for [_ 1 16]
|
(check-gantry)
|
||||||
(pulse-signal :right))
|
(print "Moving gantry into chunk")
|
||||||
|
(for [_ 1 16]
|
||||||
|
(pulse-signal :right))
|
||||||
|
(print :Mining)
|
||||||
|
(for [_ 1 depth]
|
||||||
|
(pulse-signal :down)
|
||||||
|
(pulse-signal :break))
|
||||||
|
;; Wait for items to go into chest
|
||||||
|
(print "Waiting for items")
|
||||||
|
(os.sleep 60)
|
||||||
|
(print "Resetting gantry")
|
||||||
|
(for [_ 1 depth]
|
||||||
|
(pulse-signal :up))
|
||||||
|
(for [_ 1 16]
|
||||||
|
(pulse-signal :left))
|
||||||
|
(os.sleep 3)
|
||||||
|
(check-gantry)
|
||||||
|
(print "Activating rejuvenator")
|
||||||
|
(redstone.setBundledOutput cable-dir (. outputs :rejuv))
|
||||||
|
(os.sleep 20)
|
||||||
|
(redstone.setBundledOutput cable-dir 0)
|
||||||
|
nil)
|
||||||
|
|
||||||
(print "Mining")
|
(local (_ err) (pcall run []))
|
||||||
(for [_ 1 depth]
|
(when err
|
||||||
(pulse-signal :down)
|
(print err)
|
||||||
(pulse-signal :break))
|
(redstone.setBundledOutput cable-dir (. outputs :error)))
|
||||||
|
|
||||||
;; Wait for items to go into chest
|
|
||||||
(print "Waiting for items")
|
|
||||||
(os.sleep 60)
|
|
||||||
|
|
||||||
(print "Resetting gantry")
|
|
||||||
(for [_ 1 depth]
|
|
||||||
(pulse-signal :up))
|
|
||||||
|
|
||||||
(for [_ 1 16]
|
|
||||||
(pulse-signal :left))
|
|
||||||
|
|
||||||
(os.sleep 3)
|
|
||||||
|
|
||||||
(print "Activating rejuvenator")
|
|
||||||
(redstone.setBundledOutput cable-dir (. outputs :rejuv))
|
|
||||||
(os.sleep 20)
|
|
||||||
(redstone.setBundledOutput cable-dir 0)
|
|
||||||
|
|
Loading…
Reference in a new issue