GCKI listens for on_built_entity and makes use of filtering by entity name:
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
GCKI.dprint("Entered event script on_built_entity for player " .. game.players[event.player_index].name)
local index = event.player_index
local player = game.players[index]
local entity = event.created_entity
GCKI.show(player.name, "player.name")
GCKI.show(entity.name, "entity.name")
[…]
if entity.destroy() then GCKI.dprint("Destroyed entity") end
GCKI.dprint("End of event script on_built_entity for player " .. game.players[event.player_index].name)
end, {LuaPlayerBuiltEntityEventFilters = {filter = "name", name = "car-key"}})
Code: Select all
script.raise_event(defines.events.on_built_entity, {created_entity = new_stage, player_index = player_index, stack = stack})
Code: Select all
151.072 Script @__GCKI__/common.lua:160: End of event script on_player_joined_game for player Pi-C
218.621 Script @__GCKI__/common.lua:160: Entered event script on_built_entity for player Pi-C
218.622 Script @__GCKI__/common.lua:160: Show player.name: |Pi-C| (string)
218.622 Script @__GCKI__/common.lua:160: Show entity.name: |rsc-silo-stage2| (string)
218.622 Script @__GCKI__/common.lua:160: Entered function is_locked_vehicle(car)
218.622 Script @__GCKI__/common.lua:160: This Car is unlocked.
218.622 Script @__GCKI__/common.lua:160: Show locker: |nil| (nil)
218.622 Script @__GCKI__/common.lua:160: End of function is_locked_vehicle(car)
218.622 Script @__GCKI__/common.lua:160: Can't place Car at selected location, try another one!
218.622 Script @__GCKI__/common.lua:160: Destroyed entity
218.622 Script @__GCKI__/common.lua:160: End of event script on_built_entity for player Pi-C