Page 1 of 1

[Question] How to prevent automatically taking items?

Posted: Mon May 21, 2018 12:30 am
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).

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

Posted: Mon May 21, 2018 9:43 am
by bobingabout
I don't know... I don't think there is a method for this.

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

Posted: Tue May 22, 2018 1:25 am
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?

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

Posted: Tue May 22, 2018 9:03 am
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.

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

Posted: Wed May 23, 2018 1:44 am
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...

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

Posted: Fri Jun 01, 2018 7:28 am
by BenSeidel
whenever an inserter is built, check if it's attached to your machine and if it is, disable it.

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

Posted: Fri Jun 01, 2018 4:14 pm
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.

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

Posted: Sat Jun 02, 2018 5:03 am
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?

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

Posted: Sat Jun 02, 2018 9:12 am
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.