mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
Adding extra valid check for battery recharge (#356)
* Update bonus.lua * Update bonus.lua * Update bonus.lua * Update bonus.lua * Update bonus.lua
This commit is contained in:
@@ -75,15 +75,18 @@ local function apply_periodic_bonus(player)
|
||||
local disp = frame.container["bonus_st_2"].disp.table
|
||||
|
||||
if vlayer.get_statistics()["energy_sustained"] > 0 then
|
||||
local armor = player.get_inventory(defines.inventory.character_armor)[1].grid
|
||||
local armor = player.get_inventory(defines.inventory.character_armor)
|
||||
|
||||
if armor then
|
||||
if armor and armor[1] and armor[1].valid_for_read and armor[1].grid then
|
||||
local armor_grid = armor[1].grid
|
||||
|
||||
if armor_grid and armor_grid.available_in_batteries and armor_grid.battery_capacity and armor_grid.available_in_batteries < armor_grid.battery_capacity then
|
||||
local slider = disp["bonus_display_personal_battery_recharge_slider"].slider_value * 100000 * config.player_special_bonus_rate / 6
|
||||
|
||||
for i = 1, #armor.equipment do
|
||||
if armor.equipment[i].energy < armor.equipment[i].max_energy then
|
||||
local energy_required = math.min(math.floor(armor.equipment[i].max_energy - armor.equipment[i].energy), vlayer.get_statistics()["energy_storage"], slider)
|
||||
armor.equipment[i].energy = armor.equipment[i].energy + energy_required
|
||||
for i = 1, #armor_grid.equipment do
|
||||
if armor_grid.equipment[i].energy < armor_grid.equipment[i].max_energy then
|
||||
local energy_required = math.min(math.floor(armor_grid.equipment[i].max_energy - armor_grid.equipment[i].energy), vlayer.get_statistics()["energy_storage"], slider)
|
||||
armor_grid.equipment[i].energy = armor_grid.equipment[i].energy + energy_required
|
||||
vlayer.energy_changed(-energy_required)
|
||||
|
||||
slider = slider - energy_required
|
||||
@@ -92,6 +95,7 @@ local function apply_periodic_bonus(player)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Control label for the bonus points available
|
||||
-- @element bonus_gui_control_pts_a
|
||||
|
||||
Reference in New Issue
Block a user