This commit is contained in:
2026-04-06 14:35:45 -07:00
parent eb4659817e
commit df2360ca46
8 changed files with 11 additions and 240 deletions

View File

@@ -1,11 +1,11 @@
local db = require("stratumBackend")
print("setup backend")
local completion = require("cc.completion")
local total_items = {}
local monitor = peripheral.find("monitor")
local price_map = {}
local unit_name = nil
local full_item_qoute
local dirtied = false
term.clear()
local x,y = term.getSize()
term.setCursorPos(1,y)
@@ -79,6 +79,7 @@ local function input()
total_items[added_item_name] = (total_items[added_item_name] or 0 ) + added_item_count
price_map[added_item_name] = db.getPrice(added_item_name)
end
dirtied = true
end
elseif event[2] == keys.l then
for k,v in pairs(total_items) do
@@ -126,6 +127,7 @@ local function input()
print("removed item")
end
end
dirtied = true
elseif event[2] == keys.n then
sleep(0)
term.setCursorPos(1,y)
@@ -136,6 +138,7 @@ local function input()
unit_name = unit_namel
print("set currency unit")
end
dirtied = true
elseif event[2] == keys.c then
sleep(0)
local added_currency_name = nil
@@ -159,6 +162,7 @@ local function input()
db.setWorth(added_currency_name,added_currency_worth)
end
end
dirtied = true
elseif event[2] == keys.i then
sleep(0)
local added_item_name = nil
@@ -185,6 +189,7 @@ local function input()
price_map[added_item_name] = db.getPrice(added_item_name)
end
end
dirtied = true
end
end
end
@@ -193,7 +198,7 @@ end
local function render_monitor()
while true do
sleep(0)
if monitor then
if monitor and dirtied then
if not full_item_qoute then
if not unit_name then
unit_name = db.getCurrencyUnit()
@@ -208,7 +213,7 @@ local function render_monitor()
total = total + (( price_map[k] or 0)*v)
end
monitor.setCursorPos(1,y)
monitor.write("total: "..tostring(total).." "..tostring(db.getCurrencyUnit()))
monitor.write("total: "..tostring(total).." "..tostring(unit_name))
else
if not unit_name then
unit_name = db.getCurrencyUnit()
@@ -227,8 +232,9 @@ local function render_monitor()
monitor.setCursorPos(1,1)
monitor.write("Full Item Quote:")
monitor.setCursorPos(1,y)
monitor.write("total: "..tostring(total).." "..tostring(db.getCurrencyUnit()))
monitor.write("total: "..tostring(total).." "..tostring(unit_name))
end
dirtied = false
end
end
end