[Not Implemented] LuaControl.insert but don't insert modules

Things that we aren't going to implement
Post Reply
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

[Not Implemented] LuaControl.insert but don't insert modules

Post by Mooncat »

Original title: LuaControl.insert, but don't insert to module inventory
But it won't work.

---------

Request:
Either add an additional parameter in LuaControl.insert or make a new function to let us insert items into entity while ensuring the items won't go to the module inventory.
Also the corresponding LuaControl.can_insert parameter or function.

Currently, LuaControl.insert will insert modules into module inventory if the input inventory is full. This is not how inserter behaves. We can avoid that by using the current APIs, but it is just very troublesome and not efficient (either hardcode what input inventories each entity type has, or iterate all available inventories and ignore module inventory).
Last edited by Mooncat on Tue Aug 15, 2017 2:23 am, edited 3 times in total.

User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5150
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: LuaControl.insert, but don't insert to module inventory

Post by Klonan »

Mooncat wrote:Request:
Either add an additional parameter in LuaControl.insert or make a new function to let us insert items into entity while ensuring the items won't go to the module inventory.
Also the corresponding LuaControl.can_insert parameter or function.

Currently, LuaControl.insert will insert modules into module inventory if the input inventory is full. This is not how inserter behaves. We can avoid that by using the current APIs, but it is just very troublesome and not efficient (either hardcode what input inventories each entity type has, or iterate all available inventories and ignore module inventory).
That seems awfully specific, for something which has some very easy ways to already do with the current API

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: LuaControl.insert, but don't insert to module inventory

Post by Mooncat »

Klonan wrote:
Mooncat wrote:Request:
Either add an additional parameter in LuaControl.insert or make a new function to let us insert items into entity while ensuring the items won't go to the module inventory.
Also the corresponding LuaControl.can_insert parameter or function.

Currently, LuaControl.insert will insert modules into module inventory if the input inventory is full. This is not how inserter behaves. We can avoid that by using the current APIs, but it is just very troublesome and not efficient (either hardcode what input inventories each entity type has, or iterate all available inventories and ignore module inventory).
That seems awfully specific, for something which has some very easy ways to already do with the current API
But there are already many functions that can only perform very specific actions, which also have alternative ways to do.
Like, LuaControl.clear_items_inside, or well, all item-related functions in LuaControl, as we can get the inventories and use their functions instead. So why not add a new function that is currently NOT in LuaControl or LuaInventory?

Back to my request, as I said, the current implementation is either troublesome or inefficient. Even if we have implemented, we will need to duplicate the snippet for other mods that do the same thing. I think we all know this is bad. As this behaviour is already in vanilla game, I don't see why this shouldn't be in modding API, unless it will take you guys much time to implement. But shouldn't it be just an interface calling to your original C++ function?

If it is really difficult to implement, give it a low priority, but please don't ignore/reject it. Good modding API should give mods the ability to be as vanilla-like as possible. :mrgreen:

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

Re: LuaControl.insert, but don't insert to module inventory

Post by Rseding91 »

In fact inserters will transfer into the module inventory of a machine should the input slots become full by the time it starts to drop the module. The exact same logic runs when you call transfer(...) that runs when an inserter transfers items into a non-belt entity.

If you don't want to transfer into what ever inventory can hold the item you need to use get_inventory(...) and transfer directly into that.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: LuaControl.insert, but don't insert to module inventory

Post by Mooncat »

Rseding91 wrote:In fact inserters will transfer into the module inventory of a machine should the input slots become full by the time it starts to drop the module. The exact same logic runs when you call transfer(...) that runs when an inserter transfers items into a non-belt entity.

If you don't want to transfer into what ever inventory can hold the item you need to use get_inventory(...) and transfer directly into that.
:o But...but.... but the inserter automatically stops working when the assembling machines have got enough modules in its input slot....
Oh! So the problem is not in the function for inserting items, but in the function that lets inserters detect how many ingredients are needed by its target?

How about this:
LuaEntity.get_input_items() :: dictionary string → uint [R]
Returns the fuels, ingredients, repair tools, science pack, satellites, etc. anything that can be inserted automatically by inserters, that this machine currently can take.

(Found the problem of this request. Simply don't know which fuel or repair tool is wanted.)


Edit: and could you explain, if I changed the Effective module 2 recipe to take 99x Effective module 1, why the assembling machine can take up to 242x module 1 in its input slot? :?
Why not the multiples of 50 (stack size) or 99 (ingredient count)?
Last edited by Mooncat on Mon Aug 14, 2017 2:49 pm, edited 1 time in total.

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

Re: LuaControl.insert, but don't insert to module inventory

Post by Rseding91 »

The assembling machine allows the input slots to exceed the stack limits so you can always craft a given recipe.

You can detect what a given recipe needs by reading the recipe and looking at the ingredients.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1190
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: LuaControl.insert, but don't insert to module inventory

Post by Mooncat »

Rseding91 wrote:The assembling machine allows the input slots to exceed the stack limits so you can always craft a given recipe.

You can detect what a given recipe needs by reading the recipe and looking at the ingredients.
I was thinking about a generic way that does not only work on assembling machines, but also furnaces, roboports, rocket silos...

Anyway, just found that even my second request won't work. So I guess I have no choice now but check the entity type first then get the corresponding inventory. :oops:

Thanks for your time. :mrgreen:

Post Reply

Return to “Won't implement”