[1.0.0] resource.deplete() destroys infinite resources

Bugs that are actually features.
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 525
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

[1.0.0] resource.deplete() destroys infinite resources

Post 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.
Loewchen
Global Moderator
Global Moderator
Posts: 9557
Joined: Wed Jan 07, 2015 5:53 pm
Contact:

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

Post by Loewchen »

Seems intended, https://lua-api.factorio.com/latest/Lua ... ty.deplete:
deplete() Depletes and destroys this resource entity.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3290
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

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

Post 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 :)
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

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

Post 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
Image

Transport Belt Repair Man

View unread Posts
Rseding91
Factorio Staff
Factorio Staff
Posts: 14598
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Mylon
Filter Inserter
Filter Inserter
Posts: 525
Joined: Sun Oct 23, 2016 11:42 pm
Contact:

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

Post 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.
Post Reply

Return to “Not a bug”