Using a blueprint, if you use a `player.clear_cursor()` then subsequent enumerations of the `event.stack` provided by `defines.events.on_built_entity` fail.
Example:
Code: Select all
local counter = 0
script.on_event(defines.events.on_built_entity, function(event)
game.print(tostring(counter) ..
": " .. tostring(event.stack.is_blueprint) .. " " .. tostring(event.stack.is_blueprint_book) .. " ")
counter = counter + 1
-->>>if not (event.stack.is_blueprint or event.stack.is_blueprint_book) then return end -- resolves to false after 1st on_built_entity
local player = game.players[event.player_index]
player.clear_cursor()
local name = event.stack.name
-- enumerating event.stack.name fails
--[[
Error while running event variable-blueprint::on_built_entity (ID 6)
LuaItemStack API call when LuaItemStack was invalid for read.
]]
end)
`clear_cursor()` should not clear `event.stack`. Additionally, I wouldn't expect subsequent `on_built_entity` to have valid `event.stack` as well.