[solved] Prevent item from ever going in an invetory?

Place to get help with not working mods / modding interface.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

[solved] Prevent item from ever going in an invetory?

Post by aubergine18 »

EDIT: Solution = viewtopic.php?p=213673#p213673

I have a specific item that I want to prevent from ever finding its way in to any inventory. Is there any way to do that?

Background infos:

When player uses item X to build entity X, I clear the cursor stack and replace it with item Y (the counterpart to X).

This is the only way that Y comes in to existence.

If player uses item Y to build entity Y then the item Y no longer exists. Mining entity Y yields item X, so no problem there.

The problem arises when player clears or changes their cursor stack whilst holding item Y... they end up with an item Y in their inventory or quick bar. There is also the issue that player could put the item Y in to a container.

So I have this edge case that enables item Y to go in to any inventory, and I'm pulling my hair out trying to find a decent way to avoid that from happening.

Removing it from player main inventory or quickbar isn't too painful - I know what they are holding in advance, so when inventory change events are triggered I know I need to check for it.

But what if they put it in vehicle? What if they drop it on ground (Z key)? What if they put it in container?

Is there some way I can either prevent it from ever going in inventories...?
Last edited by aubergine18 on Mon Oct 10, 2016 2:03 am, edited 1 time in total.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Prevent item from ever going in an invetory?

Post by Nexela »

I dealt with this for about 5 hours before pulling my hair out and saying forget this. It got way to hacky. Without something like on_player_transfered_item (player, target_inv -->luainventory) it wasn't worth it to keep digging into.
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Prevent item from ever going in an invetory?

Post by aubergine18 »

Yup, it's pretty complex situation :/

I've now got what appears to be 100% reliable detection of _when_ the issue occurs. Now I just need to find where the item went and eradicate it (or put it back in cursor stack).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Post Reply

Return to “Modding help”