Sounds great but I can't figure out how I'm supposed to use that. I am trying to "refund" the item used when placing the entity. Ideally the item would return to the cursor_stack and the player could place it again.Changed on_built_entity event. Instead of stack/item, it passes consumed_items - modifiable stack of items used for the building.
But nothing I tried works:
Code: Select all
local function on_built_entity(event)
    for i = 1, #event.consumed_items do
        local stack = event.consumed_items[i]
        game.print("Stack " .. tostring(i) .. " is " .. serpent.line(stack))
        if stack.valid_for_read and stack.prototype.group.name == "test" then
            game.print("Refunding")
            -- NONE OF THESE WORK:
            -- stack.count = 0
            -- stack.clear()
            -- event.consumed_items.remove(stack)
            -- event.consumed_items.remove({ name = stack.name, count = 1 })
So I honestly can't figure out how I'm supposed to use this. If what I'm trying to achieve is not supported using consumed_items, then maybe document what kind of changes are supported.



