[0.13.9] [Twinsen] inserter with condition change behavior with stack bonus

This subforum contains all the issues which we already resolved.
Post Reply
gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

[0.13.9] [Twinsen] inserter with condition change behavior with stack bonus

Post by gheift »

Hello,

I have two inserters connected to a circuit network, the left one has the condition anything > 0, the right one everything = 0. Both inserters read their hand content in pulse mode. The decider has the condition everything < 3.
0.13.9_inserter_with_stack_bonus_holds_item_forever_1.png
0.13.9_inserter_with_stack_bonus_holds_item_forever_1.png (74.81 KiB) Viewed 6107 times
With this build I can split the items 2:1. Without stack bonus, all values in the circuit network are initially zero, the right inserter grabs an item, gives the signal over the network and moves the item to the chest. The combinator will hold this signal through the loop and the right inserter will not grab any more item, because its condition is not satisfied any more. This is the behavior I expected.

When stack bonus 2 is researched, the right inserter grabs the first item and gives the signal to the network, where it is hold. Since the condition is not satisfied any more, the inserter does not grab any more items, like I expect it. But it neither moves the item, which it has already grabbed, to the box, it just holds it forever. I expect it to move the grabbed item to the box.
0.13.9_inserter_with_stack_bonus_holds_item_forever_2.png
0.13.9_inserter_with_stack_bonus_holds_item_forever_2.png (82.8 KiB) Viewed 6107 times
Thanks,
Gerhard

BlakeMW
Filter Inserter
Filter Inserter
Posts: 950
Joined: Thu Jan 21, 2016 9:29 am
Contact:

Re: [0.13.9] inserter with condition change behavior with stack bonus

Post by BlakeMW »

Hmm, I've studied this in significant detail. There are basically 3 ways of switching an inserter:

1) Use an enabled/disabled condition
2) Use "set filters" on a filter inserter
3) Use the power switch to cut power.

All three work differently.

Enabled Condition puts the inserter in "suspended animation", once it reactivates it will resume what it was doing, for example if it was picking up items, it'll keep picking up items.
"Set Filters" causes the inserter to immediately drop its load if the new filters are incompatible with what it is holding and swing back into position.
Cutting electricity seems to freeze the inserter in place and also resets it if the power cut lasts longer than about 30 ticks, it forgets what it was doing and when it is powered back on it will dump its load and resume normal activity. This is unlike the suspended animation of enabled/disabled condition.

It didn't occur to me that the "suspended animation" behaviour is a bug, but now I think about it, it probably would be more useful if a "disabled" inserter immediately drops its load and then swings back into position before ceasing activity.
Last edited by BlakeMW on Tue Jul 19, 2016 8:41 am, edited 2 times in total.

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

Re: [0.13.9] inserter with condition change behavior with stack bonus

Post by Klonan »

Thanks for the report,

Can you post a save where you have the setup so i can reproduce and confirm it?

BlakeMW
Filter Inserter
Filter Inserter
Posts: 950
Joined: Thu Jan 21, 2016 9:29 am
Contact:

Re: [0.13.9] [Pending] inserter with condition change behavior with stack bonus

Post by BlakeMW »

suspended animation is really easy to demonstrate: Just wire an inserter to a power pole and use "Enabled: Everything = 0", and "Read hand contents: Hold". If there is inserter capacity bonus then the result is an inserter which can pick up a single item and never put it down because it still wants to fill its hand.

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: [0.13.9] [Pending] inserter with condition change behavior with stack bonus

Post by gheift »

Created a testcase. Just connect the belts. The upper one puts one copper into the chest, the lower stack inserter grabs one copper and holds it forever.
Attachments
stack_inserter_condition.zip
(4.18 MiB) Downloaded 91 times

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: [0.13.9] inserter with condition change behavior with stack bonus

Post by gheift »

BlakeMW wrote:Enabled Condition puts the inserter in "suspended animation", once it reactivates it will resume what it was doing, for example if it was picking up items, it'll keep picking up items.
The inserter is only suspended in its animation, if it has a stack bonus. If it only grabs one item (because there is no stack bonus), it will put the grabbed item to its destination regardless if the condition is met or not.

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

Re: [0.13.9] [Pending] inserter with condition change behavior with stack bonus

Post by Klonan »

Thanks for the report,

I have confirmed the odd behaviour:


XKnight
Filter Inserter
Filter Inserter
Posts: 329
Joined: Thu May 28, 2015 10:40 pm
Contact:

Re: [0.13.9] [Twinsen] inserter with condition change behavior with stack bonus

Post by XKnight »

This bug report is going to be an incredibly important.
Looking forward to this fix.

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: [0.13.9] [Twinsen] inserter with condition change behavior with stack bonus

Post by gheift »

It gets even more wired. After I build this setup, I research inserter-capacity-bonus 1 & 2 and build another one. So top right built before research, top left built after research. The right one was not activated/used after building it. Now connect both belts. The left one will hold the item, the right one will put it into the chest for the first time. After this, the right inserter behave like the left one.
Attachments
stack_inserter_condition_3.zip
(4.36 MiB) Downloaded 86 times

Twinsen
Factorio Staff
Factorio Staff
Posts: 1330
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [0.13.9] [Twinsen] inserter with condition change behavior with stack bonus

Post by Twinsen »

Fixed in Version: 0.13.12
Thanks for the saves.
gheift wrote:It gets even more wired. After I build this setup, I research inserter-capacity-bonus 1 & 2 and build another one. So top right built before research, top left built after research. The right one was not activated/used after building it. Now connect both belts. The left one will hold the item, the right one will put it into the chest for the first time. After this, the right inserter behave like the left one.
This is due to the minor issue that the inserter's stack bonus gets updated after it moves one item, thus the old inserter has no stack bonus for the first item. But the situation in your save is no longer visible since the bug from this topic was fixed.

gheift
Fast Inserter
Fast Inserter
Posts: 188
Joined: Tue Mar 03, 2015 9:20 pm
Contact:

Re: [0.13.9] [Twinsen] inserter with condition change behavior with stack bonus

Post by gheift »

Twinsen wrote:Fixed in Version: 0.13.12
Thanks!
Twinsen wrote:This is due to the minor issue that the inserter's stack bonus gets updated after it moves one item, thus the old inserter has no stack bonus for the first item. But the situation in your save is no longer visible since the bug from this topic was fixed.
This is quite interesting. Why has each inserter its private stack bonus stored? I don't see any possibility to modify the stack bonus of an inserter beside the prototype and research, or is it planned to make it configurable by mods/circuit network?

I only want to understand the reason behind this. I interpret your current work flow as something like this:

Code: Select all

struct inserter {
   /* ... */
   struct prototype *prototype;
   struct entity *src;
   struct entity *dst;

   int stack_bonus;
   int stack_size;
   int wait_until;
};
struct prototype {
   /* ... */
   int stack_bonus;
};

wait_until_somthing_is_needed(inserter);
grab_from_src_wait(inserter); /* updates stack_size */
if (inserter->src->is_belt)
    while (inserter->wait_until >= game->tick && inserter->stack_size < inserter->stack_bonus) {
        grab_from_belt(inserter); /* updates stack_size & wait_until */
    }
rotate_to_dst(inserter);
put_into_dst(inserter);
rotate_to_src(inserter);
inserter->stack_bonus = inserter->prototype->stack_bonus;
Wouldn't it be easier to lookup the stack_bonus directly in the prototype?

Code: Select all

while (inserter->wait_until >= game->tick && inserter->stack_size < inserter->prototype->stack_bonus) {
    grab_from_belt(inserter); /* updates stack_size & wait_until */
}

Post Reply

Return to “Resolved Problems and Bugs”