Create: Computing AgesBrass Docs
Devices

Every device

What every block a computer drives has in common: an object of functions called with a dot, its type, several types on one block, errors when the block goes away.

A device is a block a computer drives: a Traffic Light, a chest, a Create machine, a monitor, a sensor of Create Aeronautics. peripheral.wrap and peripheral.find return an object for it: a table whose fields are the functions of that block, its methods. This page explains what all these objects have in common; the pages of each type (listed below) describe their methods.

Brass
local light = peripheral.wrap("left")   -- the Traffic Light on the left face
light.set("green")
print(light.get())                      -- green
print(light.type())                     -- traffic_light

Every computer drives devices, the Tube Computer included: against one of its six faces, or, from the Minicomputer on, anywhere on its Data Cable network. Names, searching and costs are explained in peripheral.

Methods
device.type()The type of the device, the same name peripheral.type gives for the block.

Calling methods

With a dot, not a colon. The methods of a device are plain functions stored in a table, not methods in the Lua sense: call them with a dot, light.set("green"). With a colon, Brass passes the object itself as the first argument, and the method receives a table where it expected text:

Brass
local light = peripheral.wrap("left")
light.set("red")     -- right
light:set("red")     -- wrong: bad argument #1 to 'set' (string expected, got table)

An ordinary table. A device object can be stored in a variable or a table, passed to a function, and looked through with pairs. A short function lists the methods of any device, sorted:

Brass
local function methods(device)
  local names = {}
  for name, _ in pairs(device) do
    table.insert(names, name)
  end
  table.sort(names)
  return table.concat(names, " ")
end

for _, name in ipairs(peripheral.list()) do
  print(name .. ": " .. methods(peripheral.wrap(name)))
end

For a Traffic Light, it prints get release set type. The built-in devices program goes further: it shows everything the computer can reach, with live readings.

An object only lives as long as the program: after a reboot, wrap the block again.

Types

Each device has a type, a short name in English that says what it can do. These are all the types, with the page of their methods:

typeblocksmethods
traffic_lightTraffic LightTraffic Light
inductive_loopInductive Loop DetectorInductive Loop Detector
monitorCRT Monitor, LCD MonitorMonitors
wifi_routerWi-Fi RouterRadio Modem and Wi-Fi Router
radio_modemRadio ModemRadio Modem and Wi-Fi Router
relayRelayRelay
card_readerJacquard Card ReaderJacquard Card Reader
coil_winderCoil WinderPrecision machines
vacuum_chamberVacuum ChamberPrecision machines
lithography_machinePhotolithography MachinePrecision machines
ion_implanterIon ImplanterPrecision machines
pick_and_placePick-and-Place MachinePrecision machines
crystal_pullerCrystal PullerPrecision machines
redstone_linkCreate's Redstone LinkRedstone Link
creative_motorCreate's Creative MotorCreate machines
speed_controllerCreate's Rotation Speed ControllerCreate machines
speedometerCreate's SpeedometerCreate machines
stressometerCreate's StressometerCreate machines
sequenced_gearshiftCreate's Sequenced GearshiftCreate machines
stickerCreate's StickerCreate machines
display_linkCreate's Display LinkDisplay Link and nixie tubes
nixie_tubeCreate's Nixie TubeDisplay Link and nixie tubes
stationCreate's Train StationTrains
signalCreate's Train SignalTrains
track_observerCreate's Train ObserverTrains
repackagerCreate's Re-PackagerCreate logistics
packagerCreate's PackagerCreate logistics
frogportCreate's FrogportCreate logistics
postboxCreate's PostboxesCreate logistics
redstone_requesterCreate's Redstone RequesterCreate logistics
stock_tickerCreate's Stock TickerCreate logistics
table_clothCreate's Table ClothsCreate logistics
altitude_sensorAltitude Sensor of Create AeronauticsCreate Aeronautics sensors
gimbal_sensorGimbal Sensor of Create AeronauticsCreate Aeronautics sensors
velocity_sensorVelocity Sensor of Create AeronauticsCreate Aeronautics sensors
optical_sensorOptical Sensor of Create AeronauticsCreate Aeronautics sensors
navigation_tableNavigation Table of Create AeronauticsCreate Aeronautics sensors
swivel_bearingSwivel Bearing of Create AeronauticsCreate Aeronautics sensors
torsion_springTorsion Spring of Create AeronauticsCreate Aeronautics sensors
directional_linkDirectional Linked Receiver of Create AeronauticsCreate Aeronautics sensors
modulating_linkModulating Linked Receiver of Create AeronauticsCreate Aeronautics sensors
docking_connectorDocking Connector of Create AeronauticsCreate Aeronautics sensors
linked_typewriterLinked Typewriter of Create AeronauticsCreate Aeronautics sensors
name_plateNameplates of Create AeronauticsCreate Aeronautics sensors
hot_air_burnerHot Air Burner of Create AeronauticsHot Air Burner
steam_ventSteam Vent of Create AeronauticsHot Air Burner
propeller_bearingPropeller Bearing, Gyroscopic Propeller Bearing of Create AeronauticsPropellers
cannon_mountCannon Mount of Create Big CannonsCannon mounts
fixed_cannon_mountFixed Cannon Mount of Create Big CannonsCannon mounts
electric_motorElectric Motor of Create Crafts & AdditionsCreate Crafts & Additions
servo_motorServo Motor of Create Crafts & AdditionsCreate Crafts & Additions
modular_accumulatorAccumulator of Create Crafts & AdditionsCreate Crafts & Additions
portable_energy_interfacePortable Energy Interface of Create Crafts & AdditionsCreate Crafts & Additions
redstone_relayRedstone Relay of Create Crafts & AdditionsCreate Crafts & Additions
digital_adapterDigital Adapter of Create Crafts & AdditionsCreate Crafts & Additions
electric_pumpElectric Pump of Create Crafts & AdditionsCreate Crafts & Additions
liquid_blaze_burnerBlaze Burner with Straw of Create Crafts & AdditionsCreate Crafts & Additions
kinetic_batteryKinetic Battery of Create: ConnectedCreate: Connected blocks
overstress_clutchOverstress Clutch of Create: ConnectedCreate: Connected blocks
centrifugal_clutchCentrifugal Clutch of Create: ConnectedCreate: Connected blocks
freewheel_clutchFreewheel Clutch of Create: ConnectedCreate: Connected blocks
sequenced_pulse_generatorSequenced Pulse Generator of Create: ConnectedCreate: Connected blocks
dashboardDashboard of Create: ConnectedCreate: Connected blocks
linked_leverLinked Lever of Create: ConnectedCreate: Connected blocks
linked_buttonLinked Buttons of Create: ConnectedCreate: Connected blocks
linked_analog_leverLinked Analog Lever of Create: ConnectedCreate: Connected blocks
linked_throttle_leverLinked Throttle Lever of Create: Connected (with Create Aeronautics)Create: Connected blocks
kinetic_bridgeKinetic Bridge of Create: ConnectedCreate: Connected blocks
sliding_breechSliding Breeches of Create Big CannonsCannon blocks
screw_breechScrew Breeches of Create Big CannonsCannon blocks
cannon_loaderCannon Loader of Create Big CannonsCannon blocks
cannon_drillCannon Drill of Create Big CannonsCannon blocks
cannon_castCannon Cast of Create Big CannonsCannon blocks
shellthe shells of Create Big Cannons (HE, shrapnel, AP...)Cannon blocks
big_cartridgeBig Cartridge of Create Big CannonsCannon blocks
autocannon_ammo_containerAutocannon Ammo Container of Create Big CannonsCannon blocks
blaze_enchanterBlaze Enchanter of Create: Enchantment IndustryEnchantment Industry
blaze_forgerBlaze Forger of Create: Enchantment IndustryEnchantment Industry
printerPrinter of Create: Enchantment IndustryEnchantment Industry
throttle_leverThrottle Lever of Create AeronauticsCreate Aeronautics blocks
laser_pointerLaser Pointer of Create AeronauticsCreate Aeronautics blocks
laser_sensorLaser Sensor of Create AeronauticsCreate Aeronautics blocks
redstone_accumulatorRedstone Accumulator of Create AeronauticsCreate Aeronautics blocks
redstone_inductorRedstone Inductor of Create AeronauticsCreate Aeronautics blocks
physics_assemblerPhysics Assembler of Create AeronauticsCreate Aeronautics blocks
rope_winchRope Winch of Create AeronauticsCreate Aeronautics blocks
springSprings of Create AeronauticsCreate Aeronautics blocks
steering_wheelSteering Wheel of Create AeronauticsCreate Aeronautics blocks
analog_transmissionAnalog Transmission of Create AeronauticsCreate Aeronautics blocks
portable_enginePortable Engines of Create AeronauticsCreate Aeronautics blocks
andesite_propellerAndesite Propeller of Create AeronauticsPropellers
wooden_propellerWooden Propeller of Create AeronauticsPropellers
smart_propellerSmart Propeller of Create AeronauticsPropellers
mounted_potato_cannonMounted Potato Cannon of Create AeronauticsCreate Aeronautics blocks
wheel_mountWheel Mount of Create Aeronautics (Offroad)Create Aeronautics blocks
borehead_bearingBorehead Bearing of Create Aeronautics (Offroad)Create Aeronautics blocks
diesel_engineDiesel Engine of Create: Diesel GeneratorsDiesel Generators
modular_diesel_engineModular Diesel Engine of Create: Diesel GeneratorsDiesel Generators
huge_diesel_engineHuge Diesel Engine of Create: Diesel GeneratorsDiesel Generators
burnerBurner of Create: Diesel GeneratorsDiesel Generators
basin_lidBasin Lid of Create: Diesel GeneratorsDiesel Generators
bulk_fermenterBulk Fermenter of Create: Diesel GeneratorsDiesel Generators
distillation_tankDistillation Tank of Create: Diesel GeneratorsDiesel Generators
pumpjack_holePumpjack Hole of Create: Diesel GeneratorsDiesel Generators
chemical_turretChemical Turret of Create: Diesel GeneratorsDiesel Generators
motorBasic, Advanced and Reinforced Motors of Create: New AgeCreate: New Age
motor_extensionMotor Extensions of Create: New AgeCreate: New Age
carbon_brushesCarbon Brushes of Create: New AgeCreate: New Age
energiserEnergisers of Create: New AgeCreate: New Age
electrical_connectorElectrical Connector of Create: New AgeCreate: New Age
street_lightStreet Light of Create: New AgeCreate: New Age
heaterHeater of Create: New AgeCreate: New Age
heat_pipeHeat Pipe of Create: New AgeCreate: New Age
heat_pumpHeat Pump of Create: New AgeCreate: New Age
solar_heating_plateSolar Heating Plates of Create: New AgeCreate: New Age
stirling_engineStirling Engine of Create: New AgeCreate: New Age
reactor_rodReactor Rod of Create: New AgeCreate: New Age
reactor_heat_ventReactor Heat Vent of Create: New AgeCreate: New Age
reactor_fuel_acceptorReactor Fuel Acceptor of Create: New AgeCreate: New Age
note_blockMinecraft's Note BlockNote Block
kineticevery Create block that turns: shafts, Millstone, Mechanical Press, Rotation Speed Controller...Create kinetic blocks
inventoryevery block that holds items: chest, barrel, Item Vault, Depot, Basin...Inventories
tankevery block that holds fluids: Fluid Tank, Basin...Tanks
energyevery block that holds Forge Energy (FE): batteries, electric motors...Energy blocks

The types of a mod (Create Aeronautics, Create Big Cannons, Create Crafts & Additions...) only exist when that mod is installed.

One block, several types. A block can be several things at once. A Create Millstone turns and holds items: it is both kinetic and inventory. A Basin holds items and fluids: inventory and tank. Its object then has the methods of every type together, so one object does it all:

Brass
local millstone = peripheral.wrap("left")
print(millstone.speed() .. " RPM")             -- a kinetic method
print(millstone.count() .. " items inside")    -- an inventory method

Its type, though, is a single name: the first of its types, in the order of the table above (the types of one kind of block first, kinetic, inventory, tank and energy last). The Millstone is kinetic. To find a block by any of its types, use peripheral.list(type) or peripheral.find(type), which look at all of them: peripheral.find("inventory") finds the Millstone too.

#

device.type()

→ string

The type of the device, the same name peripheral.type gives for the block.

Returns
string
the type of the device: its first type
Brass
local device = peripheral.wrap("left")
if device and device.type() == "inventory" then
  print(device.count() .. " items")
end

It is the type the block had when it was wrapped: the object keeps it, even if another block takes the place later.

A wrapped device always has a real type, since peripheral.wrap returns nil when there is nothing to talk to. Only peripheral.call("left", "type") on an empty face answers "none".

See also peripheral.type() peripheral.find()

When the block goes away

A device object does not hold the block itself: every method looks for the block again when it is called. So an object never goes stale. Break the chest on the left and put a new one there: the same object reads the new chest.

When the block is gone, or is no longer the right kind, the method stops the program with an error:

messagewhen
peripheral is not loadedthe block's chunk is not loaded (any type)
traffic light removeda Traffic Light is gone (set)
monitor removeda monitor is gone
radio removeda Radio Modem or Wi-Fi Router is gone
redstone link not readya Redstone Link is gone, or not ready yet
not a kinetic block anymorea Create block that turned is gone
not an inventory anymorea block that held items is gone
not a tank anymorea block that held fluids is gone
altitude sensor removed, hot air burner removed...a block of Create Aeronautics is gone: its type, with spaces
relay removed, station removed, display link removed...any other block is gone: its name

A few readings answer nil instead of failing: the get of a Traffic Light that is gone returns nil.

The methods of an object are chosen when it is wrapped. If a different kind of block takes the place (a barrel where the Traffic Light was), the old object keeps the methods of a Traffic Light, which now fail: wrap the block again.

To keep a program alive when a block may disappear, call the method through pcall, which returns a table instead of stopping the program:

Brass
local chest = peripheral.wrap("left")
while true do
  local result = pcall(chest.count, "minecraft:coal")
  if result.ok then
    print("coal: " .. result.value)
  else
    print("the coal chest is missing!")
  end
  sleep(5)
end

More on catching errors: pcall and Errors and debugging.