Page 1 of 1

[1.0.0] resource.deplete() destroys infinite resources

Posted: Mon Oct 19, 2020 3:01 pm
by Mylon
Summary:
entity.deplete() deletes infinite resources

To recreate: mouse over a patch of oil and do
/c game.player.selected.deplete()

What happened:
Resource is destroyed.

What was expected:
Resource remains. Is set to depletion amount.

Re: [1.0.0] resource.deplete() destroys infinite resources

Posted: Mon Oct 19, 2020 3:07 pm
by Loewchen
Seems intended, https://lua-api.factorio.com/latest/Lua ... ty.deplete:
deplete() Depletes and destroys this resource entity.

Re: [1.0.0] resource.deplete() destroys infinite resources

Posted: Mon Oct 19, 2020 3:11 pm
by boskid
Ref 83231 (where it was requested).
I think it makes more sense if it is possible to deplete infinite resources, as that way the script itself can check if resource is infinite or not and decide if it wants to deplete it or not. Other reasoning would be this function removes exactly the amount that was left which in this case is infinite and leaves it at 0 :)

Re: [1.0.0] resource.deplete() destroys infinite resources

Posted: Mon Oct 19, 2020 3:13 pm
by steinio
boskid wrote:
Mon Oct 19, 2020 3:11 pm
Ref 83231 (where it was requested).
I think it makes more sense if it is possible to deplete infinite resources, as that way the script itself can check if resource is infinite or not and decide if it wants to deplete it or not. Other reasoning would be this function removes exactly the amount that was left which in this case is infinite and leaves it at 0 :)
Sounds reasonable... forever 0/s

Re: [1.0.0] resource.deplete() destroys infinite resources

Posted: Mon Oct 19, 2020 3:48 pm
by Rseding91
Thanks for the report however that's fully working as intended. Additionally you're the one who requested it to work exactly as it does.

If you don't want it to destroy the resource then don't call it :P The whole purpose of the function is to do exactly what it does.

Re: [1.0.0] resource.deplete() destroys infinite resources

Posted: Mon Oct 19, 2020 7:42 pm
by Mylon
Infinite resources can still deplete (and they fire the related event) without being destroyed via normal gameplay. I may have mistated my original request, but the goal was to recreate the vanilla behavior.