Adds a node that is a digiline queryable database of all crafting and technic recipes known to the game engine.
This node can be used with a lua controller, lua sorting tubes and various technic machines to create a fully automated 'Universal Autocrafting Machine', which can recursively build anything (ex: technic:hv_battery_box0).
Depends on:
technic
digilines
get
- Given an exact item name (ex: 'default:pick_stone', 'technic:hv_battery_box0', ...), return a list of all technic and regular recipes that can prodce that item.find
- Given a partial (or full) item name, return a table of all items with a matching name, and details about that item, such as its inventory image (for use in digistuff:touchscreen as 'addimage').
All respones are tables with 2 keys: request
and response
, with request
being a verbatim copy of the original request (so that a LUAC can send multiple
requests and correlate the resposnes). The sub response
table depends on
the API invoked.
get
returns a list of all crafting, cooking and technic recipes that can
produce the item specified.
Digiline request message format:
command
(string) - Literal stringget
.item
(string) - Full itemstring name in the form "mod_name:item_name". Ex: 'technic:hv_cable'.
Example request:
{ command='get', item='default:pick_stone' }
The 'repsonse' entry is a list (iterate via 'ipairs()') of recipe tables.
Each recipe table contains the following keys:
inputs
(table) - keys are item names, values are quanties required. Note that this is NOT the crafting grid arrangement. This is just a summary of the inputs for the LUAC's convienience.action
(string) - Which type of machine to use to create the item. Values come directly from underlying technic and crafting tables:alloy
(alloy furnace, has 2 inputs)compressing
(compressor)extracting
(extractor)freezing
(freezer)grinding
(grinder)separating
(centrifuge)normal
(autocrafter)cooking
(furnace)
craft
(table) - Exact shape of which item goes into each slot of the crafting grid. Contains two elements:width
(number) - Integer width of the crafting grid.grid
(table) - Maps grid index (1 to width^2) to a string (item name).
outputs
(table) - Maps item names to quantities of what is produced.time
(number) - Count of seconds required to make the item.
Examples are at the bottom of this document.
find
returns a table of matching item strings and their inventory images.
Additional data might be added in future revisions of this mod.
Digiline request message format:
command
(string) - Literal stringfind
.item
(string) - Any valid matcher passable to 'string:match()'. Use '.' to match every registered item.offset
(integer) - Defaults to 1. Used to paginate the results if the count of items exceedsmax_count
.max_count
(integer) - Defaults to 20. Must be between 1 and 20. Maximum count of results to return.
Digiline response table format:
- key = full item string name. Ex: 'default:pick_stone'.
- value = table:
inventory_image
- The inventory image filename copied from the item registration.
If the item
pattern results in fewer than max_count
+1 matching items, then
the list is returned as-is. If there are more initial results than
max_count
, then the list is sorted by item string, then paginated by
offset
and max_count
. In either case, the actual returned table is
indexed by item name, so it is not inherently sorted.
- Some crafting recipes genreate a 'returned item', these returned items
are omiited from the return results. This is due to
minetest.get_all_craft_recipes()
not returning information on the 'returned item'. Ex:default.dirt
takes abucket:bucket_water
and should returnbucket:bucket_empty
. It is not safe for the craftdb to jam the returned item in, as some recipes also take buckets of liquid and do NOT return them (ex: home decor's toilet). - The node texture is terrible. Please send a PR to fix this! I am not a pixel artist.
Send a query for crafting recipe:
digiline_send("craftdb", {command='get', item='default:pick_stone'})
Response:
{
request = {
item = "default:pick_stone",
command = "get"
},
response = {
{
inputs = {
["group:stone"] = 3
},
action = "normal",
craft = {
width = 3,
grid = {
"group:stone",
"group:stone",
"group:stone",
[5] = "group:stick",
[8] = "group:stick"
}
},
outputs = {
["default:pick_stone"] = 1
},
time = 1
}
}
}
Request:
digiline_send("craftdb", {command='get', item='technic:hv_battery_box0'})
Response:
{
request = {
item = "technic:hv_battery_box0",
command = "get"
},
response = {
{
action = "normal",
craft = {
width = 3,
grid = {
"technic:mv_battery_box0",
"technic:mv_battery_box0",
"technic:mv_battery_box0",
"technic:mv_battery_box0",
"technic:hv_transformer",
"technic:mv_battery_box0",
[8] = "technic:hv_cable"
}
},
inputs = {
["technic:hv_cable"] = 1,
["technic:mv_battery_box0"] = 5,
["technic:hv_transformer"] = 1
},
outputs = {
["technic:hv_battery_box0"] = 1
},
time = 1
}
}
}
Request:
digiline_send("craftdb", {command='get', item='technic:copper_plate'})
Response:
{
request = {
item = "technic:copper_plate",
command = "get"
},
response = {
{
action = "compressing",
inputs = {
["default:copper_ingot"] = 5
},
outputs = {
["technic:copper_plate"] = 1
},
time = 4
}
}
}
Request:
digiline_send("craftdb", {command='get', item='default:bronze_ingot'})
Response:
{
request = {
item = "default:bronze_ingot",
command = "get"
},
response = {
{
action = "alloy",
inputs = {
["default:tin_ingot"] = 1,
["default:copper_ingot"] = 7
},
outputs = {
["default:bronze_ingot"] = 8
},
time = 12
},
{
action = "cooking",
craft = {
width = 3,
grid = {
"technic:bronze_dust"
}
},
inputs = {
["technic:bronze_dust"] = 1
},
outputs = {
["default:bronze_ingot"] = 1
},
time = 1
},
{
action = "normal",
craft = {
width = 1,
grid = {
"default:bronzeblock"
}
},
inputs = {
["default:bronzeblock"] = 1
},
outputs = {
["default:bronze_ingot"] = 9
},
time = 1,
}
}
}