1
0
mirror of https://github.com/mt-mods/homedecor_modpack.git synced 2025-07-28 01:40:18 +02:00

Version MFF.

This commit is contained in:
sys4-fr
2018-09-07 22:32:38 +02:00
parent 2d0363f3ac
commit a11527ed63
1027 changed files with 8090 additions and 37753 deletions

50
homedecor/handlers/furnaces.lua Normal file → Executable file
View File

@ -1,6 +1,6 @@
-- This code supplies an oven/stove. Basically it's just a copy of the default furnace with different textures.
local S = homedecor_i18n.gettext
local S = homedecor.gettext
local function swap_node(pos, name)
local node = minetest.get_node(pos)
@ -30,11 +30,7 @@ local function make_formspec(furnacedef, percent)
"list[current_name;fuel;2,3;1,1;]"..
"list[current_name;src;2,1;1,1;]"..
"list[current_name;dst;5,1;"..w..","..h..";]"..
"list[current_player;main;0,5;8,4;]"..
"listring[current_name;dst]"..
"listring[current_player;main]"..
"listring[current_name;src]"..
"listring[current_player;main]"
"list[current_player;main;0,5;8,4;]"
end
--[[
@ -88,7 +84,7 @@ function homedecor.register_furnace(name, furnacedef)
furnacedef.cook_speed = furnacedef.cook_speed or 1
local description = furnacedef.description or S("Furnace")
local description = furnacedef.description or "Furnace"
local furnace_construct = function(pos)
local meta = minetest.get_meta(pos)
@ -106,7 +102,7 @@ function homedecor.register_furnace(name, furnacedef)
if listname == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext", S("@1 (empty)", description))
meta:set_string("infotext", S("%s is empty"):format(description))
end
return stack:get_count()
else
@ -125,7 +121,7 @@ function homedecor.register_furnace(name, furnacedef)
if to_list == "fuel" then
if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then
if inv:is_empty("src") then
meta:set_string("infotext", S("@1 (empty)", description))
meta:set_string("infotext", S("%s is empty"):format(description))
end
return count
else
@ -151,7 +147,7 @@ function homedecor.register_furnace(name, furnacedef)
}
local def_active = {
description = S("@1 (active)", description),
description = description .. " (active)",
tiles = make_tiles(furnacedef.tiles_active, furnacedef.tile_format, true),
light_source = 8,
drop = "homedecor:" .. name,
@ -171,28 +167,28 @@ function homedecor.register_furnace(name, furnacedef)
end
end
local n_active = name.."_active"
local name_active = name.."_active"
homedecor.register(name, def)
homedecor.register(n_active, def_active)
homedecor.register(name_active, def_active)
local nname, name_active = "homedecor:"..name, "homedecor:"..n_active
local name, name_active = "homedecor:"..name, "homedecor:"..name_active
minetest.register_abm({
nodenames = {nname, name_active, nname.."_locked", name_active.."_locked"},
nodenames = {name, name_active, name.."_locked", name_active.."_locked"},
label = "furnaces",
interval = 1.0,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local meta = minetest.get_meta(pos)
for i, pname in ipairs({
for i, name in ipairs({
"fuel_totaltime",
"fuel_time",
"src_totaltime",
"src_time"
}) do
if meta:get_string(pname) == "" then
meta:set_float(pname, 0.0)
if meta:get_string(name) == "" then
meta:set_float(name, 0.0)
end
end
@ -226,12 +222,12 @@ function homedecor.register_furnace(name, furnacedef)
-- XXX: Quick patch, make it better in the future.
local locked = node.name:find("_locked$") and "_locked" or ""
local desc = minetest.registered_nodes[nname..locked].description
local desc = minetest.registered_nodes[name..locked].description
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", S("@1 (active: @2%)", desc, percent))
meta:set_string("infotext",S("%s active: %d%%"):format(desc,percent))
swap_node(pos,name_active..locked)
meta:set_string("formspec", make_formspec(furnacedef, percent))
return
@ -239,9 +235,9 @@ function homedecor.register_furnace(name, furnacedef)
local fuel = nil
local afterfuel
cooked = nil
local cooked = nil
local fuellist = inv:get_list("fuel")
srclist = inv:get_list("src")
local srclist = inv:get_list("src")
if srclist then
cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
@ -251,24 +247,24 @@ function homedecor.register_furnace(name, furnacedef)
end
if (not fuel) or (fuel.time <= 0) then
meta:set_string("infotext", S("@1 (out of fuel)", desc))
swap_node(pos, nname..locked)
meta:set_string("infotext",desc..S(": Out of fuel"))
swap_node(pos, name..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0))
return
end
if cooked.item:is_empty() then
if was_active then
meta:set_string("infotext", S("@1 (empty)", desc))
swap_node(pos, nname..locked)
meta:set_string("infotext",S("%s is empty"):format(desc))
swap_node(pos, name..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0))
end
return
end
if not inv:room_for_item("dst", cooked.item) then
meta:set_string("infotext", S("@1 (output bins are full)", desc))
swap_node(pos, nname..locked)
meta:set_string("infotext", desc..S(": output bins are full"))
swap_node(pos, name..locked)
meta:set_string("formspec", make_formspec(furnacedef, 0))
return
end