Allow freezing several items at once
[freezer.git] / juices.lua
1 -- Definition for juices, an intermediate stage for making popsicles
2 -- however, they can be consumed raw as well, but the benefit would be less
3
4 --[[
5 Definition scheme
6 internal_name_of_the_juice = {
7 proper_name = Human-readable name,
8 found_in = mod name where the source object is introduced
9 obj_name = name of source object (internal, without "modname:")
10 orig_nutritional_value = self-explanatory
11 }
12 -- image files for items must follow the scheme:
13 -- internal_name_of_the_juice.png and
14 -- internal_name_of_the_juice_inv.png (for inventory)
15 -- internal_name_of_the_juice_popsicle.png for the popsicle form
16 ]]
17
18 local juice_table = {
19 orange_juice = {
20 proper_name = "Orange juice",
21 found_in = "ethereal",
22 obj_name = "orange",
23 orig_nutritional_value = 2
24 },
25 banana_juice = {
26 proper_name = "Banana juice",
27 found_in = "ethereal",
28 obj_name = "banana",
29 orig_nutritional_value = 1
30 },
31 strawberry_juice = {
32 proper_name = "Strawberry juice",
33 found_in = "ethereal",
34 obj_name = "strawberry",
35 orig_nutritional_value = 1
36 },
37 coconut_milk = {
38 proper_name = "Coconut milk",
39 found_in = "ethereal",
40 obj_name = "coconut_slice",
41 orig_nutritional_value = 1
42 },
43 blueberry_juice = {
44 proper_name = "Blueberry juice",
45 found_in = "farming",
46 obj_name = "blueberries",
47 orig_nutritional_value = 1
48 },
49 raspberry_juice = {
50 proper_name = "Raspberry juice",
51 found_in = "farming",
52 obj_name = "raspberries",
53 orig_nutritional_value = 1
54 },
55 carrot_juice = {
56 proper_name = "Carrot juice",
57 found_in = "farming",
58 obj_name = "carrot",
59 orig_nutritional_value = 4
60 },
61 cucumber_juice = {
62 proper_name = "Cucumber juice",
63 found_in = "farming",
64 obj_name = "cucumber",
65 orig_nutritional_value = 4
66 },
67 grape_juice = {
68 proper_name = "Grape juice",
69 found_in = "farming",
70 obj_name = "grapes",
71 orig_nutritional_value = 2
72 },
73 melon_juice = {
74 proper_name = "Melon juice",
75 found_in = "farming",
76 obj_name = "melon_slice",
77 orig_nutritional_value = 2
78 },
79 pumpkin_juice = {
80 proper_name = "Pumpkin juice",
81 found_in = "farming",
82 obj_name = "pumpkin_slice",
83 orig_nutritional_value = 2
84 },
85 tomato_juice = {
86 proper_name = "Tomato juice",
87 found_in = "farming",
88 obj_name = "tomato",
89 orig_nutritional_value = 4
90 },
91
92 }
93
94
95 -- all juices are created accoriding to a single universal scheme
96 for juice_name, def in pairs(juice_table) do
97 if minetest.get_modpath(def.found_in) then
98
99 -- introducing a new item, a bit more nutricious than the source material
100 -- that's because one needs a glass, so effort should be rewarded
101 minetest.register_craftitem("freezer:" .. juice_name, {
102 description = def.proper_name,
103 inventory_image = juice_name .. "_inv.png",
104 wield_image = juice_name .. ".png",
105 groups = { juice = 1 },
106 on_use = minetest.item_eat(def.orig_nutritional_value+1, "vessels:drinking_glass"),
107 })
108
109 -- register corresponding popsicles
110 -- lower nutritional value is compensated by leaving a fancy stick behind
111 minetest.register_craftitem("freezer:" .. juice_name .. "_popsicle", {
112 description = def.proper_name .. " popsicle",
113 inventory_image = juice_name .. "_popsicle.png",
114 wield_image = juice_name .. "_popsicle.png",
115 groups = { popsicle = 1, not_in_creative_inventory = 1 },
116 on_use = minetest.item_eat(def.orig_nutritional_value, "default:stick"),
117 })
118
119 minetest.register_craft({
120 type = "shapeless",
121 output = "freezer:" .. juice_name,
122 recipe = {"vessels:drinking_glass", def.found_in .. ":" .. def.obj_name},
123 })
124
125 end
126 end
127
128 -- The Moor has done his duty, the Moor can go
129 juice_table = nil