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

35 lines
900 B
Lua
Raw Normal View History

2020-07-12 20:54:44 +02:00
local Event = require 'utils.event'
2021-11-26 14:48:49 +02:00
local Public = require 'maps.fish_defender_v2.table'
2020-07-12 20:54:44 +02:00
local function on_player_changed_position(event)
2021-11-26 14:48:49 +02:00
local vehicle_nanobots_unlocked = Public.get('vehicle_nanobots_unlocked')
2020-07-12 20:54:44 +02:00
if not vehicle_nanobots_unlocked then
return
end
2021-11-26 14:48:49 +02:00
local player = game.get_player(event.player_index)
if not (player and player.valid) then
2020-07-12 20:54:44 +02:00
return
end
2021-11-26 14:48:49 +02:00
if not player.character then
2020-07-12 20:54:44 +02:00
return
end
2021-11-26 14:48:49 +02:00
if not player.character.driving then
2020-07-12 20:54:44 +02:00
return
end
2021-11-26 14:48:49 +02:00
if not (player.vehicle and player.vehicle.valid) then
2020-07-12 20:54:44 +02:00
return
end
2021-11-26 14:48:49 +02:00
2020-07-12 20:54:44 +02:00
if player.vehicle.health == player.vehicle.prototype.max_health then
return
end
player.vehicle.health = player.vehicle.health + player.vehicle.prototype.max_health * 0.005
end
Event.add(defines.events.on_player_changed_position, on_player_changed_position)
2021-11-26 14:48:49 +02:00
return Public