Core¶
- class Object¶
Global object
- class DB¶
Comment to class
-
reg(self:
DB
, proto:Prototype
)¶ Register Prototype in DB
- Parameters:
proto (
Prototype
) – Prototype to register
-
remove(self:
DB
, proto:Prototype
) was:boolean
¶ Remove Prototype from DB
- Parameters:
proto (
Prototype
) – Prototype to remove- Returns:
was (
boolean
) – Prototype removed
-
from_table(self:
DB
, table:table
)¶ Register object with class “class” and name “name” from table, filling all other properties from from table too
- Parameters:
table (
table
) – Object table
-
staticmethod new(parent:
Object
, name:string
)DB
¶ Creates a new DB instance
- Parameters:
parent (
Object
) – Object of parentname (
string
) – The name of the instance
-
staticmethod get_class()
Class
¶ Return DB class object
-
reg(self:
Example usage of db:from_table¶
1db:from_table({
2 class = "StaticTip",
3 name = "Accessors1",
4 label = Loc.new("Accessors1", "tips"),
5 description = Loc.new("Accessors1Description", "tips"),
6 image = "Textures/Accessors1.png",
7 context = i_acc
8})
Example usage of db:from_table¶
1local logic = function(self)
2 local crafter = AbstractCrafter.cast(self)
3 crafter.recipes = RecipeDictionary.find("MaceratorRecipeDictionary")
4 crafter.speed = Vlib.get_speed(crafter)
5
6 Vlib.add_single_slot_invs(crafter.crafter_input_container, crafter, "ii", 1)
7 Vlib.add_single_slot_invs(crafter.crafter_output_container, crafter, "io", 2)
8
9 local inv = ResourceInventory.new(crafter, "rii")
10 inv.item = StaticItem.find("Kinetic")
11 inv.capacity = Vlib.get_consumption(crafter, 20)
12 crafter.energy_input_inventory = inv
13
14 local acc = ResourceAccessor.new(crafter, "rai")
15 acc.side, acc.pos = Vec3i.back, Vec3i.zero
16 acc.inventory = inv
17 acc.is_input = true
18 acc.channel = "Kinetic"
19 acc.cover = StaticCover.find("KineticInput")
20end
21
22local tables = { logic_init = logic }
23
24local block = StaticBlock.find("CopperMacerator")
25if block ~= nil then
26 print("CopperMacerator found, registering lua table")
27
28 for key, value in pairs(table) do
29 block.lua[key] = value
30 end
31end