Page 1 of 1

Made my first mod but need advice on extra feature

Posted: Sun Jan 16, 2022 4:49 pm
by Immow
Hi everyone, I made my first mod with help (/me waves @KRS) but I want some extra features that I'm not sure about how to implement.
The mod in question is https://mods.factorio.com/mod/dumpchest
The goal of this mod is to dump your trash slot items in a active provider chest(s) near the player. I made this because sometimes you just want to quickly "dump" your items and get on with it, instead of waiting for your bots.

The problem is that after item transfer the bot's still fly towards the player, is there a way to make them cancel their "trash pickup" job.
Some idea's that spring to mind are:
- In the jetpack mod when you fly up the bots "stop" for a short moment, I think this is because the player that lifts off is a new entity?
- A way to turn off the player logistics capabilities for a short moment.

Thanks :)

Re: Made my first mod but need advice on extra feature

Posted: Sun Jan 23, 2022 1:22 pm
by Immow

Re: Made my first mod but need advice on extra feature

Posted: Sun Jan 23, 2022 2:09 pm
by InappropriatePenguin
Took a peek at your code, and unless I'm missing something, it seems like you're replicating the items in the character's trash inventory and placing them in nearby active provider chests, but you're not ever actually deleting them from the trash inventory.

When you iterate over trash_inventory, you're copying its contents to your own trash_to_clean table. Later on, when you're subtracting item counts, you're doing it with your own copy of the data, so that will have no influence on the actual LuaInventory you meant to manipulate.

Since the items are still in your trash inventory, the bots will continue towards you to pick them up.
Nevermind, see below.

Re: Made my first mod but need advice on extra feature

Posted: Sun Jan 23, 2022 3:55 pm
by Silari
Indexing operator on an inventory gives out LUAItemStack instances - trash_to_clean is just holding references to those and calling their attributes, which works fine. A quick test confirms mod is working as expected.
Immow wrote: Sun Jan 16, 2022 4:49 pmThe problem is that after item transfer the bot's still fly towards the player, is there a way to make them cancel their "trash pickup" job.
This is a problem with vanilla Factorio, not the mod. Robots don't get any notifications if the contents of the trash slots change, so they just keep flying until they reach the character and finally check the inventory to see there's nothing there. This happens even if you move things out of your trash slots by hand, or if you take things out of logistic chests. Not aware of any way to solve it other than removing the character and replacing it with a new one (which is what jetpack does to remove the collision), which does tell the robots to stop, but is probably overcomplicated for this.

Re: Made my first mod but need advice on extra feature

Posted: Sun Jan 23, 2022 7:44 pm
by InappropriatePenguin
Ah, so I was missing something after all.

Re: Made my first mod but need advice on extra feature

Posted: Mon Jan 24, 2022 8:13 am
by darkfrei
Can the hidden teleportation to the same place or to other surface and back to this one help in this situation?