mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 11:35:22 +09:00
Add auto personal battery recharge (#327)
* Update bonus.lua * Update vlayer.lua * Update roles.lua * Update gui.cfg * Update gui.cfg * Update gui.cfg * Update bonus.lua * Update bonus.lua * Update bonus.lua * Update bonus.lua * Update vlayer.lua * Update bonus.lua * Update bonus.lua * Update bonus.lua
This commit is contained in:
@@ -5,28 +5,6 @@ local Commands = require 'expcore.commands' --- @dep expcore.commands
|
||||
require 'config.expcore.command_general_parse'
|
||||
local vlayer = require 'modules.control.vlayer'
|
||||
|
||||
Commands.new_command('personal-battery-recharge', {'vlayer.description-pbr'}, 'Recharge Player Battery upto a portion with vlayer')
|
||||
:add_param('amount', 'number-range', 0.2, 1)
|
||||
:register(function(player, amount)
|
||||
if vlayer.get_statistics()['energy_sustained'] == 0 then
|
||||
return Commands.error({'vlayer.pbr-not-running'})
|
||||
end
|
||||
|
||||
local armor = player.get_inventory(defines.inventory.character_armor)[1].grid
|
||||
|
||||
for i=1, #armor.equipment do
|
||||
local target = math.floor(armor.equipment[i].max_energy * amount)
|
||||
|
||||
if armor.equipment[i].energy < target then
|
||||
local energy_required = math.min(math.floor(target - armor.equipment[i].energy), vlayer.get_statistics()['energy_storage'])
|
||||
armor.equipment[i].energy = armor.equipment[i].energy + energy_required
|
||||
vlayer.energy_changed(- energy_required)
|
||||
end
|
||||
end
|
||||
|
||||
return Commands.success
|
||||
end)
|
||||
|
||||
Commands.new_command('vlayer-info', {'vlayer.description-vi'}, 'Vlayer Info')
|
||||
:register(function(_)
|
||||
local c = vlayer.get_circuits()
|
||||
|
||||
Reference in New Issue
Block a user