Database Upgrade: Difference between revisions

From OpenComputers: Rebooted
Jump to navigation Jump to search
m SoraFirestorm moved page Item/database upgrade to Database Upgrade without leaving a redirect: Page has been unified
m Fix links to Geolyzer block
 
Line 5: Line 5:
Provides the <code>database</code> component.
Provides the <code>database</code> component.


This upgrade can be used to store item stack information. It can be configured by open its GUI by right clicking holding it in your hand and placing items in it (no actual items are stored in the item, clicking with an item in the grid will store a "ghost" stack). Alternatively, a few components allow configuring the database programmatically, such as the [[Item/inventory controller upgrade|Inventory Controller Upgrade]] and the [[Block/geolyzer|Geolyzer]].
This upgrade can be used to store item stack information. It can be configured by open its GUI by right clicking holding it in your hand and placing items in it (no actual items are stored in the item, clicking with an item in the grid will store a "ghost" stack). Alternatively, a few components allow configuring the database programmatically, such as the [[Item/inventory controller upgrade|Inventory Controller Upgrade]] and the [[Geolyzer|Geolyzer]].


The Database Upgrade (Tier 1) is crafted using the following recipe:
The Database Upgrade (Tier 1) is crafted using the following recipe:

Latest revision as of 18:22, 1 September 2026

Overview

Provides the database component.

This upgrade can be used to store item stack information. It can be configured by open its GUI by right clicking holding it in your hand and placing items in it (no actual items are stored in the item, clicking with an item in the grid will store a "ghost" stack). Alternatively, a few components allow configuring the database programmatically, such as the Inventory Controller Upgrade and the Geolyzer.

The Database Upgrade (Tier 1) is crafted using the following recipe:

The Database Upgrade (Tier 2) is crafted using the following recipe:

The Database Upgrade (Tier 3) is crafted using the following recipe:

Component API

Component name: database.

get

get(slot:number):table

Get the representation of the item stack stored in the specified slot.

computeHash

computeHash(slot:number):string

Computes a hash value for the item stack in the specified slot. This value is guaranteed to be the same for identical item stacks, allowing comparison of item stacks across a network (by comparing the hash values).

indexOf

indexOf(hash:string):number

Get the index of an item stack with the specified hash. Returns a negative value if no such stack was found.

clear

clear(slot:number):boolean

Clears the specified slot. Returns true if there was something in the slot before.

copy

copy(fromSlot:number, toSlot:number[, address:string]):boolean

Copies an entry to another slot, optionally to another database. Returns true if something was overwritten.

clone

clone(address:string):number

Copies the data stored in this database to another database with the specified address.

Example

local component = require("component")
local sides = require("sides")

local db = component.database -- primary database component
local invcontrol = component.inventory_controller -- primary inventory controller

-- define slot numbers
dbSlot = 1 invSlot = 1

-- compare item inside remote inventory to item in first slot of database
if db.get(dbSlot).label == invcontrol.getStackInSlot(sides.north, invSlot).label then
  -- items match, do stuff with it.
else
  -- items don't match, do nothing, or do something else.
end

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 - World Sensor 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