[0.12.5] [kovarex] "item-on-ground" entities inconsistent behavior

This subforum contains all the issues which we already resolved.
Post Reply
Hazzard
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Jul 26, 2015 1:34 am
Contact:

[0.12.5] [kovarex] "item-on-ground" entities inconsistent behavior

Post by Hazzard »

There are a few strange behaviors relating to "item-on-ground" entities
  • surface.create_entity doesn't work with "ItemStack"s, only "SimpleItemStack"s

    Code: Select all

    /c game.player.surface.create_entity{name="item-on-ground", position=game.player.position, stack={name="steel-plate"}} --works
    /c game.player.surface.create_entity{name="item-on-ground", position=game.player.position, stack=game.player.cursor_stack} --says "No such node (stack)" even though "stack" is clearly set
    
  • Through lua scripts, "item-on-ground" entities can have more than one item, and more items than the max in one stack of items:

    Code: Select all

    /c game.player.surface.create_entity{name="item-on-ground", position=game.player.position, stack={name="steel-plate", count=100000}}
    I'm not sure if this is intended behavior
    • When a "mega-stack" is picked up by a player ("f"), the game subtracts from the stack until the player's inventory is full, leaving the remainder in a single entity
    • When a "mega-stack" resting on the ground is picked up by an inserter, it will pick up one item (+item stack bonus if it is placing into an inventory) and cause the remainder to scatter, creating hundreds of normal entities each with one item ( http://i.imgur.com/WB85RkC.jpg )
    • When a "mega-stack" on a belt is picked up by an inserter, it will pick up one item (+item stack bonus if placing into inventory) and delete the remainder
  • One last thing, surface.spill_item_stack only works with SimpleItemStacks, which is a huge pain in the ass when trying to drop items with damage values or power armor. When dropping a stack of damaged picks, for example, a script would have to:
    • find an open spawning position. Some inconsistency with these "mega-stacks":
    • spawn a SimpleItemStack -> "item-on-ground" based off of the ItemStack (due to bug above)
    • take the created entity and set "grid", "health", "durability", "blueprint_icons" etc based off of the stack. We cannot use .set_stack() because it will create a "mega-stack" (I think). We can't just set the original ItemStack's count to zero, because then we will clone the bottom item of the stack, when we want to clone the top. Very messy
    • subtract one from the ItemStack.count. All of the values like "grid", "health", "durability", etc, CHANGE, because then they match the second/next item in the stack (wtf)
    • repeat above steps for each item in the original ItemStack
    Same thing, why does Inventory.insert() only accept a SimpleItemStack?
Thanks

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.12.5] "item-on-ground" entities inconsistent behavior

Post by Rseding91 »

The create_entity method not accepting an "ItemStack" is unfortunately just how that system works when creating entities through the Lua interface. You can however work around this by creating the item-on-ground using any valid "SimpleItemStack" and then using: "entity.stack.set_item_stack(game.player.cursor_stack)"

As for the oddities when dealing with item-on-ground's that have > 1 item in them - that isn't used anywhere in the base and and as such hasn't really been tested at all so that's not unexpected that its behaves weirdly :)

Regarding the surface.spill_item_stack: I added support for spilling a "ItemStack" to that method in 0.12.6 so that should fix that.
If you want to get ahold of me I'm almost always on Discord.

Hazzard
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Jul 26, 2015 1:34 am
Contact:

Re: [0.12.5] "item-on-ground" entities inconsistent behavior

Post by Hazzard »

Rseding91 wrote:Regarding the surface.spill_item_stack: I added support for spilling a "ItemStack" to that method in 0.12.6 so that should fix that.
Awesome, thanks!

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.5] "item-on-ground" entities inconsistent behavior

Post by kovarex »

Hazzard wrote:
  • When a "mega-stack" is picked up by a player ("f"), the game subtracts from the stack until the player's inventory is full, leaving the remainder in a single entity
This seems to be fine.
Hazzard wrote:
  • When a "mega-stack" resting on the ground is picked up by an inserter, it will pick up one item (+item stack bonus if it is placing into an inventory) and cause the remainder to scatter, creating hundreds of normal entities each with one item ( http://i.imgur.com/WB85RkC.jpg )
This looks strange, I will take a look
Hazzard wrote: [*] When a "mega-stack" on a belt is picked up by an inserter, it will pick up one item (+item stack bonus if placing into inventory) and delete the remainder[/list]
This seems wrong as well.

kovarex
Factorio Staff
Factorio Staff
Posts: 8078
Joined: Wed Feb 06, 2013 12:00 am
Contact:

Re: [0.12.5] [kovarex] "item-on-ground" entities inconsistent behavior

Post by kovarex »

I fixed the two things I mentioned in the previous post for 0.12.6

Post Reply

Return to “Resolved Problems and Bugs”