1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-05 13:15:03 +02:00

25 lines
1.2 KiB
Lua
Raw Normal View History

2019-03-15 03:59:43 +01:00
local function spy_fish(player)
2019-03-27 03:58:22 +01:00
if not player.character then return end
2019-07-26 21:47:59 +02:00
local duration_per_unit = 2700
local i2 = player.get_inventory(defines.inventory.character_main)
2019-03-27 03:58:22 +01:00
if not i2 then return end
2019-03-15 03:59:43 +01:00
local owned_fishes = i2.get_item_count("raw-fish")
owned_fishes = owned_fishes + i2.get_item_count("raw-fish")
if owned_fishes == 0 then
player.print("You have no fish in your inventory.",{ r=0.98, g=0.66, b=0.22})
else
local x = i2.remove({name="raw-fish", count=1})
if x == 0 then i2.remove({name="raw-fish", count=1}) end
local enemy_team = "south"
if player.force.name == "south" then enemy_team = "north" end
if global.spy_fish_timeout[player.force.name] - game.tick > 0 then
global.spy_fish_timeout[player.force.name] = global.spy_fish_timeout[player.force.name] + duration_per_unit
player.print(math.ceil((global.spy_fish_timeout[player.force.name] - game.tick) / 60) .. " seconds of enemy vision left.", { r=0.98, g=0.66, b=0.22})
2020-01-22 08:30:41 +01:00
else
2019-03-15 03:59:43 +01:00
game.print(player.name .. " sent a fish to spy on " .. enemy_team .. " team!", {r=0.98, g=0.66, b=0.22})
global.spy_fish_timeout[player.force.name] = game.tick + duration_per_unit
end
end
end
return spy_fish