Christopher Head
2019-01-26 4f78a69ffc714886c9d6e812f78d543bb33fe674
technic/machines/register/generator.lua
@@ -1,6 +1,7 @@
local S = technic.getter
local fs_helpers = pipeworks.fs_helpers
local tube_entry = "^pipeworks_tube_connection_metallic.png"
local tube = {
   insert_object = function(pos, node, stack, direction)
@@ -19,7 +20,8 @@
   connect_sides = {left=1, right=1, back=1, top=1, bottom=1},
}
function technic.register_generator(data)
function technic.register_generator(data)
   local tier = data.tier
   local ltier = string.lower(tier)
@@ -33,7 +35,7 @@
   for k, v in pairs(groups) do active_groups[k] = v end
   local generator_formspec =
      "invsize[8,9;]"..
      "size[8,9;]"..
      "label[0,0;"..S("Fuel-Fired %s Generator"):format(tier).."]"..
      "list[current_name;src;3,1;1,1;]"..
      "image[4,1;1,1;default_furnace_fire_bg.png]"..
@@ -55,7 +57,7 @@
      -- Burn another piece of fuel
      if burn_time == 0 then
         local inv = meta:get_inventory()
         if not inv:is_empty("src") then
         if not inv:is_empty("src") then
            local fuellist = inv:get_list("src")
            local fuel
            local afterfuel
@@ -86,15 +88,15 @@
      if ltier ~= "lv" then
         form_buttons = fs_helpers.cycling_button(
            meta,
            "image_button[0,4.3;1,0.6",
            pipeworks.button_base,
            "splitstacks",
            {
               {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
               {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
               pipeworks.button_off,
               pipeworks.button_on
            }
         ).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
         )..pipeworks.button_label
      end
      meta:set_string("formspec",
      meta:set_string("formspec",
         "size[8, 9]"..
         "label[0, 0;"..minetest.formspec_escape(desc).."]"..
         "list[current_name;src;3, 1;1, 1;]"..
@@ -105,12 +107,20 @@
         form_buttons
      )
   end
   local tentry = tube_entry
   if ltier == "lv" then tentry = "" end
   minetest.register_node("technic:"..ltier.."_generator", {
      description = desc,
      tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
               "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
               "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front.png"},
      tiles = {
            "technic_"..ltier.."_generator_top.png"..tentry,
            "technic_machine_bottom.png"..tentry,
            "technic_"..ltier.."_generator_side.png"..tentry,
            "technic_"..ltier.."_generator_side.png"..tentry,
            "technic_"..ltier.."_generator_side.png"..tentry,
            "technic_"..ltier.."_generator_front.png"
      },
      paramtype2 = "facedir",
      groups = groups,
      connect_sides = {"bottom", "back", "left", "right"},
@@ -128,13 +138,13 @@
         if not string.find(node.name, ":lv_") then
            form_buttons = fs_helpers.cycling_button(
                  meta,
                  "image_button[0,4.3;1,0.6",
                  pipeworks.button_base,
                  "splitstacks",
                  {
                     {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
                     {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
                     pipeworks.button_off,
                     pipeworks.button_on
                  }
               ).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
               )..pipeworks.button_label
         end
         meta:set_string("formspec", generator_formspec..form_buttons)
         local inv = meta:get_inventory()
@@ -157,13 +167,13 @@
         if not string.find(node.name, ":lv_") then
            form_buttons = fs_helpers.cycling_button(
                  meta,
                  "image_button[0,4.3;1,0.6",
                  pipeworks.button_base,
                  "splitstacks",
                  {
                     {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
                     {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
                     pipeworks.button_off,
                     pipeworks.button_on
                  }
               ).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
               )..pipeworks.button_label
         end
         meta:set_string("formspec", generator_formspec..form_buttons)
      end,
@@ -171,9 +181,14 @@
   minetest.register_node("technic:"..ltier.."_generator_active", {
      description = desc,
      tiles = {"technic_"..ltier.."_generator_top.png", "technic_machine_bottom.png",
               "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_side.png",
               "technic_"..ltier.."_generator_side.png", "technic_"..ltier.."_generator_front_active.png"},
      tiles = {
         "technic_"..ltier.."_generator_top.png"..tube_entry,
         "technic_machine_bottom.png"..tube_entry,
         "technic_"..ltier.."_generator_side.png"..tube_entry,
         "technic_"..ltier.."_generator_side.png"..tube_entry,
         "technic_"..ltier.."_generator_side.png"..tube_entry,
         "technic_"..ltier.."_generator_front_active.png"
      },
      paramtype2 = "facedir",
      groups = active_groups,
      connect_sides = {"bottom"},
@@ -217,15 +232,15 @@
         if not string.find(node.name, ":lv_") then
            form_buttons = fs_helpers.cycling_button(
               meta,
               "image_button[0,4.3;1,0.6",
               pipeworks.button_base,
               "splitstacks",
               {
                  {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
                  {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
                  pipeworks.button_off,
                  pipeworks.button_on
               }
            ).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
            )..pipeworks.button_label
         end
         meta:set_string("formspec",
         meta:set_string("formspec",
            "size[8, 9]"..
            "label[0, 0;"..minetest.formspec_escape(desc).."]"..
            "list[current_name;src;3, 1;1, 1;]"..
@@ -246,20 +261,20 @@
         if not string.find(node.name, ":lv_") then
            form_buttons = fs_helpers.cycling_button(
                  meta,
                  "image_button[0,4.3;1,0.6",
                  pipeworks.button_base,
                  "splitstacks",
                  {
                     {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"},
                     {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
                     pipeworks.button_off,
                     pipeworks.button_on
                  }
               ).."label[0.9,4.31;Allow splitting incoming stacks from tubes]"
               )..pipeworks.button_label
         end
         local burn_totaltime = meta:get_int("burn_totaltime") or 0
         local burn_time = meta:get_int("burn_time")
         local percent = math.floor(burn_time / burn_totaltime * 100)
         meta:set_string("formspec",
         meta:set_string("formspec",
            "size[8, 9]"..
            "label[0, 0;"..minetest.formspec_escape(desc).."]"..
            "list[current_name;src;3, 1;1, 1;]"..