Merge remote-tracking branch 'origin/bonfire_and_furnace'
This commit is contained in:
commit
9ece5eb193
@ -11,19 +11,22 @@ function furnace.check_furnace_blocks(pos)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
furnace.formspec =
|
furnace.formspec =
|
||||||
"invsize[8,9;]"..
|
"invsize[8,10;]"..
|
||||||
"image[2,3;1,1;default_furnace_fire_bg.png]"..
|
"list[current_name;src1;1.5,0;1,1;]"..
|
||||||
"list[current_name;fuel;2,2;1,1;]"..
|
"list[current_name;dst1;1.5,1;1,1;]"..
|
||||||
"list[current_name;src;1,1;1,1;]"..
|
"list[current_name;src2;2.5,1;1,1;]"..
|
||||||
"list[current_name;dst;2,1;2,1;]"..
|
"list[current_name;dst2;2.5,2;1,1;]"..
|
||||||
"list[current_name;add;5,1;2,2;]"..
|
"list[current_name;src3;3.5,2;1,1;]"..
|
||||||
"label[0,1;Source:]"..
|
"list[current_name;dst3;3.5,3;1,1;]"..
|
||||||
"label[0,2;Fuel:]"..
|
"list[current_name;src4;4.5,1;1,1;]"..
|
||||||
"label[2,0;Output:]"..
|
"list[current_name;dst4;4.5,2;1,1;]"..
|
||||||
"label[5,0;Additional:]"..
|
"list[current_name;src5;5.5,0;1,1;]"..
|
||||||
"list[current_player;main;0,5;8,4;]"
|
"list[current_name;dst5;5.5,1;1,1;]"..
|
||||||
|
"image[3.5,4;1,1;default_furnace_fire_bg.png]"..
|
||||||
|
"list[current_name;fuel;3.5,5;1,1;]"..
|
||||||
|
"list[current_player;main;0,6;8,4;]"
|
||||||
|
|
||||||
minetest.register_node("furnace:self", {
|
minetest.register_node("furnace:self", {
|
||||||
description = "Furnace",
|
description = "Furnace",
|
||||||
tiles = {"furnace_top.png", "furnace_bottom.png", "furnace_side.png"},
|
tiles = {"furnace_top.png", "furnace_bottom.png", "furnace_side.png"},
|
||||||
@ -48,23 +51,24 @@ minetest.register_node("furnace:self", {
|
|||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
meta:set_string("formspec", furnace.formspec)
|
meta:set_string("formspec", furnace.formspec)
|
||||||
meta:set_string("infotext", "Furnace")
|
meta:set_string("infotext", "Furnace")
|
||||||
|
meta:set_int("active", 0)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
for i = 1,5 do
|
||||||
|
inv:set_size("src"..i, 1)
|
||||||
|
inv:set_size("dst"..i, 1)
|
||||||
|
end
|
||||||
inv:set_size("fuel", 1)
|
inv:set_size("fuel", 1)
|
||||||
inv:set_size("src", 1)
|
|
||||||
inv:set_size("dst", 2)
|
|
||||||
inv:set_size("add", 4)
|
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.env:get_meta(pos);
|
local meta = minetest.env:get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
for i = 1,5 do
|
||||||
|
if not inv:is_empty("src"..i) or not inv:is_empty("dst"..i) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
if not inv:is_empty("fuel") then
|
if not inv:is_empty("fuel") then
|
||||||
return false
|
return false
|
||||||
elseif not inv:is_empty("src") then
|
|
||||||
return false
|
|
||||||
elseif not inv:is_empty("dst") then
|
|
||||||
return false
|
|
||||||
elseif not inv:is_empty("add") then
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
@ -95,23 +99,24 @@ minetest.register_node("furnace:self_active", {
|
|||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
meta:set_string("formspec", furnace.formspec)
|
meta:set_string("formspec", furnace.formspec)
|
||||||
meta:set_string("infotext", "Furnace")
|
meta:set_string("infotext", "Furnace")
|
||||||
|
meta:set_int("active", 0)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
for i = 1,5 do
|
||||||
|
inv:set_size("src"..i, 1)
|
||||||
|
inv:set_size("dst"..i, 1)
|
||||||
|
end
|
||||||
inv:set_size("fuel", 1)
|
inv:set_size("fuel", 1)
|
||||||
inv:set_size("src", 1)
|
|
||||||
inv:set_size("dst", 2)
|
|
||||||
inv:set_size("add", 4)
|
|
||||||
end,
|
end,
|
||||||
can_dig = function(pos,player)
|
can_dig = function(pos,player)
|
||||||
local meta = minetest.env:get_meta(pos);
|
local meta = minetest.env:get_meta(pos);
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
for i = 1,5 do
|
||||||
|
if not inv:is_empty("src"..i) or not inv:is_empty("dst"..i) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
if not inv:is_empty("fuel") then
|
if not inv:is_empty("fuel") then
|
||||||
return false
|
return false
|
||||||
elseif not inv:is_empty("src") then
|
|
||||||
return false
|
|
||||||
elseif not inv:is_empty("dst") then
|
|
||||||
return false
|
|
||||||
elseif not inv:is_empty("add") then
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end,
|
end,
|
||||||
@ -137,25 +142,16 @@ minetest.register_abm({
|
|||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
for i, name in ipairs({
|
|
||||||
"fuel_totaltime",
|
|
||||||
"fuel_time",
|
|
||||||
"src_totaltime",
|
|
||||||
"src_time"
|
|
||||||
}) do
|
|
||||||
if meta:get_string(name) == "" then
|
|
||||||
meta:set_float(name, 0.0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
if not furnace.check_furnace_blocks(pos) then
|
if not furnace.check_furnace_blocks(pos) then
|
||||||
for _, v in ipairs({
|
for _, v in ipairs({
|
||||||
{"fuel", 1,},
|
{"fuel", 1,},
|
||||||
{"src", 1,},
|
{"src1", 1,}, {"dst1", 1,},
|
||||||
{"dst", 2,},
|
{"src2", 1,}, {"dst2", 1,},
|
||||||
{"add", 4,},
|
{"src3", 1,}, {"dst3", 1,},
|
||||||
|
{"src4", 1,}, {"dst4", 1,},
|
||||||
|
{"src5", 1,}, {"dst5", 1,},
|
||||||
}) do
|
}) do
|
||||||
local name, size = v[1], v[2]
|
local name, size = v[1], v[2]
|
||||||
for n = 1,size do
|
for n = 1,size do
|
||||||
@ -167,90 +163,113 @@ minetest.register_abm({
|
|||||||
minetest.env:remove_node(pos)
|
minetest.env:remove_node(pos)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local srclist = inv:get_list("src")
|
|
||||||
local cooked = nil
|
|
||||||
|
|
||||||
if srclist then
|
for i, name in ipairs({
|
||||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
"fuel_totaltime",
|
||||||
end
|
"fuel_time",
|
||||||
|
"src_totaltime1",
|
||||||
local was_active = false
|
"src_time1",
|
||||||
|
"src_totaltime2",
|
||||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
"src_time2",
|
||||||
was_active = true
|
"src_totaltime3",
|
||||||
meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
|
"src_time3",
|
||||||
meta:set_float("src_time", meta:get_float("src_time") + 1)
|
"src_totaltime4",
|
||||||
if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then
|
"src_time4",
|
||||||
-- check if there's room for output in "dst" list
|
"src_totaltime5",
|
||||||
if inv:room_for_item("dst",cooked.item) then
|
"src_time5",
|
||||||
-- Put result in "dst" list
|
}) do
|
||||||
inv:add_item("dst", cooked.item)
|
if meta:get_string(name) == "" then
|
||||||
-- take stuff from "src" list
|
meta:set_float(name, 0.0)
|
||||||
srcstack = inv:get_stack("src", 1)
|
|
||||||
srcstack:take_item()
|
|
||||||
inv:set_stack("src", 1, srcstack)
|
|
||||||
--else
|
|
||||||
--print("Could not insert '"..cooked.item.."'")
|
|
||||||
end
|
|
||||||
meta:set_string("src_time", 0)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
if meta:get_int("active") == 1 then
|
||||||
local percent = math.floor(meta:get_float("fuel_time") /
|
local srclists = {}
|
||||||
meta:get_float("fuel_totaltime") * 100)
|
local cookeds = {}
|
||||||
meta:set_string("infotext","Furnace active: "..percent.."%")
|
for i = 1,5 do
|
||||||
hacky_swap_node(pos,"furnace:self_active")
|
srclists[i] = inv:get_list("src"..i)
|
||||||
meta:set_string("formspec",
|
if srclists[i] then
|
||||||
"invsize[8,9;]"..
|
cookeds[i] = minetest.get_craft_result({method = "cooking", width = 1, items = srclists[i]})
|
||||||
"image[2,3;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
end
|
||||||
(100-percent)..":default_furnace_fire_fg.png]"..
|
end
|
||||||
"list[current_name;fuel;2,2;1,1;]"..
|
|
||||||
"list[current_name;src;1,1;1,1;]"..
|
|
||||||
"list[current_name;dst;2,1;2,1;]"..
|
|
||||||
"list[current_name;add;5,1;2,2;]"..
|
|
||||||
"label[0,1;Source:]"..
|
|
||||||
"label[0,2;Fuel:]"..
|
|
||||||
"label[2,0;Output:]"..
|
|
||||||
"label[5,0;Additional:]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]")
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
local fuel = nil
|
|
||||||
local cooked = nil
|
|
||||||
local fuellist = inv:get_list("fuel")
|
|
||||||
local srclist = inv:get_list("src")
|
|
||||||
|
|
||||||
if srclist then
|
local was_active = false
|
||||||
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
|
|
||||||
end
|
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||||
if fuellist then
|
was_active = true
|
||||||
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
meta:set_float("fuel_time", meta:get_float("fuel_time") + 1)
|
||||||
end
|
for i = 1,5 do
|
||||||
|
meta:set_float("src_time"..i, meta:get_float("src_time"..i) + 1)
|
||||||
|
|
||||||
|
if cookeds[i] and cookeds[i].item and meta:get_float("src_time"..i) >= cookeds[i].time then
|
||||||
|
-- check if there's room for output in "dst" list
|
||||||
|
if inv:room_for_item("dst"..i,cookeds[i].item) then
|
||||||
|
-- Put result in "dst" list
|
||||||
|
inv:add_item("dst"..i, cookeds[i].item)
|
||||||
|
-- take stuff from "src" list
|
||||||
|
srcstack = inv:get_stack("src"..i, 1)
|
||||||
|
srcstack:take_item()
|
||||||
|
inv:set_stack("src"..i, 1, srcstack)
|
||||||
|
--else
|
||||||
|
--print("Could not insert '"..cooked.item.."'")
|
||||||
|
end
|
||||||
|
meta:set_string("src_time"..i, 0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then
|
||||||
|
local percent = math.floor(meta:get_float("fuel_time") /
|
||||||
|
meta:get_float("fuel_totaltime") * 100)
|
||||||
|
meta:set_string("infotext","Furnace active: "..percent.."%")
|
||||||
|
hacky_swap_node(pos,"furnace:self_active")
|
||||||
|
meta:set_string("formspec",
|
||||||
|
"invsize[8,10;]"..
|
||||||
|
"list[current_name;src1;1.5,0;1,1;]"..
|
||||||
|
"list[current_name;dst1;1.5,1;1,1;]"..
|
||||||
|
"list[current_name;src2;2.5,1;1,1;]"..
|
||||||
|
"list[current_name;dst2;2.5,2;1,1;]"..
|
||||||
|
"list[current_name;src3;3.5,2;1,1;]"..
|
||||||
|
"list[current_name;dst3;3.5,3;1,1;]"..
|
||||||
|
"list[current_name;src4;4.5,1;1,1;]"..
|
||||||
|
"list[current_name;dst4;4.5,2;1,1;]"..
|
||||||
|
"list[current_name;src5;5.5,0;1,1;]"..
|
||||||
|
"list[current_name;dst5;5.5,1;1,1;]"..
|
||||||
|
"image[3.5,4;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
|
(100-percent)..":default_furnace_fire_fg.png]"..
|
||||||
|
"list[current_name;fuel;3.5,5;1,1;]"..
|
||||||
|
"list[current_player;main;0,6;8,4;]")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if fuel.time <= 0 then
|
local fuel = nil
|
||||||
meta:set_string("infotext","Furnace out of fuel")
|
local cookeds = {}
|
||||||
hacky_swap_node(pos,"furnace:self")
|
local fuellist = inv:get_list("fuel")
|
||||||
meta:set_string("formspec", furnace.formspec)
|
local srclists = {}
|
||||||
return
|
for i = 1,5 do
|
||||||
end
|
srclists[i] = inv:get_list("src"..i)
|
||||||
|
if srclists[i] then
|
||||||
if cooked.item:is_empty() then
|
cookeds[i] = minetest.get_craft_result({method = "cooking", width = 1, items = srclists[i]})
|
||||||
if was_active then
|
end
|
||||||
meta:set_string("infotext","Furnace is empty")
|
end
|
||||||
|
if fuellist then
|
||||||
|
fuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
|
||||||
|
end
|
||||||
|
|
||||||
|
if fuel.time <= 0 then
|
||||||
|
meta:set_string("infotext","Furnace out of fuel")
|
||||||
hacky_swap_node(pos,"furnace:self")
|
hacky_swap_node(pos,"furnace:self")
|
||||||
meta:set_string("formspec", furnace.formspec)
|
meta:set_string("formspec", furnace.formspec)
|
||||||
|
meta:set_int("active", 0)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
meta:set_string("fuel_totaltime", fuel.time)
|
meta:set_string("fuel_totaltime", fuel.time)
|
||||||
meta:set_string("fuel_time", 0)
|
meta:set_string("fuel_time", 0)
|
||||||
|
|
||||||
local stack = inv:get_stack("fuel", 1)
|
local stack = inv:get_stack("fuel", 1)
|
||||||
stack:take_item()
|
stack:take_item()
|
||||||
inv:set_stack("fuel", 1, stack)
|
inv:set_stack("fuel", 1, stack)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -4,6 +4,12 @@ minetest.register_tool("sticks:sticks", {
|
|||||||
on_use = function(item, user, pointed_thing)
|
on_use = function(item, user, pointed_thing)
|
||||||
local pos
|
local pos
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
|
if minetest.env:get_node(pointed_thing.under).name == "furnace:self" then
|
||||||
|
local meta = minetest.env:get_meta(pointed_thing.under)
|
||||||
|
meta:set_int("active", 1)
|
||||||
|
item:add_wear(65535/10)
|
||||||
|
return item
|
||||||
|
end
|
||||||
pos = pointed_thing.above
|
pos = pointed_thing.above
|
||||||
elseif pointed_thing.type == "object" then
|
elseif pointed_thing.type == "object" then
|
||||||
pos = pointed_thing.ref:getpos()
|
pos = pointed_thing.ref:getpos()
|
||||||
@ -35,7 +41,27 @@ minetest.register_tool("sticks:sticks", {
|
|||||||
for _, v in ipairs(coals) do
|
for _, v in ipairs(coals) do
|
||||||
v:remove()
|
v:remove()
|
||||||
end
|
end
|
||||||
minetest.env:set_node(pos, {name = "furnace:self"})
|
minetest.env:set_node(pos, {name = "furnace:self_active"})
|
||||||
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
meta:set_int("active", 1)
|
||||||
|
meta:set_float("fuel_time", 0)
|
||||||
|
meta:set_float("fuel_totaltime", 30)
|
||||||
|
meta:set_string("formspec",
|
||||||
|
"invsize[8,10;]"..
|
||||||
|
"list[current_name;src1;1.5,0;1,1;]"..
|
||||||
|
"list[current_name;dst1;1.5,1;1,1;]"..
|
||||||
|
"list[current_name;src2;2.5,1;1,1;]"..
|
||||||
|
"list[current_name;dst2;2.5,2;1,1;]"..
|
||||||
|
"list[current_name;src3;3.5,2;1,1;]"..
|
||||||
|
"list[current_name;dst3;3.5,3;1,1;]"..
|
||||||
|
"list[current_name;src4;4.5,1;1,1;]"..
|
||||||
|
"list[current_name;dst4;4.5,2;1,1;]"..
|
||||||
|
"list[current_name;src5;5.5,0;1,1;]"..
|
||||||
|
"list[current_name;dst5;5.5,1;1,1;]"..
|
||||||
|
"image[3.5,4;1,1;default_furnace_fire_bg.png"..
|
||||||
|
"^[lowpart:100:default_furnace_fire_fg.png]"..
|
||||||
|
"list[current_name;fuel;3.5,5;1,1;]"..
|
||||||
|
"list[current_player;main;0,6;8,4;]")
|
||||||
if furnaceb > 9 then
|
if furnaceb > 9 then
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user