This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
component:database [2015/01/14 23:40] 127.0.0.1 external edit |
component:database [2015/08/12 21:31] (current) rashy |
||
---|---|---|---|
Line 22: | Line 22: | ||
Copies the data stored in this database to another database with the specified address. | Copies the data stored in this database to another database with the specified address. | ||
+ | |||
+ | Example Use: | ||
+ | |||
+ | ```lua | ||
+ | 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 | ||
+ | ``` | ||
---- | ---- | ||
{{page>component:contents&noheader&noeditbutton&nouser&nofooter}} | {{page>component:contents&noheader&noeditbutton&nouser&nofooter}} |