Reformat + add prefix selection for config

This commit is contained in:
Soph :3 2025-11-14 22:43:49 +02:00
parent 88f4173c8e
commit 262c0b5408
13 changed files with 1191 additions and 1141 deletions

View file

@ -1,4 +1,3 @@
---@class InnerRemote
---@field port number
---@field password string
@ -8,11 +7,15 @@
---@field ender_storage string
---@field modem string
---@field remotes table<string, InnerRemote>
---
---@class Chatbox
---@field players table<string, string>
---@field prefix string|nil
---@class Config
---@field inventories string[]
---@field import string[]|nil
---@field chatbox table<string, string>|nil
---@field chatbox Chatbox|nil
---@field remote Remote
local inv = require("modules.inv")
@ -23,32 +26,32 @@ local ra = require("modules.ra")
local config = require("../config") ---@type Config
local function importMechanism()
if config.import == nil then
return
end
if #config.import == 0 then
return
end
if config.import == nil then
return
end
if #config.import == 0 then
return
end
while true do
for _, import_from_inv in ipairs(config.import) do
---@type ccTweaked.peripheral.Inventory
local perip = peripheral.wrap(import_from_inv)
if perip and perip.size then
local slotsToSend = {}
for slot = 1, perip.size() do
local item = perip.getItemDetail(slot)
if item then
table.insert(slotsToSend, slot)
end
end
if #slotsToSend > 0 then
inv.sendItemAwayMultiple(slotsToSend, perip, import_from_inv)
end
end
while true do
for _, import_from_inv in ipairs(config.import) do
---@type ccTweaked.peripheral.Inventory
local perip = peripheral.wrap(import_from_inv)
if perip and perip.size then
local slotsToSend = {}
for slot = 1, perip.size() do
local item = perip.getItemDetail(slot)
if item then
table.insert(slotsToSend, slot)
end
end
sleep(0.1)
if #slotsToSend > 0 then
inv.sendItemAwayMultiple(slotsToSend, perip, import_from_inv)
end
end
end
sleep(0.1)
end
end
inv.sync()