From 95fdbb73b3867cdeb35b4878afb9ef5269807729 Mon Sep 17 00:00:00 2001 From: fucksophie Date: Fri, 6 Feb 2026 09:50:24 +0200 Subject: [PATCH] fix loads of type errors --- src/lib/abstractInventoryLib.lua | 14 +++++------ src/modules/inventory/base.lua | 39 ++++++++++++++++++++++++------- src/modules/inventory/inv_ail.lua | 2 -- src/modules/inventory/inv_ra.lua | 9 +++---- src/modules/ra.lua | 9 +++---- src/tiny_ra_library.lua | 2 +- 6 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/lib/abstractInventoryLib.lua b/src/lib/abstractInventoryLib.lua index 6a1b36c..27faaa1 100644 --- a/src/lib/abstractInventoryLib.lua +++ b/src/lib/abstractInventoryLib.lua @@ -65,7 +65,7 @@ local function batchExecute(func, skipPartial, limit) end ---Safely call an inventory "peripheral" ----@param name string|AbstractInventory|table +---@param name string|ccTweaked.peripheral.Inventory|AbstractInventory|table ---@param func string ---@param ... unknown ---@return unknown @@ -924,7 +924,7 @@ function abstractInventory(inventories, assumeLimits, logSettings) return logExit(logOptimal, calln, "pushItemsOptimal", ret) end - ---@param targetInventory string|AbstractInventory + ---@param targetInventory string|ccTweaked.peripheral.Inventory|AbstractInventory ---@param name string|number|ItemHandle ---@param amount nil|number ---@param toSlot nil|number @@ -970,7 +970,7 @@ function abstractInventory(inventories, assumeLimits, logSettings) end ---Push items to an inventory - ---@param targetInventory string|AbstractInventory + ---@param targetInventory string|ccTweaked.peripheral.Inventory|AbstractInventory ---@param name string|number|ItemHandle ---@param amount nil|number ---@param toSlot nil|number @@ -1054,7 +1054,7 @@ function abstractInventory(inventories, assumeLimits, logSettings) end ---Pull items from an inventory - ---@param fromInventory string|AbstractInventory + ---@param fromInventory string|ccTweaked.peripheral.Inventory|AbstractInventory ---@param fromSlot string|number ---@param amount nil|number ---@param toSlot nil|number @@ -1090,7 +1090,7 @@ function abstractInventory(inventories, assumeLimits, logSettings) end ---Pull items from an inventory - ---@param fromInventory string|AbstractInventory + ---@param fromInventory string|ccTweaked.peripheral.Inventory|AbstractInventory ---@param fromSlot string|number ---@param amount nil|number ---@param toSlot nil|number @@ -1111,7 +1111,7 @@ function abstractInventory(inventories, assumeLimits, logSettings) end ---Push items to an inventory - ---@param targetInventory string|AbstractInventory + ---@param targetInventory string|ccTweaked.peripheral.Inventory|AbstractInventory ---@param name string|number|ItemHandle ---@param amount nil|number ---@param toSlot nil|number @@ -1414,7 +1414,7 @@ function abstractInventory(inventories, assumeLimits, logSettings) end ---pull all items from an inventory - ---@param inventory string|AbstractInventory + ---@param inventory string|ccTweaked.peripheral.Inventory|AbstractInventory ---@return integer moved total items moved function api.pullAll(inventory) if type(inventory) == "string" or not inventory.abstractInventory then diff --git a/src/modules/inventory/base.lua b/src/modules/inventory/base.lua index d75d538..b6d7cb8 100644 --- a/src/modules/inventory/base.lua +++ b/src/modules/inventory/base.lua @@ -3,7 +3,7 @@ ---@field count integer ---@field nbt string|nil ----@alias TurtleInventory table +---@alias TurtleInventory table ---@class InventoryBase ---@field previousInventory TurtleInventory @@ -16,7 +16,7 @@ Base.__index = Base ---@param self T ---@return T function Base.new(self) - ---@type T + ---@class T local o = setmetatable({}, self) ---@type TurtleInventory @@ -97,28 +97,49 @@ end ---@param maxAmount integer|nil ---@param id string|nil ---@return integer -function Base:sendItemToSelf(itemName, perip, maxAmount, id) end +function Base:sendItemToSelf(itemName, perip, maxAmount, id) + print("sendItemToSelf not implemented by backend") + os.exit() +end ---@param slots TurtleSlot[] ---@param perip ccTweaked.peripheral.Inventory|nil ---@param id string|nil ---@param maxAmount integer|nil ---@return integer -function Base:sendItemAwayMultiple(slots, perip, id, maxAmount) end +function Base:sendItemAwayMultiple(slots, perip, id, maxAmount) + print("sendItemAwayMultiple not implemented by backend") + os.exit() +end ---@return string[] -function Base:listNames() end +function Base:listNames() + print("listNames not implemented by backend") + os.exit() +end ---@return table -function Base:listItemAmounts() end +function Base:listItemAmounts() + print("listItemAmounts not implemented by backend") + os.exit() +end ---@param name string ---@return table -function Base:getItem(name) end +function Base:getItem(name) + print("getItem not implemented by backend") + os.exit() +end ---@return fun() -function Base:run() end +function Base:run() + print("run not implemented by backend") + os.exit() +end -function Base:sync() end +function Base:sync() + print("sync not implemented by backend") + os.exit() +end return Base diff --git a/src/modules/inventory/inv_ail.lua b/src/modules/inventory/inv_ail.lua index acdaaec..8a91e74 100644 --- a/src/modules/inventory/inv_ail.lua +++ b/src/modules/inventory/inv_ail.lua @@ -15,8 +15,6 @@ local modem = peripheral.find("modem") local turtleId = modem and modem.getNameLocal() or "self" ----@alias TurtleSlot integer - ---@return InventoryLayerAIL function AIL:new() ---@type InventoryLayerAIL diff --git a/src/modules/inventory/inv_ra.lua b/src/modules/inventory/inv_ra.lua index d6406a9..5bff169 100644 --- a/src/modules/inventory/inv_ra.lua +++ b/src/modules/inventory/inv_ra.lua @@ -15,19 +15,20 @@ local ra = require("tiny_ra_library") ---@field list fun():table ---@field pushItems fun(to:string|table, fromSlot:integer, amount?:integer, toSlot?:integer):integer ---@field pullItems fun(from:string|table, fromSlot:integer, amount?:integer, toSlot?:integer):integer - +---@field setFrequency fun(first: string, second: string, third: string) ---@return InventoryLayerRA function RA:new() - ---@type InventoryLayerRA + ---@class InventoryLayerRA local o = Base.new(self) ---@type ccTweaked.peripheral.WiredModem|nil - o.modem = peripheral.wrap(config.remote.modem) + o.modem = peripheral.wrap(config.remote.modem) --[[@as ccTweaked.peripheral.WiredModem|nil]] ---@type EnderStoragePeripheral|nil - o.ender = peripheral.wrap(config.remote.ender_storage) + o.ender = peripheral.wrap(config.remote.ender_storage) --[[@as EnderStoragePeripheral?]] ---@type string + ---@diagnostic disable-next-line: undefined-field o.turtleId = peripheral.find("modem").getNameLocal() return o diff --git a/src/modules/ra.lua b/src/modules/ra.lua index 771d391..186d3da 100644 --- a/src/modules/ra.lua +++ b/src/modules/ra.lua @@ -6,13 +6,14 @@ local encryption = require("lib.encryption") ---@class RemoteAccess ---@field type string ---@field data RemoteAccessData +---@field id string ---@class RemoteAccessData ---@field itemName string|nil ---@field amount number|nil ---@field slots number[]|nil - - +---@field manipulator string|nil +---@field index string|nil local function sendResponse(modem, port, hashedPassword, id, ok, data, err) modem.transmit( @@ -45,8 +46,8 @@ local function run() end end - ---@type ccTweaked.peripheral.Inventory - local ender_storage = peripheral.wrap(config.remote.ender_storage) + ---@type EnderStoragePeripheral + local ender_storage = peripheral.wrap(config.remote.ender_storage) --[[@as EnderStoragePeripheral]] while true do local _, _, channel, _, message, _ = os.pullEvent("modem_message") diff --git a/src/tiny_ra_library.lua b/src/tiny_ra_library.lua index 1d41fd1..f8e6db6 100644 --- a/src/tiny_ra_library.lua +++ b/src/tiny_ra_library.lua @@ -187,7 +187,7 @@ end ---@param itemName string ---@param manipulator string ----@param count number|nil +---@param amount number|nil ---@param wait boolean|nil local function depositFromManipulator(manipulator, itemName, amount, wait) if not port or not modem or not password then