1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-09 13:37:02 +02:00

charging station and rpg small fixes

This commit is contained in:
hanakocz 2020-07-24 10:20:03 +02:00
parent 594c850839
commit f6aaecdf36
2 changed files with 8 additions and 4 deletions

View File

@ -23,7 +23,7 @@ local function discharge_accumulators(surface, position, force, power_needs)
accu.energy = accu.energy - 2000000
power_needs = power_needs - 2000000
else
power_drained = power_needs
power_drained = power_drained + power_needs
accu.energy = accu.energy - power_needs
end
elseif power_needs <= 0 then
@ -43,12 +43,16 @@ local function charge(player)
if not grid or not grid.valid then return end
local equip = grid.equipment
for _,piece in pairs(equip) do
if piece.valid then
if piece.valid and piece.generator_power == 0 then
local energy_needs = piece.max_energy - piece.energy
if energy_needs > 0 then
local energy = discharge_accumulators(player.surface, player.position, player.force, energy_needs)
if energy > 0 then
piece.energy = piece.energy + energy
if piece.energy + energy >= piece.max_energy then
piece.energy = piece.max_energy
else
piece.energy = piece.energy + energy
end
end
end
end

View File

@ -2509,7 +2509,7 @@ function Public.gain_xp(player, amount, added_to_pool, text)
if not added_to_pool then
Public.debug_log('RPG - ' .. player.name .. ' got org xp: ' .. amount)
local fee = add_to_global_pool(amount, true)
local fee = amount - add_to_global_pool(amount, true)
Public.debug_log('RPG - ' .. player.name .. ' got fee: ' .. fee)
amount = math.round(amount, 3) - fee
if rpg_extra.difficulty then