Multi-armed inserters

This is the place to request new mods or give ideas about what could be done.
Post Reply
User avatar
bigyihsuan
Filter Inserter
Filter Inserter
Posts: 299
Joined: Thu Jan 01, 2015 12:57 pm
Contact:

Multi-armed inserters

Post by bigyihsuan »

This is simply an inserter that can out put to the left and right of it, along with the usual In front.

Also requesting fast, long, burner, smart, regular, etc. Versions of it, please!

User avatar
ThaPear
Fast Inserter
Fast Inserter
Posts: 226
Joined: Fri May 30, 2014 8:05 am
Contact:

Re: Multi-armed inserters

Post by ThaPear »

I have no idea why I expanded on this as much as I did. It was intended as a quick show of difficulty. :?

If you actually mean a single inserter with multiple arms, it is possible but requires control.lua programming.
It will also need adjustment for each different type of inserter (only one type supported as is).
It will only work with blueprints if you create the blueprint out of a ghost-placed tri-inserter-placer.

You'll need to make 4 entities:
tri-inserter-placer: Only used to allow the player to place the three-armed inserter.
tri-inserter-left: An inserter that outputs to the left.
tri-inserter-right: An inserter that outputs to the right.
tri-inserter-straight: An inserter that outputs to a mystery location.

The entities will need to have a mine result of tri-inserter-placer. You'll need a crafting recipe for tri-inserter-placer only.

I've written a quick piece of code that should do as you request. It's untested and still requires you to make the entities definitions as above.
Untested code:

Code: Select all

game.onevent(defines.events.onbuiltentity, function(event) EntityBuilt(event) end) -- Player built
game.onevent(defines.events.robotbuiltentity, function(event) EntityBuilt(event) end) -- Robot built

game.onevent(defines.events.onpreplayermineditem, function(event) EntityRemoved(event) end) -- Player removed
game.onevent(defines.events.onrobotmined, function(event) EntityRemoved(event) end) -- Robot removed
game.onevent(defines.events.onentitydied, function(event) EntityRemoved(event) end) -- It died

function EntityBuilt(event)
	if event.createdentity.name="tri-inserter-placer" then -- If it's the entity that's supposed to have three arms
		-- An inserter that outputs left
		game.createentity{	name = "tri-inserter-left", 
						position = event.createdentity.position, 
						direction = event.createdentity.direction, 
						force = game.players[1].force}
		-- An inserter that outputs right
		game.createentity{	name = "tri-inserter-right", 
						position = event.createdentity.position, 
						direction = event.createdentity.direction, 
						force = game.players[1].force}
		-- An inserter that outputs straight
		game.createentity{	name = "tri-inserter-straight", 
						position = event.createdentity.position, 
						direction = event.createdentity.direction, 
						force = game.players[1].force}
		-- Destroy the tri-inserter-placer
		event.createdentity.destroy()
	end
end

function EntityRemoved(event)
	-- If it's the entity that's supposed to have three arms
	if event.createdentity.name="tri-inserter-left" or event.createdentity.name="tri-inserter-right" or event.createdentity.name="tri-inserter-straight" then
		-- Delete any tri-inserters remaining at the location.
		local find = game.findentitiesfiltered{area = {{event.entity.position.x - 0.5, event.entity.position.y - 0.5}, {event.entity.position.x + 0.5, event.entity.position.y + 0.5}}, type= "tri-inserter-left"}
		if #find > 0 then find[0].destroy() end
		find = game.findentitiesfiltered{area = {{event.entity.position.x - 0.5, event.entity.position.y - 0.5}, {event.entity.position.x + 0.5, event.entity.position.y + 0.5}}, type= "tri-inserter-right"}
		if #find > 0 then find[0].destroy() end
		find = game.findentitiesfiltered{area = {{event.entity.position.x - 0.5, event.entity.position.y - 0.5}, {event.entity.position.x + 0.5, event.entity.position.y + 0.5}}, type= "tri-inserter-straight"}
		if #find > 0 then find[0].destroy() end
	end
end

Otherwise please try searching first:
Searching for side inserter:
[0.9.8] Side Inserters (1.1)
[MOD 0.10.5+] Moar Inserters! v1.2
Ctrl-f on "inserter" on the mod pages.
[MOD 0.9.x] More Inserters! v1.1
[0.9.8] wide&near inserters
[MOD 0.9.2] Insert This

Post Reply

Return to “Ideas and Requests For Mods”