mirror of
https://github.com/OgelGames/powerbanks.git
synced 2024-08-20 13:34:04 +02:00
add nil check to fix #6
This commit is contained in:
parent
7f31c77d1c
commit
81ff5aca6c
4
init.lua
4
init.lua
@ -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_max_charge = technic.power_tools[item:get_name()]
|
||||||
local item_charge = item_meta.charge
|
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)
|
charge_step = math.min(charge_step, item_max_charge - item_charge, powerbank_charge)
|
||||||
item_charge = item_charge + charge_step
|
item_charge = item_charge + charge_step
|
||||||
powerbank_charge = powerbank_charge - charge_step
|
powerbank_charge = powerbank_charge - charge_step
|
||||||
|
Loading…
Reference in New Issue
Block a user