Component : Database

logo

Description

This component is provided by the database upgrade.

The database component is primarily useful to work with “full” item stacks, including NBT tags, which are (by default) not available to Lua scripts (to avoid exploits / breaking of other mods' gameplay). Some components allow specifying item stacks by instead specifying the address of a database component, and slot the item stack is in that database - for example, the Export Bus driver for Applied Energistics 2 makes use of this functionality.

Component name: database.

Methods

Example

            
-- https://ocdoc.cil.li/component:database
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