fix broken ltier checks on MV/HV fuel-fired generators

This commit is contained in:
Vanessa Ezekowitz 2017-04-11 06:56:21 -04:00
parent 5d05f59482
commit bdd45f161a

View File

@ -82,9 +82,9 @@ function technic.register_generator(data)
local percent = math.floor((burn_time / burn_totaltime) * 100) local percent = math.floor((burn_time / burn_totaltime) * 100)
meta:set_string("infotext", desc.." ("..percent.."%)") meta:set_string("infotext", desc.." ("..percent.."%)")
local form = "" local form_buttons = ""
if ltier ~= "lv" then if ltier ~= "lv" then
form = fs_helpers.cycling_button( form_buttons = fs_helpers.cycling_button(
meta, meta,
"image_button[0,4.3;1,0.6", "image_button[0,4.3;1,0.6",
"splitstacks", "splitstacks",
@ -102,7 +102,7 @@ function technic.register_generator(data)
(percent)..":default_furnace_fire_fg.png]".. (percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0, 5;8, 4;]".. "list[current_player;main;0, 5;8, 4;]"..
"listring[]".. "listring[]"..
form form_buttons
) )
end end
@ -119,14 +119,14 @@ function technic.register_generator(data)
tube = data.tube and tube or nil, tube = data.tube and tube or nil,
on_construct = function(pos) on_construct = function(pos)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
meta:set_string("infotext", desc) meta:set_string("infotext", desc)
meta:set_int(data.tier.."_EU_supply", 0) meta:set_int(data.tier.."_EU_supply", 0)
meta:set_int("burn_time", 0) meta:set_int("burn_time", 0)
meta:set_int("tube_time", 0) meta:set_int("tube_time", 0)
local form = generator_formspec local form_buttons = ""
if ltier ~= "lv" then if not string.find(node.name, ":lv_") then
form = generator_formspec .. form_buttons = fs_helpers.cycling_button(
fs_helpers.cycling_button(
meta, meta,
"image_button[0,4.3;1,0.6", "image_button[0,4.3;1,0.6",
"splitstacks", "splitstacks",
@ -136,7 +136,7 @@ function technic.register_generator(data)
} }
).."label[0.9,4.31;Allow splitting incoming stacks from tubes]" ).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
end end
meta:set_string("formspec", form) meta:set_string("formspec", generator_formspec..form_buttons)
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("src", 1) inv:set_size("src", 1)
end, end,
@ -151,10 +151,11 @@ function technic.register_generator(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 node = minetest.get_node(pos)
local form = generator_formspec local form = generator_formspec
if ltier ~= "lv" then local form_buttons = ""
form = generator_formspec .. if not string.find(node.name, ":lv_") then
fs_helpers.cycling_button( form_buttons = fs_helpers.cycling_button(
meta, meta,
"image_button[0,4.3;1,0.6", "image_button[0,4.3;1,0.6",
"splitstacks", "splitstacks",
@ -164,9 +165,8 @@ function technic.register_generator(data)
} }
).."label[0.9,4.31;Allow splitting incoming stacks from tubes]" ).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
end end
meta:set_string("formspec", form) meta:set_string("formspec", generator_formspec..form_buttons)
end, end,
}) })
minetest.register_node("technic:"..ltier.."_generator_active", { minetest.register_node("technic:"..ltier.."_generator_active", {
@ -193,6 +193,7 @@ function technic.register_generator(data)
end, end,
on_timer = function(pos, node) on_timer = function(pos, node)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local node = minetest.get_node(pos)
-- Connected back? -- Connected back?
if meta:get_int(tier.."_EU_timeout") > 0 then return false end if meta:get_int(tier.."_EU_timeout") > 0 then return false end
@ -212,9 +213,9 @@ function technic.register_generator(data)
meta:set_int("burn_time", burn_time) meta:set_int("burn_time", burn_time)
local percent = math.floor(burn_time / burn_totaltime * 100) local percent = math.floor(burn_time / burn_totaltime * 100)
local formbuttons = "" local form_buttons = ""
if ltier ~= "lv" then if not string.find(node.name, ":lv_") then
form = fs_helpers.cycling_button( form_buttons = fs_helpers.cycling_button(
meta, meta,
"image_button[0,4.3;1,0.6", "image_button[0,4.3;1,0.6",
"splitstacks", "splitstacks",
@ -232,7 +233,7 @@ function technic.register_generator(data)
(percent)..":default_furnace_fire_fg.png]".. (percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0, 5;8, 4;]".. "list[current_player;main;0, 5;8, 4;]"..
"listring[]".. "listring[]"..
form form_buttons
) )
return true return true
end, end,
@ -240,10 +241,10 @@ function technic.register_generator(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 = generator_formspec local node = minetest.get_node(pos)
if ltier ~= "lv" then local form_buttons = ""
form = generator_formspec .. if not string.find(node.name, ":lv_") then
fs_helpers.cycling_button( form_buttons = fs_helpers.cycling_button(
meta, meta,
"image_button[0,4.3;1,0.6", "image_button[0,4.3;1,0.6",
"splitstacks", "splitstacks",
@ -266,10 +267,9 @@ function technic.register_generator(data)
(percent)..":default_furnace_fire_fg.png]".. (percent)..":default_furnace_fire_fg.png]"..
"list[current_player;main;0, 5;8, 4;]".. "list[current_player;main;0, 5;8, 4;]"..
"listring[]".. "listring[]"..
form form_buttons
) )
end, end,
}) })
technic.register_machine(tier, "technic:"..ltier.."_generator", technic.producer) technic.register_machine(tier, "technic:"..ltier.."_generator", technic.producer)