[1.1.76] LuaControl.mine_entity(entity, force?) doesn't check if mined_result can't be added to inventory if force=false

Bugs that are actually features.
Post Reply
LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

[1.1.76] LuaControl.mine_entity(entity, force?) doesn't check if mined_result can't be added to inventory if force=false

Post by LeonSkills »

LuaControl.mine_entity(entity, force?) mentions it will fail if it can't place the items of the entity into the inventory of the LuaControl when force is set to false. (Or at least, that behaviour is implied by the description of when force is true).

These items it checks do not include the mined_result of the entity, only its inventories.

How to reproduce:
Run this in the console with a full inventory while standing near some mineable entities.

Code: Select all

/c for _, entity in pairs(game.player.surface.find_entities_filtered{position=game.player.position, radius=10}) do
  game.player.mine_entity(entity, false)
end
Expected behaviour is that an entity is not mined if their mined result can not be stored in the player inventory, and the method returns false.
Current behaviour is that the entity is mined, if the mined result can not be stored in the player inventory it is spilled on the ground (the expected behaviour of when force is set to true).

It does seem to work as expected for item-on-ground entities, it returns false for them and doesn't reshuffle them around like what happens when force is true. (But they are already on the ground anyway, so doesn't really matter for that entity.)
Last edited by LeonSkills on Sat Jan 28, 2023 4:34 pm, edited 2 times in total.

lyvgbfh
Fast Inserter
Fast Inserter
Posts: 165
Joined: Fri Jul 10, 2020 6:48 pm
Contact:

Re: [1.1.76] LuaControl.mine_entity(entity, force?) seems to ignore the force parameter

Post by lyvgbfh »

Does it behave the same if force is nil (unspecified)?

LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

Re: [1.1.76] LuaControl.mine_entity(entity, force?) seems to ignore the force parameter

Post by LeonSkills »

lyvgbfh wrote:
Sat Jan 28, 2023 4:08 am
Does it behave the same if force is nil (unspecified)?
Default behaviour is equal to force=false

LeonSkills
Burner Inserter
Burner Inserter
Posts: 14
Joined: Mon Feb 11, 2019 12:37 pm
Contact:

Re: [1.1.76] LuaControl.mine_entity(entity, force?) seems to ignore the force parameter

Post by LeonSkills »

As someone has pointed out on discord, force applies to the items within the inventories of the to be mined entity, not the mined result of it.

If that is the desired behaviour then I guess the documentation should be updated to reflect that. However I still think the mined result should be included in the force check.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.76] LuaControl.mine_entity(entity, force?) seems to ignore the force parameter

Post by Rseding91 »

LeonSkills wrote:
Sat Jan 28, 2023 4:24 pm
As someone has pointed out on discord, force applies to the items within the inventories of the to be mined entity, not the mined result of it.
That is how it works.
If you want to get ahold of me I'm almost always on Discord.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [1.1.76] LuaControl.mine_entity(entity, force?) seems to ignore the force parameter

Post by Rseding91 »

LeonSkills wrote:
Sat Jan 28, 2023 4:24 pm
If that is the desired behaviour then I guess the documentation should be updated to reflect that. However I still think the mined result should be included in the force check.
Due to the nature of Factorio inventories and items knowing "can this set of items fit into this inventory" is currently only possible to know by actually trying to put it into the inventory. Because of that; we don't attempt to check if the mined results of an entity fit into the destination and instead just try to put them in. If that fails we put the items on the ground.
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Not a bug”