Made my first mod but need advice on extra feature

Place to get help with not working mods / modding interface.
Post Reply
Immow
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Jan 16, 2022 4:36 pm
Contact:

Made my first mod but need advice on extra feature

Post 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 :)

Immow
Manual Inserter
Manual Inserter
Posts: 2
Joined: Sun Jan 16, 2022 4:36 pm
Contact:

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

Post by Immow »


InappropriatePenguin
Inserter
Inserter
Posts: 29
Joined: Mon Sep 13, 2021 6:53 pm
Contact:

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

Post 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.
Last edited by InappropriatePenguin on Sun Jan 23, 2022 7:44 pm, edited 1 time in total.

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 490
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

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

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

InappropriatePenguin
Inserter
Inserter
Posts: 29
Joined: Mon Sep 13, 2021 6:53 pm
Contact:

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

Post by InappropriatePenguin »

Ah, so I was missing something after all.

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

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

Post by darkfrei »

Can the hidden teleportation to the same place or to other surface and back to this one help in this situation?

Post Reply

Return to “Modding help”