1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-10 00:43:27 +02:00

Merge pull request #283 from ComfyFactory/mtn

mtn v3 - small fix to higher diff
This commit is contained in:
Gerkiz 2022-07-13 22:34:54 +02:00 committed by GitHub
commit 665a4d5d4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 10 deletions

View File

@ -182,16 +182,41 @@ local function hurt_players_outside_of_aura()
if entity.name == 'character' then if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0}) game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end end
entity.die() if entity.valid then
else
entity.damage(1, 'enemy')
entity.health = entity.health - (max_health / 25)
if entity.health <= 0 then
if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end
entity.die() entity.die()
end end
else
local armor_inventory = player.get_inventory(defines.inventory.character_armor)
if not armor_inventory.valid then
return
end
local armor = armor_inventory[1]
if not armor.valid_for_read then
return
end
local grid = armor.grid
if not grid or not grid.valid then
return
end
local equip = grid.equipment
for _, piece in pairs(equip) do
if piece.valid then
piece.energy = 0
if piece.shield and piece.shield.valid then
piece.shield = 0
end
end
end
entity.damage(1, 'enemy')
if entity.valid then
entity.health = entity.health - (max_health / 25)
if entity.health <= 0 then
if entity.name == 'character' then
game.print(player.name .. messages[random(1, #messages)], {r = 200, g = 0, b = 0})
end
entity.die()
end
end
end end
end end
end end

View File

@ -109,7 +109,9 @@ function Public.iter_connected_players(callback)
local players = game.connected_players local players = game.connected_players
for i = 1, #players do for i = 1, #players do
local player = players[i] local player = players[i]
callback(player) if player and player.valid then
callback(player)
end
end end
end end
@ -119,7 +121,9 @@ function Public.iter_players(callback)
local players = game.players local players = game.players
for i = 1, #players do for i = 1, #players do
local player = players[i] local player = players[i]
callback(player) if player and player.valid then
callback(player)
end
end end
end end