Page 1 of 1

Deconstructing (via bots) entities that give multiple items

Posted: Sat Jan 07, 2017 2:47 pm
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?

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

Posted: Mon Jan 09, 2017 1:32 pm
by matjojo
this sounds like a bug to me if the items are not spilled on the ground, as there are just items disappearing.

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

Posted: Tue Jan 10, 2017 1:06 am
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

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

Posted: Tue Jan 10, 2017 7:07 am
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.