Novatux
2014-07-02 2a23587445cfcd4019275c063ea09ad072a25421
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 
local S = technic.getter
 
if unified_inventory and unified_inventory.register_craft_type then
    unified_inventory.register_craft_type("extracting", {
        description = S("Extracting"),
        height = 1,
        width = 1,
    })
end
 
technic.extractor_recipes = {}
 
function technic.register_extractor_recipe(data)
    data.time = data.time or 4
    local src = ItemStack(data.input):get_name()
    technic.extractor_recipes[src] = data
    if unified_inventory then
        unified_inventory.register_craft({
            type = "extracting",
            output = data.output,
            items = {data.input},
            width = 0,
        })
    end
end
 
-- Receive an ItemStack of result by an ItemStack input
function technic.get_extractor_recipe(item)
    if technic.extractor_recipes[item:get_name()] and
       item:get_count() >= ItemStack(technic.extractor_recipes[item:get_name()].input):get_count() then
        return technic.extractor_recipes[item:get_name()]
    else
        return nil
    end
end
 
minetest.after(0.01, function ()
    for ingredient, recipe in pairs(technic.extractor_recipes) do
        ingredient = minetest.registered_aliases[ingredient]
        while ingredient do
            technic.grinder_recipes[ingredient] = recipe
            ingredient = minetest.registered_aliases[ingredient]
        end
    end
end)
 
-- Receive an ItemStack of result by an ItemStack input
function technic.get_grinder_recipe(itemstack)
    return technic.grinder_recipes[itemstack:get_name()]
end
 
local recipes = {
    -- Dyes
    {"technic:coal_dust",                 "dye:black 2"},
    {"default:cactus",                    "dye:green 2"},
    {"default:dry_shrub",                 "dye:brown 2"},
    {"flowers:geranium",                  "dye:blue 2"},
    {"flowers:dandelion_white",           "dye:white 2"},
    {"flowers:dandelion_yellow",          "dye:yellow 2"},
    {"flowers:tulip",                     "dye:orange 2"},
    {"flowers:rose",                      "dye:red 2"},
    {"flowers:viola",                     "dye:violet 2"},
    
    -- Rubber
    {"technic:raw_latex",                 "technic:rubber 3"},
    {"moretrees:rubber_tree_trunk_empty", "technic:rubber"},
    {"moretrees:rubber_tree_trunk",       "technic:rubber"},
    
    -- Other
    {"technic:uranium 5",                 "technic:enriched_uranium"},
}
 
for _, data in pairs(recipes) do
    technic.register_extractor_recipe({input = data[1], output = data[2]})
end