[Question] How to prevent automatically taking items?

Place to get help with not working mods / modding interface.
Post Reply
donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

[Question] How to prevent automatically taking items?

Post by donoya »

Is there some way to make a crafting machine that can only be extracted from by players? Because I've been thinking of adding a machine for a mod (which can be replaced with a fully automate-able one, later) that only the player can take items out of. Some might see this as a poor design choice, but logically, you can't handle living workers (AKA the item that this machine makes) with a mechanized inserter. So that's the reason for my question. Is it possible with the current API? I'm okay with learning scripting if that's what's necessary, but I still have a pretty limited understanding of the code (and lua-based game modding in general, for that matter).

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [Question] How to prevent automatically taking items?

Post by bobingabout »

I don't know... I don't think there is a method for this.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Re: [Question] How to prevent automatically taking items?

Post by donoya »

Is it possible to make its selection box smaller than its build collision? Or would that not do what I want it to?

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: [Question] How to prevent automatically taking items?

Post by bobingabout »

erm... no, I think the selection box is just what the game shows you, the player, and all interactions are done directly with the collision box.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Re: [Question] How to prevent automatically taking items?

Post by donoya »

bobingabout wrote:erm... no, I think the selection box is just what the game shows you, the player, and all interactions are done directly with the collision box.
Bummer...

BenSeidel
Filter Inserter
Filter Inserter
Posts: 584
Joined: Tue Jun 28, 2016 1:44 am
Contact:

Re: [Question] How to prevent automatically taking items?

Post by BenSeidel »

whenever an inserter is built, check if it's attached to your machine and if it is, disable it.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Question] How to prevent automatically taking items?

Post by eradicator »

BenSeidel wrote:whenever an inserter is built, check if it's attached to your machine and if it is, disable it.
I think OP still wants to put stuff into the machine though?

Code: Select all

script.on_events({
 defines.events.on_built_entity,
 defines.events.on_player_rotated_entity,
 on_robot_built_entity},
 function(event)
  local ent = event.entity or event.created_entity
  if ent.type == 'inserter' then
   if ent.pickup_target.name == 'my_machine_name' then
    ent.active = false
   else
    ent.active = true
    end
   end
  end)
Though if any other mod also disabled inserters for..whatever reason, there may be situations where you accidentially enable an inserter that you're not supposed to activate.

donoya
Fast Inserter
Fast Inserter
Posts: 119
Joined: Thu Dec 04, 2014 10:55 pm
Contact:

Re: [Question] How to prevent automatically taking items?

Post by donoya »

Can I just make a structure that opens an' item exchange GUI' (for lack of a better term) for the 'assembled' item when the player right clicks it? Or can such a thing exist? And also, can it be given a cooldown time for exchanging the items?

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: [Question] How to prevent automatically taking items?

Post by eradicator »

Yes, you can replace the GUI (which is left click in factorio, not right click) of any arbitrary machine with whatever you like, if you're into heavy scripting. That won't prevent inserters from taking stuff out though.

Post Reply

Return to “Modding help”