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
---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

View file

@ -3,7 +3,7 @@
---@field count integer
---@field nbt string|nil
---@alias TurtleInventory table<TurtleSlot, TurtleItemDetail|nil>
---@alias TurtleInventory table<TurtleSlot, ccTweaked.turtle.turtleDetails|ccTweaked.turtle.turtleDetailsDetailed>
---@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<string, integer>
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

View file

@ -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

View file

@ -15,19 +15,20 @@ local ra = require("tiny_ra_library")
---@field list fun():table<TurtleSlot, 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

View file

@ -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")

View file

@ -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