Page 1 of 1

[Klonan] [15.20] robots_battery_modifier doesn't increase energy max

Posted: Thu Jun 15, 2017 2:08 am
by Dustine
It seems that LuaForces::worker_robots_battery_modifier is restricted by max_energy and only affects the initial energy for when a robot entity is spawned, which if intended behaviour (seems so, but...) leads to some really weird behaviour. As in (replication steps):
  1. Start a brand new world (no mods needed, vanilla is enough to replicate)
  2. Run the following to increase a robot's storage from 1.5MJ to 3MJ (+100%)

    Code: Select all

    /c game.player.force.worker_robots_battery_modifier = 1
  3. Spawn a construction-robot (without any roboport around) and select it (notice it'll most likely be at 2.9MJ)
  4. Run the following to attempt to charge a bot to its initial charge

    Code: Select all

    /c game.player.selected.energy = 3000000
  5. Notice that the robot's charge instantly drained to 1.4MJ (1.5MJ with some idle drain)
This is troublesome because if any mod or script tries to change a bot's energy, it won't be able to make it resume its initial levels and instead be constrained by max_energy, leading to potential energy losses as above. I didn't add a savegame as this can be quickly replicated on the sandbox, hope that's okay.

Re: [Klonan] [15.20] robots_battery_modifier doesn't increase energy max

Posted: Fri Jun 16, 2017 2:31 pm
by Rseding91
Thanks, this should be fixed for the next version of 0.15.

Re: [Klonan] [15.20] robots_battery_modifier doesn't increase energy max

Posted: Fri Jun 16, 2017 9:25 pm
by Dustine
Rseding91 wrote:Thanks, this should be fixed for the next version of 0.15.
Thank you so much for the quick fix!