This component is provided by the Items#generator-upgrade for robots. Generators have an internal inventory that can store one item stack of fuel items. This API allows interaction with that inventory.
Component name: generator
.
Callbacks:
count(): number
insert([count: number]): boolean[, string]
true
if at least one item was moved to the generator's inventory. Returns false
and an error message otherwise.remove([count: number]): boolean
true
if at least one item was removed from the generator's inventory, false
otherwise.Example use:
local component = require("component") -- Assuming the generator was just added to a robot and -- the selected slot contains one stack of coal: local g = component.generator -- get primary generator component print(g.count()) -- 0 g.insert(1) -- true print(g.count()) -- 0 because the item was immediately consumed, generator is running now g.insert(5) print(g.count()) -- 5 g.remove() -- remove everything from the generator print(g.count()) -- 0 g.insert() -- insert everything into the generator print(g.count()) -- 63 (minus the one consumed in the beginning)
Components | 3D Printer - Abstract Bus - Access Point - Chunkloader - Computer - Crafting - Data Card - Database - Debug - Drone - Drive - EEPROM - Experience - Filesystem - Generator - Geolyzer - GPU - Hologram - Internet - Inventory Controller - Leash - Microcontroller - Modem - Motion Sensor - Navigation - Net Splitter - Piston - Redstone - Redstone in Motion - Robot - Screen - Sign - Tank Controller - Tractor Beam - Transposer - Tunnel - World Sensor | |
---|---|---|
Others | Component Access - Signals | |
Cross-Mod Integration | Applied Energistics |