Skip to content

Commit

Permalink
add nil check to fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
OgelGames committed Oct 10, 2020
1 parent 7f31c77 commit 81ff5ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ local function charge_item(item, powerbank_charge, charge_step)
local item_max_charge = technic.power_tools[item:get_name()]
local item_charge = item_meta.charge

if not item_max_charge or not item_charge then
return item, powerbank_charge, true
end

charge_step = math.min(charge_step, item_max_charge - item_charge, powerbank_charge)
item_charge = item_charge + charge_step
powerbank_charge = powerbank_charge - charge_step
Expand Down

0 comments on commit 81ff5ac

Please sign in to comment.