Update startup.lua
This commit is contained in:
33
startup.lua
33
startup.lua
@@ -1,8 +1,7 @@
|
||||
local db = require("localdb")
|
||||
local db = require("remotedb")
|
||||
local completion = require("cc.completion")
|
||||
local total_items = {}
|
||||
local monitor = peripheral.find("monitor")
|
||||
db.setCurrencyUnit("diamonds")
|
||||
term.clear()
|
||||
local x,y = term.getSize()
|
||||
term.setCursorPos(1,y)
|
||||
@@ -85,6 +84,15 @@ local function input()
|
||||
print("removed item")
|
||||
end
|
||||
end
|
||||
elseif event[2] == keys.n then
|
||||
sleep(0)
|
||||
term.setCursorPos(1,y)
|
||||
term.write("unit name > ")
|
||||
local unit_name = read()
|
||||
if unit_name ~= "" then
|
||||
db.setCurrencyUnit(unit_name)
|
||||
print("set currency unit")
|
||||
end
|
||||
elseif event[2] == keys.c then
|
||||
sleep(0)
|
||||
local added_currency_name = nil
|
||||
@@ -132,5 +140,22 @@ local function render_monitor()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
parallel.waitForAny(input, render_monitor)
|
||||
local loops = {input,render_monitor}
|
||||
if db.loop then loops[#loops+1] = db.loop end
|
||||
if db.loops then loops = {table.unpack(loops),table.unpack(db.loops)} end
|
||||
for k,v in ipairs(loops) do
|
||||
---@cast loops thread[]
|
||||
loops[k] = coroutine.create(v)
|
||||
coroutine.resume(loops[k])
|
||||
end
|
||||
while true do
|
||||
local event = {os.pullEvent()}
|
||||
for _,v in ipairs(loops) do
|
||||
if coroutine.status(v) ~= "dead" then
|
||||
local succ, err = coroutine.resume(v, table.unpack(event))
|
||||
if not succ then
|
||||
print(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user