-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialer.lua
More file actions
85 lines (69 loc) · 1.54 KB
/
Copy pathdialer.lua
File metadata and controls
85 lines (69 loc) · 1.54 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
-- Dialer, by Roy Curtis
-- Using original code by KJ4IPS @
-- files.haun.guru/ComputerCraft/
dofile('dialer.lib.lua')
dofile('dialer.events.lua')
dofile('dialer.paintutils.lua')
exiting = false
debugging = false
state = {
width = 0, -- Screen width
height = 0, -- Screen height
scale = 1.0,
entryX = 0, -- Entry columns X
entryY = 0, -- Entry columns Y
entryW = 18, -- Entry column width
buttons = {},
selected = nil -- Selected book
}
pMonitor = nil
pChest = nil
pMusic = nil
function Init()
print('Dialer Server 0.3')
redstone.setOutput('bottom', true)
discoverPeripherals()
prepareUI()
setPortal()
Loop()
end
function Loop()
print 'Running. Press HOME for help.'
repeat
-- Draw UI
clearUI()
updateButtons()
drawBanner()
drawButtons()
-- Handle events
event, p1, p2, p3, p4 = os.pullEvent()
debug('Event: ', event)
-- Events handled in dialer.events.lua
if event == 'key'
then onKey(p1)
elseif event == 'monitor_touch'
then onTouch(p1, p2, p3)
elseif event == 'monitor_resize'
then onResize(p1)
elseif event == 'peripheral'
then onPeripheral(p1)
elseif event == 'peripheral_detach'
then onPeripheral(p1)
end
until exiting
Exit()
end
function Exit()
setPortal()
clearUI()
redstone.setOutput('bottom', false)
os.reboot()
end
function Panic(err)
print("*** PANIC: ", err)
print("*** Auto-reboot in 5 seconds...")
sleep(5)
os.reboot()
end
success, err = pcall(Init)
if not success then Panic(err) end