-
Notifications
You must be signed in to change notification settings - Fork 12
/
D0S.Autominer
54 lines (44 loc) · 1.89 KB
/
D0S.Autominer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
:global int diggerpos
:local int pos
; Set this to 1 to get infinite-loop behavior
#infinite 0
; Compile-time code switch for small bits of code that are different
; between infinite and non-infinite versions
#if_infinite(true_part, false_part) {lua(\
return {infinite}~=0 and [[{true_part}]] or [[{false_part}]]\
)}
:name D0S.{if_infinite(InfiniMiner,Autominer)}
wakeup()
open.mine()
isopen("mine")
diggerpos = diggerpos + 1
; The execute is a no-op for the last one.
; We create an extra Miner because, due to timing the
; last two can't be distinguished by drillpos # by the time it's
; assigned to pos.
; This creates 35 copies, which will end up numbered 2-35 (with
; two copies of 35).
execute(if(diggerpos < 35, "D0S.{if_infinite(InfiniMiner,Autominer)}", ""))
; diggerpos is inc'd once by this script and once by the script we spawn
; before this line is executed.
; We use the 3rd-to-last copy as a control, and assign it the number 33.
; It will handle tabbing. The last two copies get assigned
; number position 32, and are responsible for new layers. All the rest
; dig, according to their position. By having two copies for everything
; (including layers) using numbers that are sequential, we guarantee that
; each pair will alternate positions in the 2-action long loop, and thus
; hit one action per frame.
; We choose a late numbers for the tab/layer scripts so that all the
; diggers are already rolling by the time they get to their logic.
setpos:
pos = if(pos > 0, {if_infinite(if(pos > 43, 33, pos + 1), pos + 1)}, if(diggerpos == 34, 33, if(diggerpos == 35, 32, diggerpos - 2)))
tab(pos - 32)
digloop:
dig((pos % 8) / 2, pos / 8)
stall:
goto(if(isopen("mine") & diggerpos > 0, if(pos < 32, digloop, if(pos == 32, new_layer, if(hasLayers(), stall, {if_infinite(setpos, if(pos > 43, done, setpos))}))), done))
new_layer:
newlayer()
gotoif(new_layer, isopen("mine") & diggerpos > 0)
done:
gu("diggerpos")