[Question] How to prevent automatically taking items?
[Question] How to prevent automatically taking items?
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).
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [Question] How to prevent automatically taking items?
I don't know... I don't think there is a method for this.
Re: [Question] How to prevent automatically taking items?
Is it possible to make its selection box smaller than its build collision? Or would that not do what I want it to?
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: [Question] How to prevent automatically taking items?
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?
Bummer...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.
Re: [Question] How to prevent automatically taking items?
whenever an inserter is built, check if it's attached to your machine and if it is, disable it.
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Question] How to prevent automatically taking items?
I think OP still wants to put stuff into the machine though?BenSeidel wrote:whenever an inserter is built, check if it's attached to your machine and if it is, disable it.
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)
Re: [Question] How to prevent automatically taking items?
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?
- eradicator
- Smart Inserter
- Posts: 5211
- Joined: Tue Jul 12, 2016 9:03 am
- Contact:
Re: [Question] How to prevent automatically taking items?
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.