1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-22 03:38:48 +02:00

58 lines
1.7 KiB
Lua
Raw Normal View History

2021-03-24 19:14:12 +01:00
local Event = require 'utils.event'
2019-09-26 20:07:19 +02:00
local function on_player_changed_position(event)
if not storage.flame_boots then
2021-03-24 16:46:00 +01:00
return
end
local player = game.players[event.player_index]
if not player.character then
return
end
if player.character.driving then
return
end
if not storage.flame_boots[player.index] then
storage.flame_boots[player.index] = {}
2021-03-24 16:46:00 +01:00
end
if not storage.flame_boots[player.index].fuel then
2021-03-24 16:46:00 +01:00
return
end
if storage.flame_boots[player.index].fuel < 0 then
player.print('Your flame boots have worn out.', { r = 0.22, g = 0.77, b = 0.44 })
storage.flame_boots[player.index] = {}
2021-03-24 16:46:00 +01:00
return
end
if storage.flame_boots[player.index].fuel % 500 == 0 then
player.print('Fuel remaining: ' .. storage.flame_boots[player.index].fuel, { r = 0.22, g = 0.77, b = 0.44 })
2021-03-24 16:46:00 +01:00
end
if not storage.flame_boots[player.index].step_history then
storage.flame_boots[player.index].step_history = {}
2021-03-24 16:46:00 +01:00
end
local elements = #storage.flame_boots[player.index].step_history
2021-03-24 16:46:00 +01:00
storage.flame_boots[player.index].step_history[elements + 1] = { x = player.position.x, y = player.position.y }
2021-03-24 16:46:00 +01:00
if elements < 50 then
return
end
player.surface.create_entity({ name = 'fire-flame', position = storage.flame_boots[player.index].step_history[elements - 2] })
2021-03-24 16:46:00 +01:00
storage.flame_boots[player.index].fuel = storage.flame_boots[player.index].fuel - 1
2019-09-26 20:07:19 +02:00
end
local function on_init()
if not storage.flame_boots then
storage.flame_boots = {}
2021-03-24 16:46:00 +01:00
end
2019-09-26 20:07:19 +02:00
end
2021-03-24 19:14:12 +01:00
Event.on_init(on_init)
Event.add(defines.events.on_player_changed_position, on_player_changed_position)