Fix permset usage for allowed_items

This commit is contained in:
Ben 2024-06-01 02:03:04 +02:00
parent b70c72c535
commit 49386888c0
Signed by: ben
GPG key ID: 0F54A7ED232D3319

View file

@ -37,7 +37,7 @@ function requestsDisplay()
term.setTextColor(colors.orange) term.setTextColor(colors.orange)
term.write("N/A") term.write("N/A")
else else
if allowed_items[val.answer.name] then if permset.has(allowed_items, val.answer.name) then
term.setTextColor(colors.green) term.setTextColor(colors.green)
else else
term.setTextColor(colors.yellow) term.setTextColor(colors.yellow)
@ -47,7 +47,7 @@ function requestsDisplay()
term.setTextColor(colors.white) term.setTextColor(colors.white)
term.setCursorPos(tw-4,line_num) term.setCursorPos(tw-4,line_num)
term.write(" [") term.write(" [")
if allowed_items[val.answer.name] then if permset.has(allowed_items, val.answer.name) then
term.setTextColor(colors.green) term.setTextColor(colors.green)
term.write("X") term.write("X")
term.setTextColor(colors.white) term.setTextColor(colors.white)
@ -182,10 +182,10 @@ function on_touch(touch_x, touch_y)
end end
elseif current_tab == 1 and touch_x > tw-5 and display_list[touch_y] ~= nil then elseif current_tab == 1 and touch_x > tw-5 and display_list[touch_y] ~= nil then
local item_name = display_list[touch_y] local item_name = display_list[touch_y]
if allowed_items[item_name] then if permset.has(allowed_items, item_name) then
remove_allowed_item(item_name) permset.remove(allowed_items, item_name)
else else
add_allowed_item(item_name) permset.add(allowed_items, item_name)
end end
return true return true
end end
@ -237,7 +237,7 @@ function get_requests()
if have_it.name == it.name then if have_it.name == it.name then
found = true found = true
table.insert(requests, {req=req, answer=have_it}) table.insert(requests, {req=req, answer=have_it})
if left_amount > 0 and allowed_items[it.name] == true then if left_amount > 0 and permset.has(allowed_items, it.name) then
local export_amount = math.min(have_it.amount, left_amount) local export_amount = math.min(have_it.amount, left_amount)
left_amount = left_amount - export_amount left_amount = left_amount - export_amount
main_me.exportItem({name=it.name, count=export_amount}, config.main_me_inventory_side) main_me.exportItem({name=it.name, count=export_amount}, config.main_me_inventory_side)