Generator Upgrade: Difference between revisions

From OpenComputers: Rebooted
Jump to navigation Jump to search
imported>OCDoc Import
Imported from legacy OpenComputers documentation at ocdoc.cil.li
 
m SoraFirestorm moved page Item/generator upgrade to Generator Upgrade without leaving a redirect: Page has been unified
 
(One intermediate revision by the same user not shown)
Line 5: Line 5:
Can be used to generate energy from fuel on the go. Burns items to generate energy over time, based on their fuel value.
Can be used to generate energy from fuel on the go. Burns items to generate energy over time, based on their fuel value.


Note that fuel can only be inserted into the generator via [[Component/generator|its API]], so you'll have to charge your robot up to a certain level using a [[Block/charger|charger block]] first.
Note that fuel can only be inserted into the generator via its API, so you'll have to charge your robot up to a certain level using a [[Block/charger|charger block]] first.


Per default the generator's efficiency is at 80% of a BuildCraft Stirling Engine, i.e. it consumes the fuel at the same pace a Stirling Engine would, but only outputs 80% of the energy a Stirling Engine would.
Per default the generator's efficiency is at 80% of a BuildCraft Stirling Engine, i.e. it consumes the fuel at the same pace a Stirling Engine would, but only outputs 80% of the energy a Stirling Engine would.
Line 18: Line 18:
[[File:generatorupgrade.png|200px]]
[[File:generatorupgrade.png|200px]]


== Contents ==
= Component API =
Component name: <code>generator</code>. Callbacks:
{{APICallback|name=count|signature=(): number|description=
The current number of fuel items still in the generator.
}}
{{APICallback|name=insert|signature=([count: number]): boolean[, string]|description=
Inserts up to the specified number of fuel items from the currently selected inventory slot into the generator's inventory. Returns <code>true</code> if at least one item was moved to the generator's inventory. Returns <code>false</code> and an error message otherwise.
 
Possible error messages are:
* <code>"selected slot does not contain fuel"</code> if the selected slot has no item which can be burnt
* <code>"different fuel type already queued"</code> if there is already another type of item in the generator
* <code>"queue is full"</code> if there already are 64 items of that type in the generator
}}
{{APICallback|name=remove|signature=([count: number]): boolean|description=
Removes up to the specified number of fuel items from the generator and places them into the currently selected slot or the first free slot after it. Returns true if at least one item was removed from the generator's inventory, false otherwise.
}}
 
= Example =
 
<syntaxhighlight lang="lua">
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)
</syntaxhighlight>
 
= Contents =


{{:Item/contents}}
{{:Item/contents}}

Latest revision as of 21:28, 10 September 2026

Generator Upgrade

Can be used to generate energy from fuel on the go. Burns items to generate energy over time, based on their fuel value.

Note that fuel can only be inserted into the generator via its API, so you'll have to charge your robot up to a certain level using a charger block first.

Per default the generator's efficiency is at 80% of a BuildCraft Stirling Engine, i.e. it consumes the fuel at the same pace a Stirling Engine would, but only outputs 80% of the energy a Stirling Engine would.

The Generator Upgrade is crafted using the following recipe:

Component API

Component name: generator. Callbacks:

count

count(): number

The current number of fuel items still in the generator.

insert

insert([count: number]): boolean[, string]

Inserts up to the specified number of fuel items from the currently selected inventory slot into the generator's inventory. Returns true if at least one item was moved to the generator's inventory. Returns false and an error message otherwise.

Possible error messages are:

  • "selected slot does not contain fuel" if the selected slot has no item which can be burnt
  • "different fuel type already queued" if there is already another type of item in the generator
  • "queue is full" if there already are 64 items of that type in the generator

remove

remove([count: number]): boolean

Removes up to the specified number of fuel items from the generator and places them into the currently selected slot or the first free slot after it. Returns true if at least one item was removed from the generator's inventory, false otherwise.

Example

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)

Contents

Items
Components Data Card - Debug Card - Graphics Card - Internet Card - Linked Card - Network Card - Redstone Card - Wireless Network Card
Storage Devices Floppy Disk - EEPROM - Hard Disk Drive - Memory
Upgrades Angel Upgrade - Battery Upgrade - Chunkloader Upgrade - Database Upgrade - Experience Upgrade - Generator Upgrade - Hover Upgrade - Inventory Controller Upgrade - Inventory Upgrade - Leash Upgrade - Navigation Upgrade - Piston Upgrade - Sign I/O Upgrade - Solar Generator Upgrade - Tank Upgrade - Tank Controller Upgrade - Tractor Beam Upgrade
Containers Card Container - Upgrade Container - Disk Drive
Others Analyzer - Texture Picker - Component Bus - CPU - APU - Drone Case - Manual - Microcontroller Case - Nanomachines - Remote Terminal - Terminal Server - Server - Tablet Case - Tablet - Crafting Materials - Ink Cartridge - Scrench - Hover Boots - Grog - Loot Disks