2 function default
.get_pfurnace_active_formspec(pos
, percent
)
5 "image[2,2;1,1;default_pfurnace_fire_bg.png^[lowpart:"..
6 (100-percent
)..":default_pfurnace_fire_fg.png]"..
7 "list[current_name;fuel;2,3;1,1;]"..
8 "list[current_name;src;2,1;1,1;]"..
9 "list[current_name;dst;5,1;2,2;]"..
10 "list[current_player;main;0,5;8,4;]"..
11 "background[-0.5,-0.65;9,10.35;".."pfurnace.png".."]"..
12 "listcolors[#001100;#006600;#ffffff;#006600;#ffffff]"
17 default
.pfurnace_inactive_formspec
=
19 "image[2,2;1,1;default_pfurnace_fire_bg.png]"..
20 "list[current_name;fuel;2,3;1,1;]"..
21 "list[current_name;src;2,1;1,1;]"..
22 "list[current_name;dst;5,1;2,2;]"..
23 "list[current_player;main;0,5;8,4;]"..
24 "background[-0.5,-0.65;9,10.35;".."pfurnace.png".."]"..
25 "listcolors[#001100;#006600;#ffffff;#006600;#ffffff]"
28 minetest
.register_node("default:pfurnace", {
29 description
= "Prisma Furnace",
30 tiles
= {"default_pfurnace_top.png", "default_pfurnace_bottom.png", "default_pfurnace_side.png",
31 "default_pfurnace_side.png", "default_pfurnace_side.png", "default_pfurnace_front.png"},
32 paramtype2
= "facedir",
34 legacy_facedir_simple
= true,
35 is_ground_content
= false,
36 sounds
= default
.node_sound_stone_defaults(),
37 on_construct
= function(pos
)
38 local meta
= minetest
.get_meta(pos
)
39 meta
:set_string("formspec", default
.pfurnace_inactive_formspec
)
40 meta
:set_string("infotext", "Prisma-Furnace")
41 local inv
= meta
:get_inventory()
42 inv
:set_size("fuel", 1)
43 inv
:set_size("src", 1)
44 inv
:set_size("dst", 4)
46 can_dig
= function(pos
,player
)
47 local meta
= minetest
.get_meta(pos
);
48 local inv
= meta
:get_inventory()
49 if not inv
:is_empty("fuel") then
51 elseif not inv
:is_empty("dst") then
53 elseif not inv
:is_empty("src") then
58 allow_metadata_inventory_put
= function(pos
, listname
, index
, stack
, player
)
59 local meta
= minetest
.get_meta(pos
)
60 local inv
= meta
:get_inventory()
61 if listname
== "fuel" then
62 if minetest
.get_craft_result({method
="fuel",width
=1,items
={stack
}}).time
~= 0 then
63 if inv
:is_empty("src") then
64 meta
:set_string("infotext","Prisma-Furnace is empty")
66 return stack
:get_count()
70 elseif listname
== "src" then
71 return stack
:get_count()
72 elseif listname
== "dst" then
76 allow_metadata_inventory_move
= function(pos
, from_list
, from_index
, to_list
, to_index
, count
, player
)
77 local meta
= minetest
.get_meta(pos
)
78 local inv
= meta
:get_inventory()
79 local stack
= inv
:get_stack(from_list
, from_index
)
80 if to_list
== "fuel" then
81 if minetest
.get_craft_result({method
="fuel",width
=1,items
={stack
}}).time
~= 0 then
82 if inv
:is_empty("src") then
83 meta
:set_string("infotext","Prisma-Furnace is empty")
89 elseif to_list
== "src" then
91 elseif to_list
== "dst" then
98 minetest
.register_node("default:pfurnace_active", {
99 description
= "Prisma Furnace",
101 "default_pfurnace_top.png",
102 "default_pfurnace_bottom.png",
103 "default_pfurnace_side.png",
104 "default_pfurnace_side.png",
105 "default_pfurnace_side.png",
107 image
= "default_pfurnace_front_active.png",
108 backface_culling
= false,
110 type = "vertical_frames",
117 paramtype2
= "facedir",
119 drop
= "default:pfurnace",
120 groups
= {cracky
=2, not_in_creative_inventory
=1,hot
=1},
121 legacy_facedir_simple
= true,
122 is_ground_content
= false,
123 sounds
= default
.node_sound_stone_defaults(),
124 on_construct
= function(pos
)
125 local meta
= minetest
.get_meta(pos
)
126 meta
:set_string("formspec", default
.pfurnace_inactive_formspec
)
127 meta
:set_string("infotext", "Prisma-Furnace");
128 local inv
= meta
:get_inventory()
129 inv
:set_size("fuel", 1)
130 inv
:set_size("src", 1)
131 inv
:set_size("dst", 4)
133 can_dig
= function(pos
,player
)
134 local meta
= minetest
.get_meta(pos
);
135 local inv
= meta
:get_inventory()
136 if not inv
:is_empty("fuel") then
138 elseif not inv
:is_empty("dst") then
140 elseif not inv
:is_empty("src") then
145 allow_metadata_inventory_put
= function(pos
, listname
, index
, stack
, player
)
146 local meta
= minetest
.get_meta(pos
)
147 local inv
= meta
:get_inventory()
148 if listname
== "fuel" then
149 if minetest
.get_craft_result({method
="fuel",width
=1,items
={stack
}}).time
~= 0 then
150 if inv
:is_empty("src") then
151 meta
:set_string("infotext","Prisma-Furnace is empty")
153 return stack
:get_count()
157 elseif listname
== "src" then
158 return stack
:get_count()
159 elseif listname
== "dst" then
163 allow_metadata_inventory_move
= function(pos
, from_list
, from_index
, to_list
, to_index
, count
, player
)
164 local meta
= minetest
.get_meta(pos
)
165 local inv
= meta
:get_inventory()
166 local stack
= inv
:get_stack(from_list
, from_index
)
167 if to_list
== "fuel" then
168 if minetest
.get_craft_result({method
="fuel",width
=1,items
={stack
}}).time
~= 0 then
169 if inv
:is_empty("src") then
170 meta
:set_string("infotext","Prisma-Furnace is empty")
176 elseif to_list
== "src" then
178 elseif to_list
== "dst" then
185 local function swap_node(pos
,name
)
186 local node
= minetest
.get_node(pos
)
187 if node
.name
== name
then
191 minetest
.swap_node(pos
,node
)
195 minetest
.register_abm({
196 nodenames
= {"default:pfurnace","default:pfurnace_active"},
199 action
= function(pos
, node
, active_object_count
, active_object_count_wider
)
200 local meta
= minetest
.get_meta(pos
)
201 for i
, name
in ipairs({
207 if meta
:get_string(name
) == "" then
208 meta
:set_float(name
, 0.0)
213 local inv
= meta
:get_inventory()
216 local srclist
= inv
:get_list("src")
222 cooked
, aftercooked
= minetest
.get_craft_result({method
= "cooking", width
= 1, items
= srclist
})
226 local was_active
= false
229 if meta
:get_float("fuel_time") < meta
:get_float("fuel_totaltime") then
231 meta
:set_float("fuel_time", meta
:get_float("fuel_time") + 1)
232 meta
:set_float("src_time", meta
:get_float("src_time") + 4.25)
233 if cooked
and cooked
.item
and meta
:get_float("src_time") >= cooked
.time
then
234 -- check if there's room for output in "dst" list
235 if inv
:room_for_item("dst",cooked
.item
) then
236 -- Put result in "dst" list
237 inv
:add_item("dst", cooked
.item
)
238 -- take stuff from "src" list
239 inv
:set_stack("src", 1, aftercooked
.items
[1])
241 --print("Could not insert '"..cooked.item:to_string().."'")
243 meta
:set_string("src_time", 0)
248 if meta
:get_float("fuel_time") < meta
:get_float("fuel_totaltime") then
249 local percent
= math
.floor(meta
:get_float("fuel_time") /
250 meta
:get_float("fuel_totaltime") * 100)
251 meta
:set_string("infotext","Prisma-Furnace active: "..percent
.."%")
252 swap_node(pos
,"default:pfurnace_active")
253 --sound (brandon reese (adventuretest))
254 if meta
:get_int("sound_played") == nil or ( os
.time() - meta
:get_int("sound_played") ) >= 4 then
255 minetest
.sound_play("default_furnace",{pos
=pos
})
256 meta
:set_string("sound_played",os
.time())
259 meta
:set_string("formspec",default
.get_pfurnace_active_formspec(pos
, percent
))
267 local fuellist
= inv
:get_list("fuel")
268 local srclist
= inv
:get_list("src")
272 cooked
= minetest
.get_craft_result({method
= "cooking", width
= 1, items
= srclist
})
275 fuel
, afterfuel
= minetest
.get_craft_result({method
= "fuel", width
= 1, items
= fuellist
})
279 if not fuel
or fuel
.time
<= 0 then
280 meta
:set_string("infotext","Prisma-Furnace out of fuel")
281 swap_node(pos
,"default:pfurnace")
282 meta
:set_string("formspec", default
.pfurnace_inactive_formspec
)
287 if cooked
.item
:is_empty() then
289 meta
:set_string("infotext","Prisma-Furnace is empty")
290 swap_node(pos
,"default:pfurnace")
291 meta
:set_string("formspec", default
.pfurnace_inactive_formspec
)
297 meta
:set_string("fuel_totaltime", fuel
.time
)
298 meta
:set_string("fuel_time", 0)
301 inv
:set_stack("fuel", 1, afterfuel
.items
[1])
305 minetest
.register_craft({
306 output
= 'default:pfurnace',
308 {'default:obsidian', 'default:obsidian', 'default:obsidian'},
309 {'default:steel_ingot', 'travelnet:prismatic_gem', 'default:obsidian'},
310 {'default:obsidian', 'default:obsidian', 'default:obsidian'},