1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Merge pull request #92 from Valansch/develop_mines

Develop mines
This commit is contained in:
Valansch 2017-10-15 16:10:24 +02:00 committed by GitHub
commit dfc132742e
4 changed files with 47 additions and 15 deletions

View File

@ -417,16 +417,16 @@ local function forcetoggle(cmd)
game.player.print("You are now on the " .. game.player.force.name .. " force.")
end
local function temp_ban_init()
if not global.temp_ban_init_done then
game.permissions.create_group("Banned")
local function get_group()
local group = game.permissions.get_group("Banned")
for i=2,174 do
group.set_allows_action(i, false)
end
else
global.temp_ban_init_done = true
if not group then
game.permissions.create_group("Banned")
group = game.permissions.get_group("Banned")
for i=2,174 do
group.set_allows_action(i, false)
end
end
return group
end
local function tempban(cmd)
@ -448,9 +448,9 @@ local function tempban(cmd)
game.print("Player doesn't exist.")
return
end
temp_ban_init()
local group = get_group()
game.print(get_actor() .. " put " .. params[1] .. " in timeout for " .. params[2] .. " minutes.")
game.permissions.get_group("Banned").add_player(params[1])
group.add_player(params[1])
if not tonumber(cmd.parameter) then
Thread.set_timeout(
60 * tonumber(params[2]),

View File

@ -0,0 +1,33 @@
local Thread = require "locale.utils.Thread"
local mines_factor = 4
--Do not change this:
mines_factor = 16384 / mines_factor
function spawn_row(params)
local x = params.x
local y = params.y
local magic_number = math.floor(mines_factor / params.distance) + 1
for i = 0, 31 do
if math.random(1, magic_number) == 1 then
game.surfaces[1].create_entity{name = "land-mine", position = {x + i,y}, force = "enemy"}
end
end
end
function run_terrain_module(event)
local distance = math.sqrt(event.area.left_top.x*event.area.left_top.x+event.area.left_top.y*event.area.left_top.y)
if distance > 100 then
for i = 0, 31 do
Thread.queue_action("spawn_row", {x = event.area.left_top.x, y = event.area.left_top.y + i, distance = distance})
end
end
end
local death_messages = {"Went exploring, and didn't bring a minesweeping kit.","Wandered off, and found that it really is dangerous to go alone.","Found that minesweeper in factorio gives no hints.","And they were only one day away from retirement","Is too old for this s$%t","Ponders the question, 'How might I avoid mines in the future'","Exploded with rage","Thought it was clear, found it was not.","Thought it was clear, was wrong.","Paved the way for expansion!","Sacrificed their body to the greater factory expansion","No longer wonders why nobody else has built here","Just wants to watch the respawn timer window","Like life, mines are unfair, next time bring a helmet","Should’ve thrown a grenade before stepping over there","Is farming the death counter","Fertilized the soil","Found no man's land, also found it applies to them.","Curses the map maker","does not look forward to the death march back to retreive items","Wont be going for a walk again","Really wants a map.", "Forgot his xray goggles","Rather Forgot to bring x-ray goggles","Learned that the biters defend their territory","Mines 1, Ninja skills 0."}
local function player_died()
game.print(death_messages[math.random(1, #death_messages)])
end
Event.register(defines.events.on_player_died, player_died)

View File

@ -6,8 +6,8 @@ local medium_worm_spawn_distance = 150
local big_worm_spawn_distance = 200
local worm_names = {"small-worm-turret","medium-worm-turret","big-worm-turret"}
local function spawn_worm(params)
worm_names = {"small-worm-turret","medium-worm-turret","big-worm-turret"}
function spawn_worm(params)
local x = params.x
local y = params.y
local lvl = params.lvl
@ -21,16 +21,14 @@ end
function run_terrain_module(event)
game.print(game.tick)
local top_left = event.area.left_top
local distance = math.sqrt(top_left.x*top_left.x+top_left.y*top_left.y)
if distance > small_worm_spawn_distance - 32 then
local lvl = 1
if distance > medium_worm_spawn_distance then lvl = 2 end
if distance > big_worm_spawn_distance then lvl = 3 end
local worm_positions = {}
for i = 1, worms_per_chunk do
Thread.queue_action(spawn_worm, {x = top_left.x + math.random(0, 31), y = top_left.y + math.random(0, 31), lvl = lvl})
Thread.queue_action("spawn_worm", {x = top_left.x + math.random(0, 31), y = top_left.y + math.random(0, 31), lvl = lvl})
end
end
end

View File

@ -36,6 +36,7 @@ in this file and your run_*type*_module(event) function will be called.
--require "locale.gen_terrain.neko_bridged_rivers"
--require "locale.gen_terrain.neko_river_overlay"
--require "locale.gen_terrain.worms"
--require "locale.gen_terrain.mines"
--ores--
--require "locale.gen_ores.neko_crazy_ores"