fix loads of type errors

This commit is contained in:
Soph :3 2026-02-06 09:50:24 +02:00
parent f8bdfa2bb5
commit 95fdbb73b3
6 changed files with 48 additions and 27 deletions

View file

@ -65,7 +65,7 @@ local function batchExecute(func, skipPartial, limit)
end end
---Safely call an inventory "peripheral" ---Safely call an inventory "peripheral"
---@param name string|AbstractInventory|table ---@param name string|ccTweaked.peripheral.Inventory|AbstractInventory|table
---@param func string ---@param func string
---@param ... unknown ---@param ... unknown
---@return unknown ---@return unknown
@ -924,7 +924,7 @@ function abstractInventory(inventories, assumeLimits, logSettings)
return logExit(logOptimal, calln, "pushItemsOptimal", ret) return logExit(logOptimal, calln, "pushItemsOptimal", ret)
end end
---@param targetInventory string|AbstractInventory ---@param targetInventory string|ccTweaked.peripheral.Inventory|AbstractInventory
---@param name string|number|ItemHandle ---@param name string|number|ItemHandle
---@param amount nil|number ---@param amount nil|number
---@param toSlot nil|number ---@param toSlot nil|number
@ -970,7 +970,7 @@ function abstractInventory(inventories, assumeLimits, logSettings)
end end
---Push items to an inventory ---Push items to an inventory
---@param targetInventory string|AbstractInventory ---@param targetInventory string|ccTweaked.peripheral.Inventory|AbstractInventory
---@param name string|number|ItemHandle ---@param name string|number|ItemHandle
---@param amount nil|number ---@param amount nil|number
---@param toSlot nil|number ---@param toSlot nil|number
@ -1054,7 +1054,7 @@ function abstractInventory(inventories, assumeLimits, logSettings)
end end
---Pull items from an inventory ---Pull items from an inventory
---@param fromInventory string|AbstractInventory ---@param fromInventory string|ccTweaked.peripheral.Inventory|AbstractInventory
---@param fromSlot string|number ---@param fromSlot string|number
---@param amount nil|number ---@param amount nil|number
---@param toSlot nil|number ---@param toSlot nil|number
@ -1090,7 +1090,7 @@ function abstractInventory(inventories, assumeLimits, logSettings)
end end
---Pull items from an inventory ---Pull items from an inventory
---@param fromInventory string|AbstractInventory ---@param fromInventory string|ccTweaked.peripheral.Inventory|AbstractInventory
---@param fromSlot string|number ---@param fromSlot string|number
---@param amount nil|number ---@param amount nil|number
---@param toSlot nil|number ---@param toSlot nil|number
@ -1111,7 +1111,7 @@ function abstractInventory(inventories, assumeLimits, logSettings)
end end
---Push items to an inventory ---Push items to an inventory
---@param targetInventory string|AbstractInventory ---@param targetInventory string|ccTweaked.peripheral.Inventory|AbstractInventory
---@param name string|number|ItemHandle ---@param name string|number|ItemHandle
---@param amount nil|number ---@param amount nil|number
---@param toSlot nil|number ---@param toSlot nil|number
@ -1414,7 +1414,7 @@ function abstractInventory(inventories, assumeLimits, logSettings)
end end
---pull all items from an inventory ---pull all items from an inventory
---@param inventory string|AbstractInventory ---@param inventory string|ccTweaked.peripheral.Inventory|AbstractInventory
---@return integer moved total items moved ---@return integer moved total items moved
function api.pullAll(inventory) function api.pullAll(inventory)
if type(inventory) == "string" or not inventory.abstractInventory then if type(inventory) == "string" or not inventory.abstractInventory then

View file

@ -3,7 +3,7 @@
---@field count integer ---@field count integer
---@field nbt string|nil ---@field nbt string|nil
---@alias TurtleInventory table<TurtleSlot, TurtleItemDetail|nil> ---@alias TurtleInventory table<TurtleSlot, ccTweaked.turtle.turtleDetails|ccTweaked.turtle.turtleDetailsDetailed>
---@class InventoryBase ---@class InventoryBase
---@field previousInventory TurtleInventory ---@field previousInventory TurtleInventory
@ -16,7 +16,7 @@ Base.__index = Base
---@param self T ---@param self T
---@return T ---@return T
function Base.new(self) function Base.new(self)
---@type T ---@class T
local o = setmetatable({}, self) local o = setmetatable({}, self)
---@type TurtleInventory ---@type TurtleInventory
@ -97,28 +97,49 @@ end
---@param maxAmount integer|nil ---@param maxAmount integer|nil
---@param id string|nil ---@param id string|nil
---@return integer ---@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 slots TurtleSlot[]
---@param perip ccTweaked.peripheral.Inventory|nil ---@param perip ccTweaked.peripheral.Inventory|nil
---@param id string|nil ---@param id string|nil
---@param maxAmount integer|nil ---@param maxAmount integer|nil
---@return integer ---@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[] ---@return string[]
function Base:listNames() end function Base:listNames()
print("listNames not implemented by backend")
os.exit()
end
---@return table<string, integer> ---@return table<string, integer>
function Base:listItemAmounts() end function Base:listItemAmounts()
print("listItemAmounts not implemented by backend")
os.exit()
end
---@param name string ---@param name string
---@return table ---@return table
function Base:getItem(name) end function Base:getItem(name)
print("getItem not implemented by backend")
os.exit()
end
---@return fun() ---@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 return Base

View file

@ -15,8 +15,6 @@ local modem = peripheral.find("modem")
local turtleId = modem and modem.getNameLocal() or "self" local turtleId = modem and modem.getNameLocal() or "self"
---@alias TurtleSlot integer
---@return InventoryLayerAIL ---@return InventoryLayerAIL
function AIL:new() function AIL:new()
---@type InventoryLayerAIL ---@type InventoryLayerAIL

View file

@ -15,19 +15,20 @@ local ra = require("tiny_ra_library")
---@field list fun():table<TurtleSlot, table> ---@field list fun():table<TurtleSlot, table>
---@field pushItems fun(to:string|table, fromSlot:integer, amount?:integer, toSlot?:integer):integer ---@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 pullItems fun(from:string|table, fromSlot:integer, amount?:integer, toSlot?:integer):integer
---@field setFrequency fun(first: string, second: string, third: string)
---@return InventoryLayerRA ---@return InventoryLayerRA
function RA:new() function RA:new()
---@type InventoryLayerRA ---@class InventoryLayerRA
local o = Base.new(self) local o = Base.new(self)
---@type ccTweaked.peripheral.WiredModem|nil ---@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 ---@type EnderStoragePeripheral|nil
o.ender = peripheral.wrap(config.remote.ender_storage) o.ender = peripheral.wrap(config.remote.ender_storage) --[[@as EnderStoragePeripheral?]]
---@type string ---@type string
---@diagnostic disable-next-line: undefined-field
o.turtleId = peripheral.find("modem").getNameLocal() o.turtleId = peripheral.find("modem").getNameLocal()
return o return o

View file

@ -6,13 +6,14 @@ local encryption = require("lib.encryption")
---@class RemoteAccess ---@class RemoteAccess
---@field type string ---@field type string
---@field data RemoteAccessData ---@field data RemoteAccessData
---@field id string
---@class RemoteAccessData ---@class RemoteAccessData
---@field itemName string|nil ---@field itemName string|nil
---@field amount number|nil ---@field amount number|nil
---@field slots number[]|nil ---@field slots number[]|nil
---@field manipulator string|nil
---@field index string|nil
local function sendResponse(modem, port, hashedPassword, id, ok, data, err) local function sendResponse(modem, port, hashedPassword, id, ok, data, err)
modem.transmit( modem.transmit(
@ -45,8 +46,8 @@ local function run()
end end
end end
---@type ccTweaked.peripheral.Inventory ---@type EnderStoragePeripheral
local ender_storage = peripheral.wrap(config.remote.ender_storage) local ender_storage = peripheral.wrap(config.remote.ender_storage) --[[@as EnderStoragePeripheral]]
while true do while true do
local _, _, channel, _, message, _ = os.pullEvent("modem_message") local _, _, channel, _, message, _ = os.pullEvent("modem_message")

View file

@ -187,7 +187,7 @@ end
---@param itemName string ---@param itemName string
---@param manipulator string ---@param manipulator string
---@param count number|nil ---@param amount number|nil
---@param wait boolean|nil ---@param wait boolean|nil
local function depositFromManipulator(manipulator, itemName, amount, wait) local function depositFromManipulator(manipulator, itemName, amount, wait)
if not port or not modem or not password then if not port or not modem or not password then