forked from zeng-github01/OC-Doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent.lua
More file actions
107 lines (94 loc) · 4.36 KB
/
component.lua
File metadata and controls
107 lines (94 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---@meta
---@class Component
---@field printer3d Printer3DProxy
---@field chunkloader ChunkloaderProxy
---@field computer ComputerProxy
---@field crafting CraftingProxy
---@field database DatabaseProxy
---@field data DataProxy
---@field debug DebugProxy
---@field drive DriveProxy
---@field eeprom EEPROMProxy
---@field experience ExperienceProxy
---@field filesystem FilesystemProxy
---@field generator GeneratorProxy
---@field geolyzer GeolyzerProxy
---@field gpu GPUProxy
---@field hologram HologramProxy
---@field internet InternetProxy
---@field inventory_controller InventoryControllerProxy
---@field leash LeashProxy
---@field microcontroller MicrocontrollerProxy
---@field modem ModemProxy
---@field motion_sensor MotionSensorProxy
---@field navigation NavigationProxy
---@field net_splitter NetSplitterProxy
---@field piston PistonProxy
---@field redstone RedstoneProxy
---@field screen ScreenProxy
---@field tank_controller TankControllerProxy
---@field signn SignProxy
---@field tractor_beam TractorBeamProxy
---@field robot RobotProxy
---@field transposer TransposerProxy
---@field tunnel TunnelProxy
local component = {}
--- Returns the documentation string for the specified method of the component at the given address.
---@param address string Component address
---@param method string Method name
---@return string "Documentation string"
function component.doc(address, method) end
--- Calls the specified method on the component at the given address, passing any additional arguments.
---@param address string Component address
---@param method string Method name
---@param ... any Arguments to pass to the method
---@return any Results returned by the method
function component.invoke(address, method, ...) end
--- Returns an iterator over all components attached to the computer.
--- If filter is set, only components whose type contains the filter string are returned.
--- If exact is true, only exact matches are returned.
---@param filter? string Filter string (optional)
---@param exact? boolean Exact match (optional)
---@return fun(): (string, string) "Iterator yielding address and type"
function component.list(filter, exact) end
--- Returns a table of all method names provided by the component at the given address.
--- The table keys are method names, values indicate if the method is called directly.
---@param address string Component address
---@return table<string, boolean> Table of method names to direct-call flags
function component.methods(address) end
--- Gets a proxy object for the component at the given address, providing all its methods as fields.
---@param address string Component address
---@return table "Proxy object for the component"
function component.proxy(address) end
--- Gets the component type of the component at the given address.
---@param address string Component address
---@return string "Component type"
function component.type(address) end
--- Returns the slot number where the component is installed, or -1 if not applicable.
---@param address string Component address
---@return integer Slot number or -1
function component.slot(address) end
--- (Undocumented) Returns fields for the component at the given address.
---@param address string Component address
---@return string Fields (undocumented)
function component.fields(address) end -- undocumented
--- Tries to resolve an abbreviated address to a full address, optionally filtering by component type.
---@param address string Abbreviated or full address
---@param componentType? string Component type to filter (optional)
---@return string|nil Full address or nil
---@return string? "Error message if not found"
function component.get(address, componentType) end
--- Checks if there is a primary component of the specified type.
---@param componentType string Component type
---@return boolean `True` if available
function component.isAvailable(componentType) end
--- Gets the proxy for the primary component of the specified type.
--- Throws an error if there is no primary component of that type.
---@param componentType string Component type
---@return table "Proxy object for the primary component"
function component.getPrimary(componentType) end
--- Sets a new primary component for the specified type. Triggers signals if changed.
---@param componentType string Component type
---@param address string Component address (can be abbreviated)
function component.setPrimary(componentType, address) end
return component