1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-12 10:04:40 +02:00

implemented nuke control #8

This commit is contained in:
Valansch 2017-07-08 22:24:24 +02:00
parent 57b86e43dc
commit f8f5eb340a
3 changed files with 30 additions and 11 deletions

View File

@ -11,5 +11,5 @@ Event.register(-1, function()
global.scenario.config.mapsettings.spiral_land_width = 70 -- width of land in spiral
global.scenario.config.mapsettings.spiral_water_width = 70 -- width of water in spiral
global.scenario.custom_functions = {}
global.scenario.config.nuke_min_time_hours = 3 --how long a player must be on the server to be allowed to use the nuke
end)

View File

@ -13,13 +13,14 @@ require "train_station_names"
require "score"
require "map_layout"
require "custom_commands"
require "nuke_control"
function player_joined(event)
local player = game.players[event.player_index]
player.insert { name = "raw-fish", count = 4 }
player.insert { name = "iron-gear-wheel", count = 8 }
player.insert { name = "iron-gear-wheel", count = 8 }
player.insert { name = "iron-plate", count = 16 }
--player.insert { name = "pistol", count = 1 }
--player.insert { name = "firearm-magazine", count = 8 }
@ -28,7 +29,7 @@ function player_joined(event)
--player.insert { name = "construction-robot", count = 16 }
--player.insert { name = "solar-panel", count = 16 }
--player.insert { name = "substation", count = 16 }
--player.insert { name = "logistic-chest-passive-provider", count = 16 }
--player.insert { name = "logistic-chest-passive-provider", count = 16 }
--player.insert { name = "power-armor", count = 1 }
player.print("Welcome to our Server. You can join our Discord at: discord.me/redmew")
player.print("And remember.. Keep Calm And Spaghetti!")
@ -41,7 +42,7 @@ function walkabout(player_name, distance)
distance = math.random(5000, 10000)
return
end
if distance == "close" then
distance = math.random(3000, 7000)
else
@ -69,18 +70,18 @@ function walkabout(player_name, distance)
local distance_min = distance * 0.95
distance_max = round(distance_max, 0)
distance_min = round(distance_min, 0)
--while r <= repeat_attempts do
x = math.random(distance_min, distance_max)
if 1 == math.random(1, 2) then
x = x * -1
x = x * -1
end
y = math.random(distance_min, distance_max)
if 1 == math.random(1, 2) then
y = y * -1
end
if 1 == math.random(1, 2) then
z = distance_max * -1
x = math.random(z, distance_max)
@ -88,11 +89,11 @@ function walkabout(player_name, distance)
z = distance_max * -1
y = math.random(z, distance_max)
end
--r = r + 1
--local tile = surface.get_tile(x,y)
--game.print(tile.name)
--if tile.name == "deep-water" or tile.name == "water" then
--if tile.name == "deep-water" or tile.name == "water" then
--if r >= repeat_attempts then
--game.print(player_name .. " tried to go on a walkabout, but could only find water.")
--return
@ -101,7 +102,7 @@ function walkabout(player_name, distance)
local pos = {x, y}
player.teleport(pos)
game.print(player_name .. " went on a walkabout, to find himself.")
return
return
--end
--end
end

18
nuke_control.lua Normal file
View File

@ -0,0 +1,18 @@
local function allowed_to_nuke(player)
return player.admin or(player.online_time / 216000) > global.scenario.config.nuke_min_time_hours
end
local function ammo_changed(event)
local player = game.players[event.player_index]
if allowed_to_nuke(player) then return end
local nukes = player.remove_item({name="atomic-bomb", count=1000})--.remove_item("atomic-bomb")
if nukes > 0 then
game.print(player.name .. " tried to use a nuke, but instead dropped it on his foot.")
player.character.health = 0
end
end
Event.register(defines.events.on_player_ammo_inventory_changed, ammo_changed)