Move config from test.lua to config.lua

This commit is contained in:
Ben 2024-06-01 01:37:49 +02:00
parent e1b385fffc
commit 15fdb806aa
Signed by: ben
GPG key ID: 0F54A7ED232D3319
2 changed files with 25 additions and 25 deletions

11
config.lua Normal file
View file

@ -0,0 +1,11 @@
return {
has_me = true,
main_system_ae_bridge_side = "right",
main_me_inventory_side = "up",
colony_interface_side = "left",
monitor_side = "top",
monitor_scale = 1.0,
step_sleep_time = 0.5,
round_sleep_time = 60.0,
initial_tab = 1,
}

View file

@ -1,27 +1,16 @@
-- options --
local has_me = true
local main_system_ae_bridge_side = "right"
local main_me_inventory_side = "up"
local colony_interface_side = "left"
local monitor_side = "top"
local monitor_scale = 1.0
local step_sleep_time = 0.5
local round_sleep_time = 60.0
local current_tab = 1
-- runtime variables --
local config = require "config"
local pretty = require "cc.pretty"
local permset = require "permset"
local main_me = {}
if has_me then
main_me = peripheral.wrap(main_system_ae_bridge_side)
if config.has_me then
main_me = peripheral.wrap(config.main_system_ae_bridge_side)
end
local colony = peripheral.wrap(colony_interface_side)
local colony = peripheral.wrap(config.colony_interface_side)
local requests = {}
local orders = {}
local current_tab = config.initial_tab
-- to match click positions back to item names
local display_list = {}
@ -224,17 +213,17 @@ function wait_for(time_secs)
end
if peripheral.isPresent(monitor_side) then
monitor = peripheral.wrap(monitor_side)
monitor.setTextScale(monitor_scale)
if peripheral.isPresent(config.monitor_side) then
monitor = peripheral.wrap(config.monitor_side)
monitor.setTextScale(config.monitor_scale)
term.redirect(monitor)
end
function get_requests()
requests = {}
local reqs = colony.getRequests()
local me_items = has_me
if has_me then
local me_items = config.has_me
if config.has_me then
me_items = main_me.listItems()
end
for i, req in pairs(reqs) do
@ -249,7 +238,7 @@ function get_requests()
if left_amount > 0 and allowed_items[it.name] == true then
local export_amount = math.min(have_it.amount, left_amount)
left_amount = left_amount - export_amount
main_me.exportItem({name=it.name, count=export_amount}, main_me_inventory_side)
main_me.exportItem({name=it.name, count=export_amount}, config.main_me_inventory_side)
end
end
end
@ -258,7 +247,7 @@ function get_requests()
if found == false then
table.insert(requests, {req=req, answer=nil})
end
wait_for(step_sleep_time)
wait_for(config.step_sleep_time)
end
end
@ -269,7 +258,7 @@ function get_orders()
for i, order in pairs(orders) do
local res = colony.getWorkOrderResources(order.id)
table.insert(orders, {id=order.id, type=order.workOrderType, target=order.type, pos=order.builder, item=res.item, claimed=order.isClaimed, delivering=res.delivering})
wait_for(step_sleep_time)
wait_for(config.step_sleep_time)
end
end
end
@ -279,5 +268,5 @@ while true do
get_requests()
get_orders()
currently_working = false
wait_for(round_sleep_time)
wait_for(config.round_sleep_time)
end