mirror of
https://github.com/minetest-mods/technic.git
synced 2025-03-20 11:20:31 +01:00
Merge f72322ff14c468c1647c17d2aa9a35fb2b582d42 into 42efc7e47c8e89ed5436261786bbfa1740300730
This commit is contained in:
commit
80c2f428c7
@ -13,20 +13,24 @@ minetest.register_craft({
|
|||||||
})
|
})
|
||||||
|
|
||||||
local machine_name = S("Fuel-Fired Alloy Furnace")
|
local machine_name = S("Fuel-Fired Alloy Furnace")
|
||||||
local formspec =
|
local function make_formspec(fuel_percent, progress_percentage)
|
||||||
"size[8,9]"..
|
return "size[8,9]"..
|
||||||
"label[0,0;"..machine_name.."]"..
|
"label[0,0;"..machine_name.."]"..
|
||||||
"image[2,2;1,1;default_furnace_fire_bg.png]"..
|
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
||||||
"list[current_name;fuel;2,3;1,1;]"..
|
fuel_percent..":default_furnace_fire_fg.png]"..
|
||||||
"list[current_name;src;2,1;2,1;]"..
|
"list[current_name;fuel;2,3;1,1;]"..
|
||||||
"list[current_name;dst;5,1;2,2;]"..
|
"list[current_name;src;2,1;2,1;]"..
|
||||||
"list[current_player;main;0,5;8,4;]"..
|
"list[current_name;dst;5,1;2,2;]"..
|
||||||
"listring[current_name;dst]"..
|
"list[current_player;main;0,5;8,4;]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_name;dst]"..
|
||||||
"listring[current_name;src]"..
|
"listring[current_player;main]"..
|
||||||
"listring[current_player;main]"..
|
"listring[current_name;src]"..
|
||||||
"listring[current_name;fuel]"..
|
"listring[current_player;main]"..
|
||||||
"listring[current_player;main]"
|
"listring[current_name;fuel]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"image[4,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
|
||||||
|
progress_percentage..":gui_furnace_arrow_fg.png^[transformR270]"
|
||||||
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:coal_alloy_furnace", {
|
minetest.register_node("technic:coal_alloy_furnace", {
|
||||||
description = machine_name,
|
description = machine_name,
|
||||||
@ -39,7 +43,7 @@ minetest.register_node("technic:coal_alloy_furnace", {
|
|||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", make_formspec(0, 0))
|
||||||
meta:set_string("infotext", machine_name)
|
meta:set_string("infotext", machine_name)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("fuel", 1)
|
inv:set_size("fuel", 1)
|
||||||
@ -124,21 +128,11 @@ minetest.register_abm({
|
|||||||
meta:get_float("fuel_totaltime") * 100)
|
meta:get_float("fuel_totaltime") * 100)
|
||||||
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
meta:set_string("infotext", S("%s Active"):format(machine_name).." ("..percent.."%)")
|
||||||
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
|
technic.swap_node(pos, "technic:coal_alloy_furnace_active")
|
||||||
meta:set_string("formspec",
|
if result and result.time ~= 0 then
|
||||||
"size[8,9]"..
|
meta:set_string("formspec", make_formspec(100 - percent, 100.0 * meta:get_int("src_time") / result.time))
|
||||||
"label[0,0;"..machine_name.."]"..
|
else
|
||||||
"image[2,2;1,1;default_furnace_fire_bg.png^[lowpart:"..
|
meta:set_string("formspec", make_formspec(100 - percent, 0))
|
||||||
(100 - percent)..":default_furnace_fire_fg.png]"..
|
end
|
||||||
"list[current_name;fuel;2,3;1,1;]"..
|
|
||||||
"list[current_name;src;2,1;2,1;]"..
|
|
||||||
"list[current_name;dst;5,1;2,2;]"..
|
|
||||||
"list[current_player;main;0,5;8,4;]"..
|
|
||||||
"listring[current_name;dst]"..
|
|
||||||
"listring[current_player;main]"..
|
|
||||||
"listring[current_name;src]"..
|
|
||||||
"listring[current_player;main]"..
|
|
||||||
"listring[current_name;fuel]"..
|
|
||||||
"listring[current_player;main]")
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -148,7 +142,7 @@ minetest.register_abm({
|
|||||||
if was_active then
|
if was_active then
|
||||||
meta:set_string("infotext", S("%s is empty"):format(machine_name))
|
meta:set_string("infotext", S("%s is empty"):format(machine_name))
|
||||||
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", make_formspec(0, 0))
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -165,7 +159,7 @@ minetest.register_abm({
|
|||||||
if fuel.time <= 0 then
|
if fuel.time <= 0 then
|
||||||
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
meta:set_string("infotext", S("%s Out Of Fuel"):format(machine_name))
|
||||||
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
technic.swap_node(pos, "technic:coal_alloy_furnace")
|
||||||
meta:set_string("formspec", formspec)
|
meta:set_string("formspec", make_formspec(0, 0))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -43,28 +43,45 @@ function technic.register_base_machine(data)
|
|||||||
local active_groups = {not_in_creative_inventory = 1}
|
local active_groups = {not_in_creative_inventory = 1}
|
||||||
for k, v in pairs(groups) do active_groups[k] = v end
|
for k, v in pairs(groups) do active_groups[k] = v end
|
||||||
|
|
||||||
local formspec =
|
local function make_formspec(data, progress_percentage, meta)
|
||||||
"invsize[8,9;]"..
|
local formspec_string = "size[8,9;]"..
|
||||||
"list[current_name;src;"..(4-input_size)..",1;"..input_size..",1;]"..
|
"list[current_name;src;"..(3.75-input_size)..",1.5;"..input_size..",1;]"..
|
||||||
"list[current_name;dst;5,1;2,2;]"..
|
"list[current_name;dst;5,1;2,2;]"..
|
||||||
"list[current_player;main;0,5;8,4;]"..
|
"list[current_player;main;0,5;8,4;]"..
|
||||||
"label[0,0;"..machine_desc:format(tier).."]"..
|
"label[0,0;"..machine_desc:format(tier).."]"..
|
||||||
"listring[current_name;dst]"..
|
"listring[current_name;dst]"..
|
||||||
"listring[current_player;main]"..
|
|
||||||
"listring[current_name;src]"..
|
|
||||||
"listring[current_player;main]"
|
|
||||||
if data.upgrade then
|
|
||||||
formspec = formspec..
|
|
||||||
"list[current_name;upgrade1;1,3;1,1;]"..
|
|
||||||
"list[current_name;upgrade2;2,3;1,1;]"..
|
|
||||||
"label[1,4;"..S("Upgrade Slots").."]"..
|
|
||||||
"listring[current_name;upgrade1]"..
|
|
||||||
"listring[current_player;main]"..
|
"listring[current_player;main]"..
|
||||||
"listring[current_name;upgrade2]"..
|
"listring[current_name;src]"..
|
||||||
"listring[current_player;main]"
|
"listring[current_player;main]"..
|
||||||
|
"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
|
||||||
|
progress_percentage..":gui_furnace_arrow_fg.png^[transformR270]"
|
||||||
|
if data.upgrade then
|
||||||
|
formspec_string = formspec_string..
|
||||||
|
"list[current_name;upgrade1;1,3;1,1;]"..
|
||||||
|
"list[current_name;upgrade2;2,3;1,1;]"..
|
||||||
|
"label[1,4;"..S("Upgrade Slots").."]"..
|
||||||
|
"listring[current_name;upgrade1]"..
|
||||||
|
"listring[current_player;main]"..
|
||||||
|
"listring[current_name;upgrade2]"..
|
||||||
|
"listring[current_player;main]"
|
||||||
|
end
|
||||||
|
if tier == "LV" then
|
||||||
|
return formspec_string
|
||||||
|
end
|
||||||
|
formspec_string = formspec_string..
|
||||||
|
fs_helpers.cycling_button(
|
||||||
|
meta,
|
||||||
|
pipeworks.button_base,
|
||||||
|
"splitstacks",
|
||||||
|
{
|
||||||
|
pipeworks.button_off,
|
||||||
|
pipeworks.button_on
|
||||||
|
}
|
||||||
|
)..pipeworks.button_label
|
||||||
|
return formspec_string
|
||||||
end
|
end
|
||||||
|
|
||||||
local run = function(pos, node)
|
local function run(pos, node)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
local eu_input = meta:get_int(tier.."_EU_input")
|
local eu_input = meta:get_int(tier.."_EU_input")
|
||||||
@ -73,6 +90,14 @@ function technic.register_base_machine(data)
|
|||||||
local machine_node = "technic:"..ltier.."_"..machine_name
|
local machine_node = "technic:"..ltier.."_"..machine_name
|
||||||
local machine_demand = data.demand
|
local machine_demand = data.demand
|
||||||
|
|
||||||
|
local function update_formspec(result)
|
||||||
|
if result and result.time ~= 0 then
|
||||||
|
meta:set_string("formspec", make_formspec(data, 100.0 * meta:get_int("src_time") / round(result.time * 10), meta))
|
||||||
|
else
|
||||||
|
meta:set_string("formspec", make_formspec(data, 0, meta))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Setup meta data if it does not exist.
|
-- Setup meta data if it does not exist.
|
||||||
if not eu_input then
|
if not eu_input then
|
||||||
meta:set_int(tier.."_EU_demand", machine_demand[1])
|
meta:set_int(tier.."_EU_demand", machine_demand[1])
|
||||||
@ -99,11 +124,13 @@ function technic.register_base_machine(data)
|
|||||||
meta:set_string("infotext", S("%s Idle"):format(machine_desc_tier))
|
meta:set_string("infotext", S("%s Idle"):format(machine_desc_tier))
|
||||||
meta:set_int(tier.."_EU_demand", 0)
|
meta:set_int(tier.."_EU_demand", 0)
|
||||||
meta:set_int("src_time", 0)
|
meta:set_int("src_time", 0)
|
||||||
|
update_formspec(result)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
meta:set_int(tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
meta:set_int(tier.."_EU_demand", machine_demand[EU_upgrade+1])
|
||||||
technic.swap_node(pos, machine_node.."_active")
|
technic.swap_node(pos, machine_node.."_active")
|
||||||
meta:set_string("infotext", S("%s Active"):format(machine_desc_tier))
|
meta:set_string("infotext", S("%s Active"):format(machine_desc_tier))
|
||||||
|
update_formspec(result)
|
||||||
if meta:get_int("src_time") < round(result.time*10) then
|
if meta:get_int("src_time") < round(result.time*10) then
|
||||||
if not powered then
|
if not powered then
|
||||||
technic.swap_node(pos, machine_node)
|
technic.swap_node(pos, machine_node)
|
||||||
@ -132,9 +159,11 @@ function technic.register_base_machine(data)
|
|||||||
meta:set_string("infotext", S("%s Idle"):format(machine_desc_tier))
|
meta:set_string("infotext", S("%s Idle"):format(machine_desc_tier))
|
||||||
meta:set_int(tier.."_EU_demand", 0)
|
meta:set_int(tier.."_EU_demand", 0)
|
||||||
meta:set_int("src_time", round(result.time*10))
|
meta:set_int("src_time", round(result.time*10))
|
||||||
|
update_formspec(result)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
meta:set_int("src_time", meta:get_int("src_time") - round(result.time*10))
|
meta:set_int("src_time", meta:get_int("src_time") - round(result.time*10))
|
||||||
|
update_formspec(result)
|
||||||
inv:set_list("src", result.new_input)
|
inv:set_list("src", result.new_input)
|
||||||
inv:set_list("dst", inv:get_list("dst_tmp"))
|
inv:set_list("dst", inv:get_list("dst_tmp"))
|
||||||
end
|
end
|
||||||
@ -164,22 +193,9 @@ function technic.register_base_machine(data)
|
|||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
local form_buttons = ""
|
|
||||||
if not string.find(node.name, ":lv_") then
|
|
||||||
form_buttons = fs_helpers.cycling_button(
|
|
||||||
meta,
|
|
||||||
pipeworks.button_base,
|
|
||||||
"splitstacks",
|
|
||||||
{
|
|
||||||
pipeworks.button_off,
|
|
||||||
pipeworks.button_on
|
|
||||||
}
|
|
||||||
)..pipeworks.button_label
|
|
||||||
end
|
|
||||||
|
|
||||||
meta:set_string("infotext", machine_desc:format(tier))
|
meta:set_string("infotext", machine_desc:format(tier))
|
||||||
meta:set_int("tube_time", 0)
|
meta:set_int("tube_time", 0)
|
||||||
meta:set_string("formspec", formspec..form_buttons)
|
meta:set_string("formspec", make_formspec(data, 0, meta))
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("src", input_size)
|
inv:set_size("src", input_size)
|
||||||
inv:set_size("dst", 4)
|
inv:set_size("dst", 4)
|
||||||
@ -198,19 +214,7 @@ function technic.register_base_machine(data)
|
|||||||
if not pipeworks.may_configure(pos, sender) then return end
|
if not pipeworks.may_configure(pos, sender) then return end
|
||||||
fs_helpers.on_receive_fields(pos, fields)
|
fs_helpers.on_receive_fields(pos, fields)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local form_buttons = ""
|
meta:set_string("formspec", make_formspec(data, 0, meta))
|
||||||
if not string.find(node.name, ":lv_") then
|
|
||||||
form_buttons = fs_helpers.cycling_button(
|
|
||||||
meta,
|
|
||||||
pipeworks.button_base,
|
|
||||||
"splitstacks",
|
|
||||||
{
|
|
||||||
pipeworks.button_off,
|
|
||||||
pipeworks.button_on
|
|
||||||
}
|
|
||||||
)..pipeworks.button_label
|
|
||||||
end
|
|
||||||
meta:set_string("formspec", formspec..form_buttons)
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -254,7 +258,7 @@ function technic.register_base_machine(data)
|
|||||||
}
|
}
|
||||||
)..pipeworks.button_label
|
)..pipeworks.button_label
|
||||||
end
|
end
|
||||||
meta:set_string("formspec", formspec..form_buttons)
|
meta:set_string("formspec", make_formspec(data, 0, meta))
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user