Deconstructing (via bots) entities that give multiple items

Place to get help with not working mods / modding interface.
Graveeater
Burner Inserter
Burner Inserter
Posts: 19
Joined: Thu Jul 07, 2016 8:00 pm
Contact:

Deconstructing (via bots) entities that give multiple items

Post by Graveeater »

Most entities give exactly one item when deconstructed, usually the item which was used to build them.
Trees give a couple of units of raw wood. I would like to add additional results to trees, for example seeds as done in the arborium mod.
This works perfectly well if I hand-mine them: I get the raw-wood and the seeds. However when the construction robots deconstruct the tree I get only one type, the one defined first.
It seems that the construction robot can carry at most one item type but multiple items of that type.

I tried this, but nothing really changed:
* adding loot has no influence at all
* setting bot.max_payload_size = 2 has no effect
* as mentioned above, changing the minable.results order just switches which item is returned

I don't know any example where this works so its a bit hard to understand. I remember that for hard crafting a similar problem existed with drills where the solution was to increase the drill's storage size, but max_payload size does not work.

Now I am looking for good ideas. Can this be done with some property? Do I need a workaround? Is this actually a bug?
matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: Deconstructing (via bots) entities that give multiple items

Post by matjojo »

this sounds like a bug to me if the items are not spilled on the ground, as there are just items disappearing.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Deconstructing (via bots) entities that give multiple items

Post by Nexela »

This could be worked around using on robot_pre_mined event in control.lua

Something like this

Code: Select all

script.on_event(defines.events.on_robot_pre_mined, 
  function(event)
    local tree = event.entity
    if tree.type == "tree" then
      local stack = {name="seed", count=math.random(1, 5)}  -- 1 and 5 would be your min and max
      seed = tree.surface.create_entity{name="item-on-ground", position=tree.position, stack=stack}
      if seed then seed.order_deconstruction() end
    end
end
Last edited by Nexela on Tue Jan 10, 2017 9:55 am, edited 1 time in total.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14345
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Deconstructing (via bots) entities that give multiple items

Post by Rseding91 »

Setting items being deleted is indeed a bug. I'll fix it for 0.15 so it drops the extra items on the ground and marks them for deconstruction.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Modding help”