[0.12.5] [kovarex] "item-on-ground" entities inconsistent behavior
Posted: Sat Aug 29, 2015 6:27 am
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:
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