Code: Select all
script.on_event(defines.events.on_pre_player_mined_item, function(event)
if event.entity.type == "car" then
for index,car in pairs(global.cars) do
if event.entity == car then
global.cars[index] = {}
if index == event.player_index then
game.players[index].print("You no longer own a car, use your keys to claim a new one")
else
game.players[index].print(game.players[event.player_index].name.." mined your car, use your keys to claim a new one")
end
end
end
elseif event.entity.type == "unit" then
for index,car in pairs(global.cars) do
if not car.valid and event.entity == car.kitt then
global.cars[index] = {}
global.surface[index] = nil
global.position[index] = nil
if index == event.player_index then
game.players[index].print("You no longer own a car, use your keys to claim a new one")
else
game.players[index].print(game.players[event.player_index].name.." mined your car, use your keys to claim a new one")
end
end
end
end
end)
There was a similar thing where the original code looked for the string "turret" in the entity name. I couldn't make sense of it until I read this thread on the original mod's discussion board, which led me to believe addresses an issue with the "Vehicle turrets" mod. I therefore assume that "car.kitt" also is there for compatibility with another mod.
Unfortunately, the original code isn't documented really well, so I have no idea what mod this could come from. Does anybody know of a mod that does something with cars and uses "car.kitt"? I know it's a long shot, but perhaps somebody does know something and can help me out …