[0.12.6][po]LuaInventory.insert into trash doesn't call bots

This subforum contains all the issues which we already resolved.
Post Reply
Choumiko
Smart Inserter
Smart Inserter
Posts: 1352
Joined: Fri Mar 21, 2014 10:51 pm
Contact:

[0.12.6][po]LuaInventory.insert into trash doesn't call bots

Post by Choumiko »

When inserting items into the trash inventory via script, these items don't get picked up by logistics bots.
It works if those items got inserted when the player was outside of logistics range at the time of insertion or if he walks out of range after insertion and then walks back in.

Code: Select all

function on_tick(event)
  if event.tick % 120 == 0 then
    for pi, player in pairs(game.players) do
      if not player.valid or not player.connected or not global.config[player.name] then
        break
      end
      for i, item in pairs(global.config[player.name]) do
        if item.name == "" then
          break
        end
        local stack = {name=item.name, count=1}
        local count = player.get_item_count(item.name)
        local desired = item.count
        local diff = count - desired
        if diff > 0 then
          player.print(item.name.. ": " .. diff)
          local trash = player.get_inventory(defines.inventory.player_trash)
          for j=1,diff do
            if trash.can_insert(stack) then
              player.remove_item(stack)
              trash.insert(stack)
            end
          end
        end
      end
    end
  end
end
global.config[player.name] is a table of items that should get moved to trash by the mod

posila
Factorio Staff
Factorio Staff
Posts: 5201
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: [0.12.6][po]LuaInventory.insert into trash doesn't call bots

Post by posila »

Thanks for the report, fixed for next release.

Post Reply

Return to “Resolved Problems and Bugs”