mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-28 03:57:22 +02:00
.created_entity -> .entity
This commit is contained in:
parent
709e48ba03
commit
50d4117ff1
@ -1604,10 +1604,10 @@ end
|
||||
--anti construction robot cheese
|
||||
local function on_robot_built_entity(event)
|
||||
if event.robot.force.name == 'north' then
|
||||
if event.created_entity.position.y >= -1 * storage.horizontal_border_width / 2 then
|
||||
local x = event.created_entity.position.x
|
||||
local y = event.created_entity.position.y
|
||||
event.created_entity.die('south')
|
||||
if event.entity.position.y >= -1 * storage.horizontal_border_width / 2 then
|
||||
local x = event.entity.position.x
|
||||
local y = event.entity.position.y
|
||||
event.entity.die('south')
|
||||
search_for_ghost = game.surfaces['surface'].find_entities({ { x, y }, { x + 1, y + 1 } })
|
||||
for _, e in pairs(search_for_ghost) do
|
||||
if e.type == 'entity-ghost' then
|
||||
@ -1619,10 +1619,10 @@ local function on_robot_built_entity(event)
|
||||
end
|
||||
end
|
||||
if event.robot.force.name == 'south' then
|
||||
if event.created_entity.position.y <= storage.horizontal_border_width / 2 then
|
||||
local x = event.created_entity.position.x
|
||||
local y = event.created_entity.position.y
|
||||
event.created_entity.die('north')
|
||||
if event.entity.position.y <= storage.horizontal_border_width / 2 then
|
||||
local x = event.entity.position.x
|
||||
local y = event.entity.position.y
|
||||
event.entity.die('north')
|
||||
search_for_ghost = game.surfaces['surface'].find_entities({ { x, y }, { x + 1, y + 1 } })
|
||||
for _, e in pairs(search_for_ghost) do
|
||||
if e.type == 'entity-ghost' then
|
||||
|
@ -207,14 +207,14 @@ function Public.init_player(player)
|
||||
end
|
||||
|
||||
function Public.no_turret_creep(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if not no_turret_blacklist[event.created_entity.type] then
|
||||
if not no_turret_blacklist[event.entity.type] then
|
||||
return
|
||||
end
|
||||
local surface = event.created_entity.surface
|
||||
local surface = event.entity.surface
|
||||
local spawners =
|
||||
surface.find_entities_filtered({ type = 'unit-spawner', area = { { entity.position.x - 70, entity.position.y - 70 }, { entity.position.x + 70, entity.position.y + 70 } } })
|
||||
if #spawners == 0 then
|
||||
|
@ -49,13 +49,13 @@ end
|
||||
|
||||
local function on_built_entity(event)
|
||||
Functions.no_turret_creep(event)
|
||||
Functions.add_target_entity(event.created_entity)
|
||||
Functions.add_target_entity(event.entity)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
Functions.no_turret_creep(event)
|
||||
Terrain.deny_construction_bots(event)
|
||||
Functions.add_target_entity(event.created_entity)
|
||||
Functions.add_target_entity(event.entity)
|
||||
end
|
||||
|
||||
local function on_entity_died(event)
|
||||
|
@ -793,14 +793,14 @@ function Public.deny_construction_bots(event)
|
||||
if not robot_build_restriction[event.robot.force.name] then
|
||||
return
|
||||
end
|
||||
if not robot_build_restriction[event.robot.force.name](event.created_entity.position.y) then
|
||||
if not robot_build_restriction[event.robot.force.name](event.entity.position.y) then
|
||||
return
|
||||
end
|
||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({ name = event.created_entity.name, count = 1 })
|
||||
event.robot.surface.create_entity({ name = 'explosion', position = event.created_entity.position })
|
||||
inventory.insert({ name = event.entity.name, count = 1 })
|
||||
event.robot.surface.create_entity({ name = 'explosion', position = event.entity.position })
|
||||
game.print('Team ' .. event.robot.force.name .. "'s construction drone had an accident.", { r = 200, g = 50, b = 100 })
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -357,14 +357,14 @@ local function on_robot_built_entity(event)
|
||||
if not robot_build_restriction[event.robot.force.name] then
|
||||
return
|
||||
end
|
||||
if not robot_build_restriction[event.robot.force.name](event.created_entity.position.x) then
|
||||
if not robot_build_restriction[event.robot.force.name](event.entity.position.x) then
|
||||
return
|
||||
end
|
||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({ name = event.created_entity.name, count = 1 })
|
||||
event.robot.surface.create_entity({ name = 'explosion', position = event.created_entity.position })
|
||||
inventory.insert({ name = event.entity.name, count = 1 })
|
||||
event.robot.surface.create_entity({ name = 'explosion', position = event.entity.position })
|
||||
game.print('Team ' .. event.robot.force.name .. "'s construction drone had an accident.", { r = 200, g = 50, b = 100 })
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
|
@ -29,7 +29,7 @@ function Public.create_chest(surface, position, storage)
|
||||
end
|
||||
|
||||
local function built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid or entity.name ~= 'infinity-chest' then
|
||||
return
|
||||
end
|
||||
|
@ -87,7 +87,7 @@ local function check_player_ports()
|
||||
end
|
||||
|
||||
local function built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -291,7 +291,7 @@ function Public.on_entity_damaged(event)
|
||||
end
|
||||
|
||||
function Public.on_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -1095,7 +1095,7 @@ local deny_buildings_tbl = {
|
||||
}
|
||||
|
||||
local function deny_building(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -1110,7 +1110,7 @@ local function deny_building(event)
|
||||
inventory.insert({ name = entity.name, count = 1 })
|
||||
end
|
||||
end
|
||||
event.created_entity.surface.create_entity(
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
@ -1129,7 +1129,7 @@ end
|
||||
local on_built_entity = function (event)
|
||||
local get_score = Score.get_table().score_table
|
||||
local this = FDT.get()
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
@ -1188,7 +1188,7 @@ local on_built_entity = function (event)
|
||||
end
|
||||
|
||||
local on_robot_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
local surface = entity.surface
|
||||
|
||||
if not surface or not surface.valid then
|
||||
|
@ -234,12 +234,12 @@ local type_whitelist = {
|
||||
}
|
||||
|
||||
local function deny_building(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if type_whitelist[event.created_entity.type] then
|
||||
if type_whitelist[event.entity.type] then
|
||||
return
|
||||
end
|
||||
|
||||
@ -254,7 +254,7 @@ local function deny_building(event)
|
||||
inventory.insert({ name = entity.name, count = 1 })
|
||||
end
|
||||
|
||||
event.created_entity.surface.create_entity(
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
|
@ -612,7 +612,7 @@ end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local dungeontable = DungeonsTable.get_dungeontable()
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -1034,7 +1034,7 @@ end
|
||||
local function on_built_entity(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
local this = FDT.get()
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -1076,7 +1076,7 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
local entity_limits = FDT.get('entity_limits')
|
||||
if entity_limits[entity.name] then
|
||||
local surface = entity.surface
|
||||
|
@ -1563,7 +1563,7 @@ end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -1605,7 +1605,7 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if storage.entity_limits[entity.name] then
|
||||
local surface = entity.surface
|
||||
if storage.entity_limits[entity.name].placed < storage.entity_limits[entity.name].limit then
|
||||
|
@ -1094,7 +1094,7 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
|
||||
local function deny_building(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -1111,7 +1111,7 @@ local function deny_building(event)
|
||||
end
|
||||
end
|
||||
|
||||
event.created_entity.surface.create_entity(
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
@ -1132,7 +1132,7 @@ local function on_built_entity(event)
|
||||
return
|
||||
end
|
||||
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -1175,7 +1175,7 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if deny_building(event) then
|
||||
return
|
||||
end
|
||||
|
@ -282,7 +282,7 @@ function Public.mothership_message_queue(journey)
|
||||
end
|
||||
|
||||
function Public.deny_building(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -297,7 +297,7 @@ function Public.deny_building(event)
|
||||
end
|
||||
|
||||
function Public.register_built_silo(event, journey)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -126,7 +126,7 @@ Public.matter_anomaly = {
|
||||
end
|
||||
end,
|
||||
on_robot_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -138,7 +138,7 @@ Public.matter_anomaly = {
|
||||
end
|
||||
end,
|
||||
on_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -227,7 +227,7 @@ Public.replicant_fauna = {
|
||||
|
||||
Public.tarball = {
|
||||
on_robot_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -240,7 +240,7 @@ Public.tarball = {
|
||||
entity.minable = false
|
||||
end,
|
||||
on_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -368,7 +368,7 @@ Public.oceanic = {
|
||||
surface.clear(true)
|
||||
end,
|
||||
on_robot_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -380,7 +380,7 @@ Public.oceanic = {
|
||||
end
|
||||
end,
|
||||
on_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -564,7 +564,7 @@ Public.low_mass = {
|
||||
|
||||
Public.dense_atmosphere = {
|
||||
on_robot_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -576,7 +576,7 @@ Public.dense_atmosphere = {
|
||||
end
|
||||
end,
|
||||
on_built_entity = function (event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -600,7 +600,7 @@ end
|
||||
|
||||
Public.lazy_bastard = {
|
||||
on_robot_built_entity = function (event, journey)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -612,7 +612,7 @@ Public.lazy_bastard = {
|
||||
end
|
||||
end,
|
||||
on_built_entity = function (event, journey)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -1235,16 +1235,16 @@ local loaders = {
|
||||
['express-loader'] = true
|
||||
}
|
||||
local function on_built_entity(event)
|
||||
if not event.created_entity or not event.created_entity.valid then
|
||||
if not event.entity or not event.entity.valid then
|
||||
return
|
||||
end
|
||||
local get_score = Score.get_table().score_table
|
||||
local name = event.created_entity.name
|
||||
local name = event.entity.name
|
||||
if inserters[name] then
|
||||
local surface = event.created_entity.surface
|
||||
local surface = event.entity.surface
|
||||
local a = {
|
||||
left_top = { x = event.created_entity.position.x - 2, y = event.created_entity.position.y - 2 },
|
||||
right_bottom = { x = event.created_entity.position.x + 2, y = event.created_entity.position.y + 2 }
|
||||
left_top = { x = event.entity.position.x - 2, y = event.entity.position.y - 2 },
|
||||
right_bottom = { x = event.entity.position.x + 2, y = event.entity.position.y + 2 }
|
||||
}
|
||||
local chest = surface.find_entities_filtered { area = a, name = 'infinity-chest', limit = 1 }
|
||||
if not chest[1] then
|
||||
@ -1273,14 +1273,14 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
if loaders[name] then
|
||||
local surface = event.created_entity.surface
|
||||
local surface = event.entity.surface
|
||||
local a = {
|
||||
left_top = { x = event.created_entity.position.x - 2, y = event.created_entity.position.y - 2 },
|
||||
right_bottom = { x = event.created_entity.position.x + 2, y = event.created_entity.position.y + 2 }
|
||||
left_top = { x = event.entity.position.x - 2, y = event.entity.position.y - 2 },
|
||||
right_bottom = { x = event.entity.position.x + 2, y = event.entity.position.y + 2 }
|
||||
}
|
||||
local found = surface.find_entities_filtered { area = a, name = 'infinity-chest' }
|
||||
if found[1] then
|
||||
event.created_entity.die('enemy')
|
||||
event.entity.die('enemy')
|
||||
if event.player_index then
|
||||
local player = game.players[event.player_index]
|
||||
player.print('The mysterious chest noticed your greed and devoured your device.', { r = 0.75, g = 0.0, b = 0.0 })
|
||||
@ -1290,11 +1290,11 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
if name == 'flamethrower-turret' or name == 'laser-turret' then
|
||||
if event.created_entity.position.y < 0 then
|
||||
if event.entity.position.y < 0 then
|
||||
if event.player_index then
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({ name = name, count = 1 })
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
if get_score[player.force.name].players[player.name] then
|
||||
@ -1307,7 +1307,7 @@ local function on_built_entity(event)
|
||||
if event.robot then
|
||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({ name = name, count = 1 })
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -1315,14 +1315,14 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
if name == 'gun-turret' then
|
||||
local surface = event.created_entity.surface
|
||||
local surface = event.entity.surface
|
||||
local amount_of_enemy_structures =
|
||||
surface.count_entities_filtered(
|
||||
{
|
||||
name = { 'spitter-spawner', 'biter-spawner' },
|
||||
area = {
|
||||
{ event.created_entity.position.x - 18, event.created_entity.position.y - 18 },
|
||||
{ event.created_entity.position.x + 18, event.created_entity.position.y + 18 }
|
||||
{ event.entity.position.x - 18, event.entity.position.y - 18 },
|
||||
{ event.entity.position.x + 18, event.entity.position.y + 18 }
|
||||
},
|
||||
force = 'enemy',
|
||||
limit = 1
|
||||
@ -1332,7 +1332,7 @@ local function on_built_entity(event)
|
||||
if event.player_index and amount_of_enemy_structures > 0 then
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({ name = name, count = 1 })
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
player.print('Their nests aura seems to deny the placement of any close turrets.', { r = 0.75, g = 0.0, b = 0.0 })
|
||||
if get_score then
|
||||
if get_score[player.force.name] then
|
||||
@ -1346,7 +1346,7 @@ local function on_built_entity(event)
|
||||
if event.robot and amount_of_enemy_structures > 0 then
|
||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({ name = name, count = 1 })
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -489,7 +489,7 @@ local function on_player_changed_position(event)
|
||||
end
|
||||
|
||||
local function deny_building(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -1476,7 +1476,7 @@ local function on_entity_spawned(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -1576,7 +1576,7 @@ local function on_built_entity(event)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -1237,7 +1237,7 @@ function Public.create_car_room(car)
|
||||
end
|
||||
|
||||
function Public.create_car(event)
|
||||
local ce = event.created_entity
|
||||
local ce = event.entity
|
||||
|
||||
local player = game.get_player(event.player_index)
|
||||
|
||||
|
@ -52,7 +52,7 @@ local function on_robot_mined_entity(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local ce = event.created_entity
|
||||
local ce = event.entity
|
||||
|
||||
if not ce or not ce.valid then
|
||||
return
|
||||
|
@ -622,7 +622,7 @@ local function on_built_entity(event, mode, bypass)
|
||||
if this.disable_normal_placement and not mode then
|
||||
return
|
||||
end
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -702,7 +702,7 @@ local function built_entity_robot(event)
|
||||
if this.disable_normal_placement then
|
||||
return
|
||||
end
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -781,7 +781,7 @@ local function built_entity_robot(event)
|
||||
create_chest(entity)
|
||||
return
|
||||
else
|
||||
local created = event.created_entity
|
||||
local created = event.entity
|
||||
if created and created.valid then
|
||||
local inventory = robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({ name = created.name, count = 1 })
|
||||
@ -793,7 +793,7 @@ local function built_entity_robot(event)
|
||||
end
|
||||
|
||||
if disable_link_chest_cheese_mode then
|
||||
local created = event.created_entity
|
||||
local created = event.entity
|
||||
if created and created.valid then
|
||||
local inventory = robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({ name = created.name, count = 1 })
|
||||
@ -1227,7 +1227,7 @@ Gui.on_click(
|
||||
|
||||
player.remove_item({ name = 'coin', count = this.cost_to_convert })
|
||||
player.opened = nil
|
||||
event.created_entity = entity
|
||||
event.entity = entity
|
||||
event.entity = entity
|
||||
event.player_index = player.index
|
||||
AG.append_scenario_history(player, entity, player.name .. ' converted chest (' .. entity.unit_number .. ')')
|
||||
|
@ -173,7 +173,7 @@ Event.add(
|
||||
defines.events.on_built_entity,
|
||||
function (event)
|
||||
local icw = ICW.get()
|
||||
return Functions.create_wagon(icw, event.created_entity)
|
||||
return Functions.create_wagon(icw, event.entity)
|
||||
end
|
||||
)
|
||||
|
||||
|
@ -349,9 +349,9 @@ end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local player = game.players[event.player_index]
|
||||
if event.created_entity.name == 'radar' then
|
||||
local unit_number = event.created_entity.unit_number
|
||||
local entity = event.created_entity
|
||||
if event.entity.name == 'radar' then
|
||||
local unit_number = event.entity.unit_number
|
||||
local entity = event.entity
|
||||
storage.map_forces[player.force.name].radar[unit_number] = entity
|
||||
end
|
||||
end
|
||||
@ -525,19 +525,19 @@ local function on_robot_built_entity(event)
|
||||
if not robot_build_restriction[event.robot.force.name] then
|
||||
return
|
||||
end
|
||||
if not robot_build_restriction[event.robot.force.name](event.created_entity.position.x, event.created_entity.position.y) then
|
||||
if event.created_entity.name == 'radar' then
|
||||
local unit_number = event.created_entity.unit_number
|
||||
local entity = event.created_entity
|
||||
if not robot_build_restriction[event.robot.force.name](event.entity.position.x, event.entity.position.y) then
|
||||
if event.entity.name == 'radar' then
|
||||
local unit_number = event.entity.unit_number
|
||||
local entity = event.entity
|
||||
storage.map_forces[event.robot.force.name].radar[unit_number] = entity
|
||||
end
|
||||
return
|
||||
end
|
||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({ name = event.created_entity.name, count = 1 })
|
||||
event.robot.surface.create_entity({ name = 'explosion', position = event.created_entity.position })
|
||||
inventory.insert({ name = event.entity.name, count = 1 })
|
||||
event.robot.surface.create_entity({ name = 'explosion', position = event.entity.position })
|
||||
game.print('Team ' .. event.robot.force.name .. "'s construction drone had an accident.", { r = 200, g = 50, b = 100 })
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
end
|
||||
|
||||
local function on_entity_damaged(event)
|
||||
|
@ -242,7 +242,7 @@ local function on_pre_player_mined_item(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local created_entity = event.created_entity
|
||||
local created_entity = event.entity
|
||||
if not created_entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -2359,7 +2359,7 @@ local function event_on_rocket_launched(event)
|
||||
end
|
||||
|
||||
local function event_on_built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity then
|
||||
return
|
||||
end
|
||||
|
@ -1710,7 +1710,7 @@ local function merchant_exploit_check(ent)
|
||||
end
|
||||
|
||||
local function on_built_entity(e)
|
||||
local ent = e.created_entity
|
||||
local ent = e.entity
|
||||
if not ent or not ent.valid then
|
||||
return
|
||||
end
|
||||
|
@ -220,12 +220,12 @@ local type_whitelist = {
|
||||
}
|
||||
|
||||
local function deny_building(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
||||
if type_whitelist[event.created_entity.type] then
|
||||
if type_whitelist[event.entity.type] then
|
||||
return
|
||||
end
|
||||
|
||||
@ -240,7 +240,7 @@ local function deny_building(event)
|
||||
inventory.insert({ name = entity.name, count = 1 })
|
||||
end
|
||||
|
||||
event.created_entity.surface.create_entity(
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
|
@ -207,7 +207,7 @@ end
|
||||
|
||||
local function prevent_entity_in_restricted_zone(event)
|
||||
local player_index = event.player_index or nil
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if entity == nil or not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -265,7 +265,7 @@ end
|
||||
|
||||
local function process_built_entities(event)
|
||||
local player_index = event.player_index
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if entity == nil or not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ local ScenarioTable = require 'maps.scrap_towny_ffa.table'
|
||||
-- called whenever a player places an item
|
||||
local function on_built_entity(event)
|
||||
local this = ScenarioTable.get_table()
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -64,7 +64,7 @@ end
|
||||
-- called whenever a robot places an item
|
||||
local function on_robot_built_entity(event)
|
||||
local this = ScenarioTable.get_table()
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -386,7 +386,7 @@ function Public.enemy_players_nearby(town_center, max_radius)
|
||||
end
|
||||
|
||||
local function found_town(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
-- is a valid entity placed?
|
||||
if entity == nil or not entity.valid then
|
||||
return
|
||||
|
@ -170,12 +170,12 @@ end
|
||||
local disabled_entities = { 'stone-furnace', 'electric-furnace', 'solar-panel' }
|
||||
local function on_built_entity(event)
|
||||
for _, e in pairs(disabled_entities) do
|
||||
if e == event.created_entity.name then
|
||||
if e == event.entity.name then
|
||||
if event.player_index then
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({ name = event.created_entity.name, count = 1 })
|
||||
player.insert({ name = event.entity.name, count = 1 })
|
||||
end
|
||||
event.created_entity.destroy()
|
||||
event.entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -574,14 +574,14 @@ end
|
||||
--local disabled_entities = {"gun-turret", "laser-turret", "flamethrower-turret"}
|
||||
local function on_built_entity(event)
|
||||
for _, e in pairs(disabled_entities) do
|
||||
if e == event.created_entity.name then
|
||||
if e == event.entity.name then
|
||||
local a = {
|
||||
left_top = { x = event.created_entity.position.x - 31, y = event.created_entity.position.y - 31 },
|
||||
right_bottom = { x = event.created_entity.position.x + 32, y = event.created_entity.position.y + 32 }
|
||||
left_top = { x = event.entity.position.x - 31, y = event.entity.position.y - 31 },
|
||||
right_bottom = { x = event.entity.position.x + 32, y = event.entity.position.y + 32 }
|
||||
}
|
||||
local enemy_count = event.created_entity.surface.count_entities_filtered({ force = 'enemy', area = a, limit = 1 })
|
||||
local enemy_count = event.entity.surface.count_entities_filtered({ force = 'enemy', area = a, limit = 1 })
|
||||
if enemy_count > 0 then
|
||||
event.created_entity.active = false
|
||||
event.entity.active = false
|
||||
if event.player_index then
|
||||
local player = game.players[event.player_index]
|
||||
player.print('The turret seems to be malfunctioning near those creatures.', { r = 0.75, g = 0.0, b = 0.0 })
|
||||
|
@ -392,7 +392,7 @@ local function on_entity_built(event)
|
||||
return
|
||||
end
|
||||
|
||||
local ce = event.created_entity
|
||||
local ce = event.entity
|
||||
if not (ce and ce.valid) then
|
||||
return
|
||||
end
|
||||
|
@ -5,11 +5,11 @@ local Event = require 'utils.event'
|
||||
local valid_types = {'boiler', 'furnace', 'generator', 'offshore-pump', 'lab', 'assembling-machine'}
|
||||
|
||||
local function on_built_entity(event)
|
||||
if not event.created_entity.valid then
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
local area = {{event.created_entity.position.x - 12, event.created_entity.position.y - 12}, {event.created_entity.position.x + 12, event.created_entity.position.y + 12}}
|
||||
local area = {{event.entity.position.x - 12, event.entity.position.y - 12}, {event.entity.position.x + 12, event.entity.position.y + 12}}
|
||||
if player.surface.count_entities_filtered({area = area, force = player.force, type = valid_types}) > 12 then
|
||||
player.force.set_spawn_position(player.position, player.surface)
|
||||
end
|
||||
|
@ -505,7 +505,7 @@ end
|
||||
--[[
|
||||
local function on_built_entity(event)
|
||||
local get_score = Score.get_table().score_table
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -57,13 +57,13 @@ local function on_robot_mined_entity(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
local created_entity = event.created_entity
|
||||
local created_entity = event.entity
|
||||
Functions.create_wagon(icw, created_entity)
|
||||
Functions.add_wagon_entity_count(icw, created_entity)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
local created_entity = event.created_entity
|
||||
local created_entity = event.entity
|
||||
Functions.create_wagon(icw, created_entity)
|
||||
Functions.add_wagon_entity_count(icw, created_entity)
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ local function validate_player(player)
|
||||
end
|
||||
|
||||
local function built_entity(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -124,7 +124,7 @@ local function built_entity(event)
|
||||
end
|
||||
|
||||
local function built_entity_robot(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -1,5 +1,5 @@
|
||||
local function deny_building(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -16,11 +16,11 @@ local function destroy_turret(entity)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
destroy_turret(event.created_entity)
|
||||
destroy_turret(event.entity)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
destroy_turret(event.created_entity)
|
||||
destroy_turret(event.entity)
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
@ -135,7 +135,7 @@ local function spaghett(surface, entity, inventory, player)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
spaghett(event.created_entity.surface, event.created_entity, game.players[event.player_index].get_main_inventory(), game.players[event.player_index])
|
||||
spaghett(event.entity.surface, event.entity, game.players[event.player_index].get_main_inventory(), game.players[event.player_index])
|
||||
end
|
||||
|
||||
local function on_player_rotated_entity(event)
|
||||
@ -143,7 +143,7 @@ local function on_player_rotated_entity(event)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
spaghett(event.robot.surface, event.created_entity, event.robot.get_inventory(defines.inventory.robot_cargo))
|
||||
spaghett(event.robot.surface, event.entity, event.robot.get_inventory(defines.inventory.robot_cargo))
|
||||
end
|
||||
|
||||
local function on_player_created(event)
|
||||
|
@ -108,7 +108,7 @@ local function is_town_market_nearby(entity)
|
||||
end
|
||||
|
||||
function Public.prevent_isolation(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
@ -118,7 +118,7 @@ function Public.prevent_isolation(event)
|
||||
if not entity_type_whitelist[entity.type] then
|
||||
return
|
||||
end
|
||||
local surface = event.created_entity.surface
|
||||
local surface = event.entity.surface
|
||||
|
||||
if is_position_isolated(surface, entity.force, entity.position) then
|
||||
error_floaty(surface, entity.position, {'modules_towny.message_error_building'})
|
||||
@ -155,7 +155,7 @@ end
|
||||
local square_min_distance_to_spawn = 80 ^ 2
|
||||
|
||||
function Public.restrictions(event)
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
|
@ -343,7 +343,7 @@ end
|
||||
|
||||
function Public.found(event)
|
||||
local townytable = Table.get_table()
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if entity.force.index ~= 1 then
|
||||
return
|
||||
end
|
||||
|
@ -192,7 +192,7 @@ local function on_built_entity(event)
|
||||
if not turrettable.enabled then
|
||||
return
|
||||
end
|
||||
local turret = event.created_entity
|
||||
local turret = event.entity
|
||||
if not turret or not turret.valid then
|
||||
return
|
||||
end
|
||||
@ -210,7 +210,7 @@ local function on_robot_built_entity(event)
|
||||
if not turrettable.enabled then
|
||||
return
|
||||
end
|
||||
local turret = event.created_entity
|
||||
local turret = event.entity
|
||||
if not turret or not turret.valid then
|
||||
return
|
||||
end
|
||||
|
@ -76,29 +76,29 @@ local function add_entity(entity)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
if not event.created_entity then
|
||||
if not event.entity then
|
||||
return
|
||||
end
|
||||
if not event.created_entity.valid then
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
if not side_target_types[event.created_entity.type] then
|
||||
if not side_target_types[event.entity.type] then
|
||||
return
|
||||
end
|
||||
add_entity(event.created_entity)
|
||||
add_entity(event.entity)
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
if not event.created_entity then
|
||||
if not event.entity then
|
||||
return
|
||||
end
|
||||
if not event.created_entity.valid then
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
if not side_target_types[event.created_entity.type] then
|
||||
if not side_target_types[event.entity.type] then
|
||||
return
|
||||
end
|
||||
add_entity(event.created_entity)
|
||||
add_entity(event.entity)
|
||||
end
|
||||
|
||||
local event = require 'utils.event'
|
||||
|
@ -328,7 +328,7 @@ local function on_built_entity(event)
|
||||
return
|
||||
end
|
||||
|
||||
local created_entity = event.created_entity
|
||||
local created_entity = event.entity
|
||||
|
||||
if created_entity.type == 'entity-ghost' then
|
||||
local player = game.get_player(event.player_index)
|
||||
|
@ -52,11 +52,11 @@ local function spaghett_deny_building(event)
|
||||
if not spaghett.enabled then
|
||||
return
|
||||
end
|
||||
local entity = event.created_entity
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
return
|
||||
end
|
||||
if not spaghett_entity_blacklist[event.created_entity.name] then
|
||||
if not spaghett_entity_blacklist[event.entity.name] then
|
||||
return
|
||||
end
|
||||
|
||||
@ -67,7 +67,7 @@ local function spaghett_deny_building(event)
|
||||
inventory.insert({ name = entity.name, count = 1 })
|
||||
end
|
||||
|
||||
event.created_entity.surface.create_entity(
|
||||
event.entity.surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = entity.position,
|
||||
|
@ -475,10 +475,10 @@ local function on_player_mined_entity(event)
|
||||
end
|
||||
|
||||
local function on_built_entity(event)
|
||||
if not event.created_entity.valid then
|
||||
if not event.entity.valid then
|
||||
return
|
||||
end
|
||||
if building_and_mining_blacklist[event.created_entity.type] then
|
||||
if building_and_mining_blacklist[event.entity.type] then
|
||||
return
|
||||
end
|
||||
local player = game.players[event.player_index]
|
||||
|
Loading…
x
Reference in New Issue
Block a user