Improve upgrade handling to allow an arbitrary number of upgrades.

Main changes included:
1) Upgrade handling code can now handle an arbitrary number of upgrades.
2) Compatibility code to move upgrade items to the new upgrade inventory.
3) Registrations (power requirement tables, etc.) were updated so they no longer assume a fixed upgrade size.
4) Wrench registrations include the new inventory name.
This commit is contained in:
Bluebird 2015-03-11 13:32:30 -05:00
parent 5bc306d4ba
commit 5b7f1813ce
15 changed files with 241 additions and 144 deletions

View File

@ -10,5 +10,5 @@ minetest.register_craft({
} }
}) })
technic.register_alloy_furnace({tier = "LV", speed = 1, demand = {300}}) technic.register_alloy_furnace({tier = "LV", speed = 1, demand = 300})

View File

@ -10,4 +10,4 @@ minetest.register_craft({
} }
}) })
technic.register_compressor({tier = "LV", demand = {300}, speed = 1}) technic.register_compressor({tier = "LV", demand = 300, speed = 1})

View File

@ -11,6 +11,6 @@ minetest.register_craft({
} }
}) })
technic.register_electric_furnace({tier="LV", demand={300}, speed = 2}) technic.register_electric_furnace({tier="LV", demand=300, speed = 2})

View File

@ -10,4 +10,4 @@ minetest.register_craft({
} }
}) })
technic.register_extractor({tier = "LV", demand = {300}, speed = 1}) technic.register_extractor({tier = "LV", demand = 300, speed = 1})

View File

@ -9,5 +9,5 @@ minetest.register_craft({
} }
}) })
technic.register_grinder({tier="LV", demand={200}, speed=1}) technic.register_grinder({tier="LV", demand=200, speed=1})

View File

@ -10,5 +10,5 @@ minetest.register_craft({
}) })
technic.register_alloy_furnace({tier = "MV", speed = 1.5, upgrade = 1, tube = 1, demand = {3000, 2000, 1000}}) technic.register_alloy_furnace({tier = "MV", speed = 1.5, upgrade = 1, tube = 1, demand = 3000, demand_reduction_factor=0.65 })

View File

@ -9,7 +9,8 @@ minetest.register_craft({
technic.register_centrifuge({ technic.register_centrifuge({
tier = "MV", tier = "MV",
demand = { 8000, 7000, 6000 }, demand = 8000,
demand_reduction_factor=0.25,
speed = 2, speed = 2,
upgrade = 1, upgrade = 1,
tube = 1, tube = 1,

View File

@ -14,5 +14,5 @@ minetest.register_craft({
} }
}) })
technic.register_electric_furnace({tier="MV", upgrade=1, tube=1, demand={2000, 1000, 500}, speed=4}) technic.register_electric_furnace({tier="MV", upgrade=1, tube=1, demand=2000, demand_reduction_factor=0.75, speed=4})

View File

@ -9,4 +9,4 @@ minetest.register_craft({
} }
}) })
technic.register_extractor({tier = "MV", demand = {800, 600, 400}, speed = 2, upgrade = 1, tube = 1}) technic.register_extractor({tier = "MV", demand = 800, demand_reduction_factor=0.5, speed = 2, upgrade = 1, tube = 1})

View File

@ -9,5 +9,5 @@ minetest.register_craft({
} }
}) })
technic.register_grinder({tier="MV", demand={600, 450, 300}, speed=2, upgrade=1, tube=1}) technic.register_grinder({tier="MV", demand=600, demand_reduction_factor=0.5, speed=2, upgrade=1, tube=1})

View File

@ -14,14 +14,15 @@ minetest.register_craft({
} }
}) })
local workshop_demand = {5000, 3500, 2000} local workshop_demand = 5000
local workshop_demand_reduction_factor = 0.6
local num_upgrade_slots = 2
local workshop_formspec = local workshop_formspec =
"invsize[8,9;]".. "invsize[8,9;]"..
"list[current_name;src;3,1;1,1;]".. "list[current_name;src;3,1;1,1;]"..
"label[0,0;"..S("%s Tool Workshop"):format("MV").."]".. "label[0,0;"..S("%s Tool Workshop"):format("MV").."]"..
"list[current_name;upgrade1;1,3;1,1;]".. "list[current_name;upgrades;1,3;" .. num_upgrade_slots .. ",1;]"..
"list[current_name;upgrade2;2,3;1,1;]"..
"label[1,4;"..S("Upgrade Slots").."]".. "label[1,4;"..S("Upgrade Slots").."]"..
"list[current_player;main;0,5;8,4;]".. "list[current_player;main;0,5;8,4;]"..
"listring[current_player;main]".. "listring[current_player;main]"..
@ -41,13 +42,20 @@ local run = function(pos, node)
-- 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("MV_EU_demand", workshop_demand[1]) meta:set_int("MV_EU_demand", workshop_demand)
meta:set_int("MV_EU_input", 0) meta:set_int("MV_EU_input", 0)
return return
end end
-- Do compatibility updates if needed.
technic.transfer_upgrades_to_new_upgrade_inventory(meta, formspec, num_upgrade_slots)
local EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta) local EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
-- Calculate the required EUs based on the normalized number of battery upgrades.
local norm_eu_upgrade = technic.normalize_value(EU_upgrade, 0, num_upgrade_slots)
local total_required_power = workshop_demand - ((workshop_demand * workshop_demand_reduction_factor) * norm_eu_upgrade)
local repairable = false local repairable = false
local srcstack = inv:get_stack("src", 1) local srcstack = inv:get_stack("src", 1)
if not srcstack:is_empty() then if not srcstack:is_empty() then
@ -70,14 +78,14 @@ local run = function(pos, node)
return return
end end
if eu_input < workshop_demand[EU_upgrade+1] then if eu_input < total_required_power then
meta:set_string("infotext", S("%s Unpowered"):format(machine_name)) meta:set_string("infotext", S("%s Unpowered"):format(machine_name))
elseif eu_input >= workshop_demand[EU_upgrade+1] then elseif eu_input >= total_required_power then
meta:set_string("infotext", S("%s Active"):format(machine_name)) meta:set_string("infotext", S("%s Active"):format(machine_name))
srcstack:add_wear(-1000) srcstack:add_wear(-1000)
inv:set_stack("src", 1, srcstack) inv:set_stack("src", 1, srcstack)
end end
meta:set_int("MV_EU_demand", workshop_demand[EU_upgrade+1]) meta:set_int("MV_EU_demand", total_required_power)
end end
minetest.register_node("technic:tool_workshop", { minetest.register_node("technic:tool_workshop", {
@ -92,8 +100,7 @@ minetest.register_node("technic:tool_workshop", {
meta:set_string("formspec", workshop_formspec) meta:set_string("formspec", workshop_formspec)
local inv = meta:get_inventory() local inv = meta:get_inventory()
inv:set_size("src", 1) inv:set_size("src", 1)
inv:set_size("upgrade1", 1) inv:set_size("upgrades", num_upgrade_slots)
inv:set_size("upgrade2", 1)
end, end,
can_dig = technic.machine_can_dig, can_dig = technic.machine_can_dig,
allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_put = technic.machine_inventory_put,

View File

@ -77,14 +77,13 @@ function technic.register_battery_box(data)
"listring[current_name;src]".. "listring[current_name;src]"..
"listring[current_player;main]" "listring[current_player;main]"
local num_upgrade_slots = 2
if data.upgrade then if data.upgrade then
formspec = formspec.. formspec = formspec..
"list[current_name;upgrade1;3.5,3;1,1;]".. "list[current_name;upgrades;3,3;"..num_upgrade_slots..",1;]"..
"list[current_name;upgrade2;4.5,3;1,1;]".. "label[3,4;"..S("Upgrade Slots").."]"..
"label[3.5,4;"..S("Upgrade Slots").."]".. "listring[current_name;upgrades]"..
"listring[current_name;upgrade1]"..
"listring[current_player;main]"..
"listring[current_name;upgrade2]"..
"listring[current_player;main]" "listring[current_player;main]"
end end
@ -93,6 +92,9 @@ function technic.register_battery_box(data)
local eu_input = meta:get_int(tier.."_EU_input") local eu_input = meta:get_int(tier.."_EU_input")
local current_charge = meta:get_int("internal_EU_charge") local current_charge = meta:get_int("internal_EU_charge")
-- Do compatibility updates if needed.
technic.transfer_upgrades_to_new_upgrade_inventory(meta, formspec, num_upgrade_slots)
local EU_upgrade, tube_upgrade = 0, 0 local EU_upgrade, tube_upgrade = 0, 0
if data.upgrade then if data.upgrade then
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta) EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
@ -195,8 +197,7 @@ function technic.register_battery_box(data)
meta:set_float("internal_EU_charge", 0) meta:set_float("internal_EU_charge", 0)
inv:set_size("src", 1) inv:set_size("src", 1)
inv:set_size("dst", 1) inv:set_size("dst", 1)
inv:set_size("upgrade1", 1) inv:set_size("upgrades", num_upgrade_slots)
inv:set_size("upgrade2", 1)
end, end,
can_dig = technic.machine_can_dig, can_dig = technic.machine_can_dig,
allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_put = technic.machine_inventory_put,

View File

@ -1,63 +1,132 @@
local S = technic.getter local S = technic.getter
-- handles the machine upgrades every tick
-- A function to normalize a value. The output floating-point value should
-- always be in the range [0, 1].
function technic.normalize_value(value, lower, upper)
value = value - lower
upper = upper - lower
return value / upper
end
-- This function is defined because the same compatibility code needs to be run
-- in three different places. This function can be removed once we are
-- reasonably sure that everyone is updated.
function technic.transfer_upgrades_to_new_upgrade_inventory(meta, new_formspec, new_inv_size)
local inv = meta:get_inventory()
-- Compatibility code. Move upgrade items from the (now depreciated)
-- upgrade inventory lists into the new unified upgrade list. This code
-- assumes that the new upgrade inventory size is at least 2.
if inv:get_size("upgrade1") > 0 then
assert(new_inv_size >= 2)
local upg1 = "upgrade1"
local upg2 = "upgrade2"
local new_list = "upgrades"
inv:set_size(new_list, new_inv_size)
local stack1 = inv:get_stack(upg1, 1)
local stack2 = inv:get_stack(upg2, 1)
if stack1 and stack1:get_count() > 0 then
inv:set_stack(new_list, 1, stack1)
inv:remove_item(upg1, stack1)
end
if stack2 and stack2:get_count() > 0 then
inv:set_stack(new_list, 2, stack2)
inv:remove_item(upg2, stack2)
end
-- Update the formspec.
meta:set_string("formspec", new_formspec)
inv:set_size(upg1, 0)
inv:set_size(upg2, 0)
end
end
-- Calculates the number & type of machine upgrades.
function technic.handle_machine_upgrades(meta) function technic.handle_machine_upgrades(meta)
-- Get the names of the upgrades local inv = meta:get_inventory()
local clu = "technic:control_logic_unit"
local bat = "technic:battery"
local bat_upgrades = 0
local clu_upgrades = 0
local upgrade_list = "upgrades"
local num_upgrade_slots = inv:get_size(upgrade_list)
for i = 1, num_upgrade_slots, 1 do
local stack = inv:get_stack(upgrade_list, i)
if stack then
local item = stack:get_name()
-- Assume that each inv slot cannot have more than 1 upgrade item.
if item == bat then bat_upgrades = bat_upgrades + 1 end
if item == clu then clu_upgrades = clu_upgrades + 1 end
end
end
return bat_upgrades, clu_upgrades
end
-- Machine upgrade callback. Called when something is about to be added. Returns
-- 'true' if the upgrade can be added, 'false' if not.
local function on_machine_upgrade(player, meta, to_index, stack)
local clu = "technic:control_logic_unit"
local bat = "technic:battery"
local chest = "default:chest"
local player_name = player:get_player_name()
local inv = meta:get_inventory() local inv = meta:get_inventory()
local srcstack = inv:get_stack("upgrade1", 1) local item = stack:get_name()
local upg_item1 = srcstack and srcstack:get_name() if item == chest then
srcstack = inv:get_stack("upgrade2", 1)
local upg_item2 = srcstack and srcstack:get_name()
-- Save some power by installing battery upgrades.
-- Tube loading speed can be upgraded using control logic units.
local EU_upgrade = 0
local tube_upgrade = 0
if upg_item1 == "technic:control_logic_unit" then
tube_upgrade = tube_upgrade + 1
elseif upg_item1 == "technic:battery" then
EU_upgrade = EU_upgrade + 1
end
if upg_item2 == "technic:control_logic_unit" then
tube_upgrade = tube_upgrade + 1
elseif upg_item2 == "technic:battery" then
EU_upgrade = EU_upgrade + 1
end
return EU_upgrade, tube_upgrade
end
-- handles the machine upgrades when set or removed
local function on_machine_upgrade(meta, stack)
local stack_name = stack:get_name()
if stack_name == "default:chest" then
meta:set_int("public", 1) meta:set_int("public", 1)
return 1 return true
elseif stack_name ~= "technic:control_logic_unit" elseif item == clu then
and stack_name ~= "technic:battery" then return true
return 0 elseif item == bat then
end return true
return 1
end end
-- something is about to be removed minetest.chat_send_player(player_name, S("That is not a valid upgrade item!"))
local function on_machine_downgrade(meta, stack, list) return false
if stack:get_name() == "default:chest" then end
-- Machine downgrade callback. Called just before something is removed.
local function on_machine_downgrade(player, meta, from_index, stack)
local chest = "default:chest"
if stack:get_name() == chest then
local inv = meta:get_inventory() local inv = meta:get_inventory()
local upg1, upg2 = inv:get_stack("upgrade1", 1), inv:get_stack("upgrade2", 1)
-- only set 0 if theres not another chest in the other list too local upgrade_list = "upgrades"
if (not upg1 or not upg2 or upg1:get_name() ~= upg2:get_name()) then local num_upgrade_slots = inv:get_size(upgrade_list)
meta:set_int("public", 0)
-- Check if any of the upgrade slots contain a chest.
local has_chest = false
for i = 1, num_upgrade_slots, 1 do
if i ~= from_index then -- Skip the chest that's about to be removed.
local stack = inv:get_stack(upgrade_list, i)
if stack then
local item = stack:get_name()
if item == chest then
has_chest = true
break -- If one chest is found, we don't need to look for more.
end end
end end
return 1
end end
end
-- If none of the upgrade slots contains a chest, the machine is no longer
-- publicly accessible.
if has_chest == false then meta:set_int("public", 0) end
end
end
function technic.send_items(pos, x_velocity, z_velocity, output_name, item_count) function technic.send_items(pos, x_velocity, z_velocity, output_name, item_count)
@ -136,8 +205,8 @@ function technic.handle_machine_pipeworks(pos, tube_upgrade, send_function, item
local eject_count = meta:get_int("eject_count") + items_processed_this_cycle local eject_count = meta:get_int("eject_count") + items_processed_this_cycle
meta:set_int("eject_count", eject_count) meta:set_int("eject_count", eject_count)
local tube_upgrade_max = 2 local num_upgrade_slots = inv:get_size("upgrades")
local norm_tube_upgrade = tube_upgrade / tube_upgrade_max local norm_tube_upgrade = technic.normalize_value(tube_upgrade, 0, num_upgrade_slots)
local stack_size = 11 local stack_size = 11
local tube_time = meta:get_int("tube_time") + 1 local tube_time = meta:get_int("tube_time") + 1
@ -174,10 +243,12 @@ end
function technic.machine_can_dig(pos, player) function technic.machine_can_dig(pos, player)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
if not inv:is_empty("src") or not inv:is_empty("dst") then if not inv:is_empty("src") or not inv:is_empty("dst") then
if player then if player then
minetest.chat_send_player(player:get_player_name(), local name = player:get_player_name()
S("Machine cannot be removed because it is not empty")) minetest.chat_send_player(
name, S("Machine cannot be removed because it is not empty"))
end end
return false return false
end end
@ -187,16 +258,15 @@ end
function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player) function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player)
if oldmetadata.inventory then if oldmetadata.inventory then
if oldmetadata.inventory.upgrade1 and oldmetadata.inventory.upgrade1[1] then if oldmetadata.inventory.upgrades then
local stack = ItemStack(oldmetadata.inventory.upgrade1[1]) local num_upgrade_slots = #(oldmetadata.inventory.upgrades)
for i = 1, num_upgrade_slots, 1 do
if oldmetadata.inventory.upgrades[i] then
local stack = ItemStack(oldmetadata.inventory.upgrades[i])
if not stack:is_empty() then if not stack:is_empty() then
minetest.item_drop(stack, "", pos) minetest.add_item(pos, stack)
end end
end end
if oldmetadata.inventory.upgrade2 and oldmetadata.inventory.upgrade2[1] then
local stack = ItemStack(oldmetadata.inventory.upgrade2[1])
if not stack:is_empty() then
minetest.item_drop(stack, "", pos)
end end
end end
end end
@ -206,42 +276,52 @@ function technic.machine_after_dig_node(pos, oldnode, oldmetadata, player)
end end
end end
local function inv_change(pos, player, count, from_list, to_list, stack)
local playername = player:get_player_name()
local meta = minetest.get_meta(pos);
local public = (meta:get_int("public") == 1)
local to_upgrade = to_list == "upgrade1" or to_list == "upgrade2"
local from_upgrade = from_list == "upgrade1" or from_list == "upgrade2"
if (not public or to_upgrade or from_upgrade) and minetest.is_protected(pos, playername) then
minetest.chat_send_player(playername, S("Inventory move disallowed due to protection")) local function inv_change(pos, player, count, from_list, from_index, to_list, to_index, stack)
local player_name = player:get_player_name()
local meta = minetest.get_meta(pos)
local public = (meta:get_int("public") == 1)
local is_upgrade = (to_list == "upgrades")
local is_downgrade = (from_list == "upgrades")
if (not public or is_upgrade or is_downgrade) and minetest.is_protected(pos, player_name) then
minetest.chat_send_player(player_name, S("Inventory move disallowed due to protection"))
return 0 return 0
end end
if to_upgrade then
-- only place a single item into it, if it's empty if is_upgrade then
local empty = meta:get_inventory():is_empty(to_list) local previous_stack = meta:get_inventory():get_stack("upgrades", to_index)
if empty then -- Only place a single item into the upgrade slot, if it is empty.
return on_machine_upgrade(meta, stack) if previous_stack:get_count() == 0 then
if on_machine_upgrade(player, meta, to_index, stack) then
count = 1
else
count = 0
end end
return 0 else
elseif from_upgrade then count = 0
-- only called on take (not move)
on_machine_downgrade(meta, stack, from_list)
end end
elseif is_downgrade then
-- Only called on take (not move).
on_machine_downgrade(player, meta, from_index, stack)
end
return count return count
end end
function technic.machine_inventory_put(pos, listname, index, stack, player)
return inv_change(pos, player, stack:get_count(), nil, listname, stack)
function technic.machine_inventory_put(pos, to_list, to_index, stack, player)
return inv_change(pos, player, stack:get_count(), nil, nil, to_list, to_index, stack)
end end
function technic.machine_inventory_take(pos, listname, index, stack, player) function technic.machine_inventory_take(pos, from_list, from_index, stack, player)
return inv_change(pos, player, stack:get_count(), listname, nil, stack) return inv_change(pos, player, stack:get_count(), from_list, from_index, nil, nil, stack)
end end
function technic.machine_inventory_move(pos, from_list, from_index, function technic.machine_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
to_list, to_index, count, player)
local stack = minetest.get_meta(pos):get_inventory():get_stack(from_list, from_index) local stack = minetest.get_meta(pos):get_inventory():get_stack(from_list, from_index)
return inv_change(pos, player, count, from_list, to_list, stack) return inv_change(pos, player, count, from_list, from_index, to_list, to_index, stack)
end end

View File

@ -26,6 +26,7 @@ function technic.register_base_machine(data)
local machine_desc = data.machine_desc local machine_desc = data.machine_desc
local tier = data.tier local tier = data.tier
local ltier = string.lower(tier) local ltier = string.lower(tier)
local num_upgrade_slots = data.upgrade_slots or 2
local groups = {cracky = 2, technic_machine = 1} local groups = {cracky = 2, technic_machine = 1}
local active_groups = {cracky = 2, technic_machine = 1, not_in_creative_inventory = 1} local active_groups = {cracky = 2, technic_machine = 1, not_in_creative_inventory = 1}
@ -36,7 +37,6 @@ function technic.register_base_machine(data)
active_groups.tubedevice_receiver = 1 active_groups.tubedevice_receiver = 1
end end
local formspec = local formspec =
"invsize[8,9;]".. "invsize[8,9;]"..
"list[current_name;src;"..(4-input_size)..",1;"..input_size..",1;]".. "list[current_name;src;"..(4-input_size)..",1;"..input_size..",1;]"..
@ -49,12 +49,9 @@ function technic.register_base_machine(data)
"listring[current_player;main]" "listring[current_player;main]"
if data.upgrade then if data.upgrade then
formspec = formspec.. formspec = formspec..
"list[current_name;upgrade1;1,3;1,1;]".. "list[current_name;upgrades;0,3;"..num_upgrade_slots..",1;]"..
"list[current_name;upgrade2;2,3;1,1;]".. "label[0,4;"..S("Upgrade Slots").."]"..
"label[1,4;"..S("Upgrade Slots").."]".. "listring[current_name;upgrades]"..
"listring[current_name;upgrade1]"..
"listring[current_player;main]"..
"listring[current_name;upgrade2]"..
"listring[current_player;main]" "listring[current_player;main]"
end end
@ -67,19 +64,31 @@ 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
-- This is the percentage by which the base demand may be reduced by a
-- complete complement of battery upgrades. Fewer battery upgrades than the
-- maximum possible will reduce the total demand by less than this.
local machine_demand_reduction_factor = data.demand_reduction_factor or 0.0
-- 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)
meta:set_int(tier.."_EU_input", 0) meta:set_int(tier.."_EU_input", 0)
return return
end end
-- Do compatibility updates if needed.
technic.transfer_upgrades_to_new_upgrade_inventory(meta, formspec, num_upgrade_slots)
local EU_upgrade, tube_upgrade = 0, 0 local EU_upgrade, tube_upgrade = 0, 0
if data.upgrade then if data.upgrade then
EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta) EU_upgrade, tube_upgrade = technic.handle_machine_upgrades(meta)
end end
local powered = eu_input >= machine_demand[EU_upgrade+1] -- Calculate the required EUs based on the normalized number of battery upgrades.
local norm_eu_upgrade = technic.normalize_value(EU_upgrade, 0, num_upgrade_slots)
local total_required_power = machine_demand - ((machine_demand * machine_demand_reduction_factor) * norm_eu_upgrade)
local powered = eu_input >= total_required_power
if powered then if powered then
meta:set_int("src_time", meta:get_int("src_time") + round(data.speed*10)) meta:set_int("src_time", meta:get_int("src_time") + round(data.speed*10))
end end
@ -95,7 +104,7 @@ function technic.register_base_machine(data)
meta:set_int("src_time", 0) meta:set_int("src_time", 0)
break break
end end
meta:set_int(tier.."_EU_demand", machine_demand[EU_upgrade+1]) meta:set_int(tier.."_EU_demand", total_required_power)
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))
if meta:get_int("src_time") < round(result.time*10) then if meta:get_int("src_time") < round(result.time*10) then
@ -158,8 +167,7 @@ function technic.register_base_machine(data)
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)
inv:set_size("upgrade1", 1) inv:set_size("upgrades", num_upgrade_slots)
inv:set_size("upgrade2", 1)
end, end,
can_dig = technic.machine_can_dig, can_dig = technic.machine_can_dig,
allow_metadata_inventory_put = technic.machine_inventory_put, allow_metadata_inventory_put = technic.machine_inventory_put,

View File

@ -75,7 +75,7 @@ wrench:register_node("technic:lv_electric_furnace_active", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_electric_furnace", { wrench:register_node("technic:mv_electric_furnace", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -84,7 +84,7 @@ wrench:register_node("technic:mv_electric_furnace", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_electric_furnace_active", { wrench:register_node("technic:mv_electric_furnace_active", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -127,7 +127,7 @@ wrench:register_node("technic:alloy_furnace_active", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_alloy_furnace", { wrench:register_node("technic:mv_alloy_furnace", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -136,7 +136,7 @@ wrench:register_node("technic:mv_alloy_furnace", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_alloy_furnace_active", { wrench:register_node("technic:mv_alloy_furnace_active", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -145,7 +145,7 @@ wrench:register_node("technic:mv_alloy_furnace_active", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:tool_workshop", { wrench:register_node("technic:tool_workshop", {
lists = {"src", "upgrade1", "upgrade2"}, lists = {"src", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -169,7 +169,7 @@ wrench:register_node("technic:grinder_active", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_grinder", { wrench:register_node("technic:mv_grinder", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -178,7 +178,7 @@ wrench:register_node("technic:mv_grinder", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_grinder_active", { wrench:register_node("technic:mv_grinder_active", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -203,7 +203,7 @@ wrench:register_node("technic:extractor_active", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_extractor", { wrench:register_node("technic:mv_extractor", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -212,7 +212,7 @@ wrench:register_node("technic:mv_extractor", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_extractor_active", { wrench:register_node("technic:mv_extractor_active", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -237,7 +237,7 @@ wrench:register_node("technic:compressor_active", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_compressor", { wrench:register_node("technic:mv_compressor", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -246,7 +246,7 @@ wrench:register_node("technic:mv_compressor", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_compressor_active", { wrench:register_node("technic:mv_compressor_active", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -273,7 +273,7 @@ wrench:register_node("technic:cnc_active", {
cnc_product = STRING}, cnc_product = STRING},
}) })
wrench:register_node("technic:mv_centrifuge", { wrench:register_node("technic:mv_centrifuge", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,
@ -282,7 +282,7 @@ wrench:register_node("technic:mv_centrifuge", {
src_time = INT}, src_time = INT},
}) })
wrench:register_node("technic:mv_centrifuge_active", { wrench:register_node("technic:mv_centrifuge_active", {
lists = {"src", "dst", "upgrade1", "upgrade2"}, lists = {"src", "dst", "upgrade1", "upgrade2", "upgrades"},
metas = {infotext = STRING, metas = {infotext = STRING,
formspec = STRING, formspec = STRING,
MV_EU_demand = INT, MV_EU_demand = INT,