-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstartup.lua
More file actions
42 lines (33 loc) · 997 Bytes
/
Copy pathstartup.lua
File metadata and controls
42 lines (33 loc) · 997 Bytes
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
-- Init user data:
require("initUserdata")
-- Load devices:
local device = require("devices")
local storage = require("storage")
local relay = peripheral.find("redstone_relay") or error("Redstone relay required to be connected.")
local logger = require("logger")
-- Display on monitor:
local ui = require("ui")
local comments = {
"System booted up!"
}
local function main()
ui.update(comments)
if not relay.getInput("front") then return false end
-- Perform transaction:
logger.write("BEGIN: Transaction -------------")
comments = storage.performTransactions()
logger.write("END: Transaction ---------------\n")
return true
end
print("Initialised, listening for redstone requests...")
while true do
-- Perform purchase or exit early:
local moreTime = main()
ui.update(comments)
-- Reset comments after being drawn:
comments = {}
-- Sleep:
local sleepTime = 0.2
if moreTime then sleepTime = 2 end
os.sleep(sleepTime)
end