- 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:
I'm not sure if this is intended behavior
Code: Select all
/c game.player.surface.create_entity{name="item-on-ground", position=game.player.position, stack={name="steel-plate", count=100000}}
- 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
[0.12.5] [kovarex] "item-on-ground" entities inconsistent behavior
[0.12.5] [kovarex] "item-on-ground" entities inconsistent behavior
There are a few strange behaviors relating to "item-on-ground" entities
Re: [0.12.5] "item-on-ground" entities inconsistent behavior
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.
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.
Re: [0.12.5] "item-on-ground" entities inconsistent behavior
Awesome, thanks!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.
Re: [0.12.5] "item-on-ground" entities inconsistent behavior
This seems to be fine.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 looks strange, I will take a lookHazzard 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 seems wrong as well.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]
Re: [0.12.5] [kovarex] "item-on-ground" entities inconsistent behavior
I fixed the two things I mentioned in the previous post for 0.12.6