ShadowNinja
2014-12-15 5382a88aefbd503c00500236510412e6f2b42f4e
Fix some global errors
2 files modified
20 ■■■■■ changed files
technic/machines/register/battery_box.lua 17 ●●●● patch | view | raw | blame | history
technic/machines/register/common.lua 3 ●●●● patch | view | raw | blame | history
technic/machines/register/battery_box.lua
@@ -212,20 +212,19 @@
    if inv:is_empty("src") then
        return batt_charge, false
    end
    local srcstack = inv:get_stack("src", 1)
    local src_stack = inv:get_stack("src", 1)
    local toolname = srcstack:get_name()
    if not technic.power_tools[toolname] then
    local tool_name = src_stack:get_name()
    if not technic.power_tools[tool_name] then
        return batt_charge, false
    end
    -- Set meta data for the tool if it didn't do it itself
    src_meta = minetest.deserialize(srcstack:get_metadata())
    src_meta = src_meta or {}
    local src_meta = minetest.deserialize(src_stack:get_metadata()) or {}
    if not src_meta.charge then
        src_meta.charge = 0
    end
    -- 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
    if tool_charge >= item_max_charge then
        return batt_charge, true
@@ -236,10 +235,10 @@
    charge_step = math.min(charge_step, item_max_charge - tool_charge)
    tool_charge = tool_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
    srcstack:set_metadata(minetest.serialize(src_meta))
    inv:set_stack("src", 1, srcstack)
    src_stack:set_metadata(minetest.serialize(src_meta))
    inv:set_stack("src", 1, src_stack)
    return batt_charge, (tool_charge == item_max_charge)
end
technic/machines/register/common.lua
@@ -105,8 +105,7 @@
    if minetest.get_item_group(node1.name, "tubedevice") > 0 then
        output_tube_connected = true
    end
    tube_time = meta:get_int("tube_time")
    tube_time = tube_time + tube_upgrade
    local tube_time = meta:get_int("tube_time") + tube_upgrade
    if tube_time >= 2 then
        tube_time = 0
        if output_tube_connected then