From 15fdb806aae519527cce3b00970ca1591d1c05f4 Mon Sep 17 00:00:00 2001 From: Benedikt Ziemons Date: Sat, 1 Jun 2024 01:37:49 +0200 Subject: [PATCH] Move config from test.lua to config.lua --- config.lua | 11 +++++++++++ test.lua | 39 ++++++++++++++------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 config.lua diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..40ef23f --- /dev/null +++ b/config.lua @@ -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, +} diff --git a/test.lua b/test.lua index aa4eb72..13ebbb8 100644 --- a/test.lua +++ b/test.lua @@ -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