local gases_list = {["loria:oxygen_balloon"] = (balloon_coeff * 3)}
local function furnace_ready_3f(pos)
  local meta = minetest.get_meta(pos)
  local inv = meta:get_inventory()
  local gas = (inv:get_list("gas")[1]):get_name()
  local fuel = (inv:get_list("fuel")[1]):get_name()
  return (gases_list[gas] and fuel_list[fuel])
end
local function _0_(pos, elapsed)
  local meta = minetest.get_meta(pos)
  local inv = meta:get_inventory()
  local gas = inv:get_list("gas")[1]
  local _ce_94wear = gases_list[gas:get_name()]
  local wear = (gas:get_wear() + _ce_94wear)
  if (wear >= 65535) then
    inv:set_stack("gas", 1, {name = "loria:empty_balloon"})
    return false
  else
    gas:set_wear(wear)
    inv:set_stack("gas", 1, gas)
    return true
  end
end
update_gas = _0_
local function process_liquid_fuel(pos, meta, inv, fuel, burning_time, elapsed)
  local wear = fuel:get_wear()
  local _ce_94wear = ((elapsed / burning_time) * 65535)
  if ((wear + _ce_94wear) >= 65535) then
    add_or_drop(inv, "output", {name = "loria:bucket_empty"}, vector.add(pos, vector.new(0, 1, 0)))
    inv:set_list("fuel", {})
    return false
  else
    fuel:add_wear(_ce_94wear)
    inv:set_stack("fuel", 1, fuel)
    meta:set_float("cycle", ((1 - (wear / 65535)) * burning_time))
    return true
  end
end
local function process_solid_fuel(pos, meta, inv, fuel, burning_time, elapsed)
  local cycle = (meta:get_float("cycle") + elapsed)
  if (cycle > burning_time) then
    local count = (fuel:get_count() - 1)
    fuel:set_count(count)
    inv:set_stack("fuel", 1, fuel)
    if (count == 0) then
      return false
    else
      meta:set_float("cycle", 0)
      return true
    end
  else
    meta:set_float("cycle", cycle)
    return true
  end
end
local function _1_(fuel_list)
  local function _2_(pos, elapsed)
    local meta = minetest.get_meta(pos)
    local inv = meta:get_inventory()
    local fuel = inv:get_list("fuel")[1]
    local fuel_name = fuel:get_name()
    local burning_time = fuel_list[fuel_name]
    local handler = nil
    if bucket.is_bucket[fuel_name] then
      handler = process_liquid_fuel
    else
      handler = process_solid_fuel
    end
    return handler(pos, meta, inv, fuel, burning_time, elapsed)
  end
  return _2_
end
update_fuel = _1_
local function _2_(meta)
  return ("label[0,1.5;Gas]" .. "list[context;gas;0,2;1,1;]" .. "label[2,1.5;Fuel]" .. "list[context;fuel;2,2;1,1;]")
end
local function _3_(pos)
  return minetest.get_meta(pos):set_float("cycle", 0)
end
return register_furnace({additional_formspec = _2_, after_stop = _3_, crafts = furnace_crafts, description = "Gas furnace", groups = {cracky = 2}, is_furnace_ready = furnace_ready_3f, light_source = 10, lists = {fuel = 1, gas = 1}, name = "gas", on_tick = {update_fuel(fuel_list), update_gas}, textures = {active = {"furnace_side.png", "furnace_side.png", "furnace_side.png", "furnace_side.png", "furnace_side.png", {animation = {aspect_h = 16, aspect_w = 16, length = 1.5, type = "vertical_frames"}, backface_culling = false, image = "furnace_gas_front_active.png"}}, inactive = {"furnace_side.png", "furnace_side.png", "furnace_side.png", "furnace_side.png", "furnace_side.png", "furnace_gas_front.png"}}})
