Data Hubs
Overview
The Data Hubs section in the cee API provides functions for interacting with and managing remote data hubs, claiming and releasing hub nodes, driving voltages, sending messages, and querying peripherals and redstone states across hub connections in a ComputerCraft/CC:Tweaked environment.
This section is essential for developers working on distributed network systems, multi-computer setups, and remote hardware control through network hubs. The functions provided allow for fine-grained control over how programs interact with hub nodes and connected devices.
Calling Conventions / Prefixes
All methods within the Data Hubs section are accessed through the global cee namespace, meaning they can be invoked directly as:
local hubs = cee.listHubs()
cee.claimHubNode(1, 3)
These functions do not require any object instantiation and operate on the current network hub states. They should not be confused with methods that are part of other sections like speaker or monitor, which may have their own peripheral handles.
API Reference Table
| Signature | Arguments & Types | Description |
|---|---|---|
cee.listHubs() |
None | Returns hubs on this computer's fabric. |
cee.hubInfo(hubId) |
hubId (string/number) |
Returns pins, claims, and power for one hub. |
cee.claimHubNode(hubId, pin) |
hubId (number), pin (number) |
Take a hub pin, exclusively. |
cee.releaseHubNode(hubId, pin) |
hubId (number), pin (number) |
Give a hub pin back. |
cee.hubSetVoltage(hubId, pin, v) |
hubId (number), pin (number), v (number) |
Drive a claimed hub pin. |
cee.hubClearNode(hubId, pin) |
hubId (number), pin (number) |
Stop driving a claimed pin. |
cee.hubGetVoltage(hubId, pin) |
hubId (number), pin (number) |
Volts on a hub pin (no claim). |
cee.hubSend(hubId, pin, x) |
hubId (number), pin (number), x (any) |
Send out of a claimed hub pin. |
cee.getHubPeripheral(hubId, pin) |
hubId (number), pin (number) |
Wrap the peripheral on a claimed pin. |
cee.getHubPeripheralType(hubId, pin) |
hubId (number), pin (number) |
Its type name, or nil. |
cee.hasHubPeripheral(hubId, pin) |
hubId (number), pin (number) |
Anything on the far end?. |
cee.hubGetAnalog(hubId, pin) |
hubId (number), pin (number) |
Redstone 0-15 into that pin's port. |
cee.hubIsPortPowered(hubId, pin) |
hubId (number), pin (number) |
That pin's port sees redstone. |
cee.hubSetAnalog(hubId, pin, lvl) |
hubId (number), pin (number), lvl (number) |
Drive that pin's port at 0-15. |
cee.hubSetOutput(hubId, pin, on) |
hubId (number), pin (number), on (boolean) |
Drive that pin's port on or off. |
cee.hubGetAnalogOutput(hubId, pin) |
hubId (number), pin (number) |
What that port is driving, 0-15. |
cee.hubGetOutput(hubId, pin) |
hubId (number), pin (number) |
What it is driving, as a boolean. |
cee.hubSendAll(hubId, msg) |
hubId (number), msg (any) |
Message every computer using that hub. |
cee.getHubPeripherals(hubId, pin) |
hubId (number), pin (number) |
All of them on that pin. |
cee.getHubMonitor(hubId, pin[, n]) |
hubId (number), pin (number), n (number, optional) |
Screen on a claimed pin. |
cee.getHubMonitors(hubId, pin) |
hubId (number), pin (number) |
Every screen on that pin. |
cee.getHubSpeaker(hubId, pin[, n]) |
hubId (number), pin (number), n (number, optional) |
Speakers on a claimed pin. |
cee.getHubSpeakers(hubId, pin) |
hubId (number), pin (number) |
Each speaker on its own. |
Lua Code Examples
Example 1: List Hubs and Inspect Hub Info
local hubs = cee.listHubs()
for _, hubId in ipairs(hubs) do
local info = cee.hubInfo(hubId)
print("Hub ID:", hubId)
end
Example 2: Claiming and Releasing a Hub Node
local hubId = 1
local pin = 3
-- Claim the node exclusively
cee.claimHubNode(hubId, pin)
print("Hub node claimed.")
-- Send a message out of the claimed pin
cee.hubSend(hubId, pin, "Hello Remote Pin")
-- Release the node when done
cee.releaseHubNode(hubId, pin)
print("Hub node released.")
Example 3: Wrapping a Hub Peripheral
local hubId = 1
local pin = 2
if cee.hasHubPeripheral(hubId, pin) then
local pType = cee.getHubPeripheralType(hubId, pin)
print("Found peripheral type:", pType)
local peripheralHandle = cee.getHubPeripheral(hubId, pin)
end
Example 4: Controlling Hub Redstone Ports
local hubId = 1
local pin = 4
-- Set analog output level on the hub port
cee.hubSetAnalog(hubId, pin, 15)
-- Read incoming analog redstone level
local analogValue = cee.hubGetAnalog(hubId, pin)
print("Hub port analog value:", analogValue)
Example 5: Messaging All Computers on a Hub
local hubId = 1
local sentCount = cee.hubSendAll(hubId, "Broadcast message to all hub users")
print("Message sent to", sentCount, "computers.")
Notes
cee.claimHubNode()allows a computer to take exclusive control of a hub pin.- Reads on dead hubs or invalid nodes return default fallback values (
0,false, ornil) rather than throwing fatal errors. cee.hubSendAll()reaches all computers holding a claim on that specific hub, acting as a private channel between them.