forked from minetest-mods/technic
Fix some global errors
This commit is contained in:
parent
a413904ecd
commit
5382a88aef
@ -212,20 +212,19 @@ function technic.charge_tools(meta, batt_charge, charge_step)
|
|||||||
if inv:is_empty("src") then
|
if inv:is_empty("src") then
|
||||||
return batt_charge, false
|
return batt_charge, false
|
||||||
end
|
end
|
||||||
local srcstack = inv:get_stack("src", 1)
|
local src_stack = inv:get_stack("src", 1)
|
||||||
|
|
||||||
local toolname = srcstack:get_name()
|
local tool_name = src_stack:get_name()
|
||||||
if not technic.power_tools[toolname] then
|
if not technic.power_tools[tool_name] then
|
||||||
return batt_charge, false
|
return batt_charge, false
|
||||||
end
|
end
|
||||||
-- Set meta data for the tool if it didn't do it itself
|
-- Set meta data for the tool if it didn't do it itself
|
||||||
src_meta = minetest.deserialize(srcstack:get_metadata())
|
local src_meta = minetest.deserialize(src_stack:get_metadata()) or {}
|
||||||
src_meta = src_meta or {}
|
|
||||||
if not src_meta.charge then
|
if not src_meta.charge then
|
||||||
src_meta.charge = 0
|
src_meta.charge = 0
|
||||||
end
|
end
|
||||||
-- Do the charging
|
-- Do the charging
|
||||||
local item_max_charge = technic.power_tools[toolname]
|
local item_max_charge = technic.power_tools[tool_name]
|
||||||
local tool_charge = src_meta.charge
|
local tool_charge = src_meta.charge
|
||||||
if tool_charge >= item_max_charge then
|
if tool_charge >= item_max_charge then
|
||||||
return batt_charge, true
|
return batt_charge, true
|
||||||
@ -236,10 +235,10 @@ function technic.charge_tools(meta, batt_charge, charge_step)
|
|||||||
charge_step = math.min(charge_step, item_max_charge - tool_charge)
|
charge_step = math.min(charge_step, item_max_charge - tool_charge)
|
||||||
tool_charge = tool_charge + charge_step
|
tool_charge = tool_charge + charge_step
|
||||||
batt_charge = batt_charge - charge_step
|
batt_charge = batt_charge - charge_step
|
||||||
technic.set_RE_wear(srcstack, tool_charge, item_max_charge)
|
technic.set_RE_wear(src_stack, tool_charge, item_max_charge)
|
||||||
src_meta.charge = tool_charge
|
src_meta.charge = tool_charge
|
||||||
srcstack:set_metadata(minetest.serialize(src_meta))
|
src_stack:set_metadata(minetest.serialize(src_meta))
|
||||||
inv:set_stack("src", 1, srcstack)
|
inv:set_stack("src", 1, src_stack)
|
||||||
return batt_charge, (tool_charge == item_max_charge)
|
return batt_charge, (tool_charge == item_max_charge)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -105,8 +105,7 @@ function technic.handle_machine_pipeworks(pos, tube_upgrade, send_function)
|
|||||||
if minetest.get_item_group(node1.name, "tubedevice") > 0 then
|
if minetest.get_item_group(node1.name, "tubedevice") > 0 then
|
||||||
output_tube_connected = true
|
output_tube_connected = true
|
||||||
end
|
end
|
||||||
tube_time = meta:get_int("tube_time")
|
local tube_time = meta:get_int("tube_time") + tube_upgrade
|
||||||
tube_time = tube_time + tube_upgrade
|
|
||||||
if tube_time >= 2 then
|
if tube_time >= 2 then
|
||||||
tube_time = 0
|
tube_time = 0
|
||||||
if output_tube_connected then
|
if output_tube_connected then
|
||||||
|
Loading…
Reference in New Issue
Block a user