Page 1 of 1

Adding automatic belt loaders into a furnace entity

Posted: Wed Sep 02, 2020 7:22 am
by Whovian44
the title includes everything that i'm trying to do, i'm making a furnace that belts in and out without inserters for a mod i'm working on and i don't know where to start, can i make a second entity that can't be targeted that acts like a loader and gets placed invisibly with the furnace, or is there some way to make it part of the furnace's block of code. Thank you!

Re: Adding automatic belt loaders into a furnace entity

Posted: Wed Sep 02, 2020 1:45 pm
by DaveMcW
Whovian44 wrote: Wed Sep 02, 2020 7:22 amis there some way to make it part of the furnace's block of code.
No.
Whovian44 wrote: Wed Sep 02, 2020 7:22 amcan i make a second entity that can't be targeted that acts like a loader and gets placed invisibly with the furnace
Yes.

To make an entity invisible, in data.lua set all of its sprites to

Code: Select all

{
  filename = "__core__/graphics/empty.png",
  width = 1,
  height = 1,
}
To place the entity with the furnace, in control.lua add a handler to all the build events.

Code: Select all

function on_built(event) {
  local entity = event.created_entity or event.entity or event.destination
  if not entity or not entity.valid then return end
  if entity.name == "my-furnace" then
    -- Place the second entity
  end
}
script.on_event(defines.events.on_built_entity, on_built)
script.on_event(defines.events.on_robot_built_entity, on_built)
script.on_event(defines.events.script_raised_built, on_built)
script.on_event(defines.events.script_raised_revive, on_built)
script.on_event(defines.events.on_entity_cloned, on_built)

Re: Adding automatic belt loaders into a furnace entity

Posted: Thu Sep 03, 2020 5:58 pm
by darkfrei
Whovian44 wrote: Wed Sep 02, 2020 7:22 am the title includes everything that i'm trying to do, i'm making a furnace that belts in and out without inserters for a mod i'm working on and i don't know where to start, can i make a second entity that can't be targeted that acts like a loader and gets placed invisibly with the furnace, or is there some way to make it part of the furnace's block of code. Thank you!
Like this one? https://mods.factorio.com/mod/Loader-Furnace

But you can probably to go the way of miniloaders: https://mods.factorio.com/mod/miniloader
It's not a loader, but hidden inserters in this entity.