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

fixed merge conflicts

This commit is contained in:
Maik Wild 2018-10-07 20:56:39 +02:00
commit 8623338c0b
20 changed files with 197 additions and 92 deletions

View File

@ -32,7 +32,6 @@ require 'paint'
require 'score'
require 'popup'
local Event = require 'utils.event'
local Donators = require 'resources.donators'
@ -167,7 +166,7 @@ local function player_joined(event)
return
end
game.print(table.concat({'*** ', message, ' ***'}))
game.print(table.concat({'*** ', message, ' ***'}), player.chat_color)
end
Event.add(defines.events.on_player_created, player_created)

View File

@ -21,10 +21,7 @@ local new_info_key = 4
local welcomed_players = {}
local editable_info = {
[map_name_key] = 'This Map has no name',
[map_description_key] = [[
By default this section is blank as it's supposed to be filled out on a per map basis.
(If you're seeing this message, ping the admin team to get a description added for
this map)]],
[map_description_key] = "By default this section is blank as it's supposed to be filled out on a per map basis. (If you're seeing this message, ping the admin team to get a description added for this map)",
[map_extra_info_key] = 'This map has no extra infomation',
[new_info_key] = 'Nothing is new. The world is at peace'
}
@ -405,6 +402,7 @@ Shows number of rockets launched and biters liberated.]]
text = editable_info[map_name_key]
}
map_name_textbox.read_only = read_only
map_name_textbox.word_wrap = true
local map_name_textbox_style = map_name_textbox.style
map_name_textbox_style.width = text_width
@ -420,6 +418,7 @@ Shows number of rockets launched and biters liberated.]]
text = editable_info[map_description_key]
}
map_description_textbox.read_only = read_only
map_description_textbox.word_wrap = true
local map_description_textbox_style = map_description_textbox.style
map_description_textbox_style.width = text_width
@ -435,6 +434,7 @@ Shows number of rockets launched and biters liberated.]]
text = editable_info[map_extra_info_key]
}
map_extra_info_textbox.read_only = read_only
map_extra_info_textbox.word_wrap = true
local map_extra_info_textbox_style = map_extra_info_textbox.style
map_extra_info_textbox_style.width = text_width
@ -705,7 +705,7 @@ Gui.on_custom_close(
local Public = {}
function Public.get_map_name()
function Public.get_map_name()
return editable_info[map_name_key]
end
@ -713,7 +713,7 @@ function Public.set_map_name(value)
editable_info[map_name_key] = value
end
function Public.get_map_description()
function Public.get_map_description()
return editable_info[map_description_key]
end
@ -721,7 +721,7 @@ function Public.set_map_description(value)
editable_info[map_description_key] = value
end
function Public.get_map_extra_info()
function Public.get_map_extra_info()
return editable_info[map_extra_info_key]
end
@ -729,7 +729,7 @@ function Public.set_map_extra_info(value)
editable_info[map_extra_info_key] = value
end
function Public.get_new_info()
function Public.get_new_info()
return editable_info[new_info_key]
end

View File

@ -49,25 +49,25 @@ local Config = {
mask_relative_ring_weights = {2,3,4},
-- delay in seconds before the cave collapses
collapse_delay_min = 1.5,
collapse_delay_max = 3,
collapse_delay = 2.5,
-- the threshold that will be applied to all neighbors on a collapse via a mask
collapse_threshold_total_strength = 15,
support_beam_entities = {
['stone-wall'] = 1,
['sand-rock-big'] = 1,
['market'] = 9,
['stone-wall'] = 2.5,
['sand-rock-big'] = 2,
['out-of-map'] = 1,
['stone-brick'] = 0.05,
['stone-path'] = 0.05,
['concrete'] = 0.1,
['hazard-concrete-left'] = 0.1,
['hazard-concrete-right'] = 0.1,
['refined-concrete'] = 0.1,
['stone-brick'] = 0.07,
['stone-path'] = 0.07,
['concrete'] = 0.11,
['hazard-concrete-left'] = 0.11,
['hazard-concrete-right'] = 0.11,
['refined-concrete'] = 0.15,
['refined-hazard-concrete-left'] = 0.15,
['refined-hazard-concrete-right'] = 0.15,
['deepwater-green'] = 0.2,
['deepwater-green'] = 0.7,
},
cracking_sounds = {
'CRACK',

View File

@ -32,8 +32,7 @@ end
--[[--
Registers all event handlers.
]]
function AlienSpawner.register(cfg)
local config = cfg.features.AlienSpawner
function AlienSpawner.register(config)
local alien_minimum_distance_square = config.alien_minimum_distance ^ 2
Event.add(Template.events.on_void_removed, function(event)
@ -48,4 +47,10 @@ function AlienSpawner.register(cfg)
end)
end
function AlienSpawner.get_extra_map_info(config)
return [[Alien Spawner, aliens might spawn when mining!
Spawn chance: ]] .. (config.alien_probability * 100) .. [[%
Minimum spawn distance: ]] .. config.alien_minimum_distance .. ' tiles'
end
return AlienSpawner

View File

@ -104,7 +104,7 @@ local function create_collapse_template(positions, surface)
return tiles, entities
end
local function collapse(args, surface, position)
local function collapse(args)
local position = args.position
local surface = args.surface
local positions = {}
@ -169,13 +169,17 @@ local function on_collapse_triggered(event)
end
end
local function on_built_tile(event)
local strength = support_beam_entities[event.item.name]
local function on_built_tile(surface, new_tile, tiles)
local new_tile_strength = support_beam_entities[new_tile.name]
if strength then
local surface = game.surfaces[event.surface_index]
for _, tile in pairs(event.tiles) do
stress_map_blur_add(surface, tile.position, -1 * strength)
for _, tile in pairs(tiles) do
if new_tile_strength then
stress_map_blur_add(surface, tile.position, -1 * new_tile_strength, 'on_built_tile')
end
local old_tile_strength = support_beam_entities[tile.old_tile.name]
if (old_tile_strength) then
stress_map_blur_add(surface, tile.position, old_tile_strength, 'on_built_tile')
end
end
end
@ -276,14 +280,18 @@ end
@param global_config Table {@see Diggy.Config}.
]]
function DiggyCaveCollapse.register(global_config)
config = global_config.features.DiggyCaveCollapse
function DiggyCaveCollapse.register(cfg)
config = cfg
support_beam_entities = config.support_beam_entities
Event.add(DiggyCaveCollapse.events.on_collapse_triggered, on_collapse_triggered)
Event.add(defines.events.on_robot_built_entity, on_built_entity)
Event.add(defines.events.on_robot_built_tile, on_built_tile)
Event.add(defines.events.on_player_built_tile, on_built_tile)
Event.add(defines.events.on_robot_built_tile, function (event)
on_built_tile(event.robot.surface, event.item, event.tiles)
end)
Event.add(defines.events.on_player_built_tile, function (event)
on_built_tile(game.surfaces[event.surface_index], event.item, event.tiles)
end)
Event.add(defines.events.on_robot_mined_tile, on_robot_mined_tile)
Event.add(defines.events.on_player_mined_tile, on_player_mined_tile)
Event.add(defines.events.on_robot_mined_entity, on_mined_entity)
@ -584,4 +592,9 @@ mask_disc_blur = function(x_start, y_start, factor, callback)
end
end
function DiggyCaveCollapse.get_extra_map_info(config)
return [[Alien Spawner, aliens might spawn when mining!
Place stone walls, stone paths and (refined) concrete to reinforce the mine. If you see cracks appear, run!]]
end
return DiggyCaveCollapse

View File

@ -49,10 +49,35 @@ local artificial_tiles = {
['deepwater-green'] = true,
}
local function on_mined_tile(surface, tiles)
local new_tiles = {}
for _, tile in pairs(tiles) do
if (artificial_tiles[tile.old_tile.name]) then
table.insert(new_tiles, { name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
end
Template.insert(surface, new_tiles, {})
end
local function on_built_tile(surface, item, old_tile_and_positions)
if ('landfill' ~= item.name) then
return
end
local tiles = {}
for _, tile in pairs(old_tile_and_positions) do
table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
Template.insert(surface, tiles)
end
--[[--
Registers all event handlers.
]]
function DiggyHole.register(cfg)
function DiggyHole.register(config)
Event.add(defines.events.on_entity_died, function (event)
diggy_hole(event.entity)
end)
@ -68,27 +93,19 @@ function DiggyHole.register(cfg)
end)
Event.add(defines.events.on_robot_mined_tile, function(event)
local tiles = {}
for _, tile in pairs(event.tiles) do
if (artificial_tiles[tile.old_tile.name]) then
table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
end
Template.insert(event.robot.surface, tiles, {})
on_mined_tile(event.robot.surface, event.tiles)
end)
Event.add(defines.events.on_player_mined_tile, function(event)
local tiles = {}
on_mined_tile(game.surfaces[event.surface_index], event.tiles)
end)
for _, tile in pairs(event.tiles) do
if (artificial_tiles[tile.old_tile.name]) then
table.insert(tiles, {name = 'dirt-' .. math.random(1, 7), position = tile.position})
end
end
Event.add(defines.events.on_robot_built_tile, function (event)
on_built_tile(event.robot.surface, item, tiles)
end)
Template.insert(game.surfaces[event.surface_index], tiles, {})
Event.add(defines.events.on_player_built_tile, function (event)
on_built_tile(game.surfaces[event.surface_index], event.item, event.tiles)
end)
end

View File

@ -16,12 +16,12 @@ global.MarketExchange = {
stone_sent_to_surface = 0,
}
local on_init;
--[[--
Registers all event handlers.
]]
function MarketExchange.register(cfg)
local config = cfg.features.MarketExchange
function MarketExchange.register(config)
local market_items = {
{price = {{config.currency_item, 50}}, offer = {type = 'nothing', effect_description = 'Send ' .. config.stone_to_surface_amount .. ' stone to the surface'}},
}
@ -37,15 +37,18 @@ function MarketExchange.register(cfg)
end
local on_market_timeout_finished = Token.register(function(params)
Template.market(game.surfaces.nauvis, {x = 0, y = -5}, game.forces.player, params.currency_item, params.market_items)
Template.market(params.surface, params.position, params.player_force, params.currency_item, params.market_items)
end)
Event.on_init(function()
Task.set_timeout_in_ticks(360, on_market_timeout_finished, {
on_init = function()
Task.set_timeout_in_ticks(60, on_market_timeout_finished, {
surface = game.surfaces.nauvis,
position = {x = 0, y = -5},
player_force = game.forces.player,
currency_item = config.currency_item,
market_items = market_items,
})
end)
end
Event.add(defines.events.on_market_item_purchased, function (event)
@ -57,4 +60,16 @@ function MarketExchange.register(cfg)
end)
end
function MarketExchange.get_extra_map_info(config)
return 'Market Exchange, trade your stone or send it to the surface'
end
function MarketExchange.on_init()
if ('function' ~= type(on_init)) then
error('Expected local on_init in MarketExchange to have a function assigned.')
end
on_init()
end
return MarketExchange

View File

@ -35,9 +35,7 @@ end
--[[--
Registers all event handlers.
]]
function MiningEfficiency.register(cfg)
local config = cfg.features.MiningEfficiency
function MiningEfficiency.register(config)
global.MiningEfficiency.default_mining_speed = config.default_mining_speed
Event.add(
@ -53,10 +51,13 @@ function MiningEfficiency.register(cfg)
)
end
Event.on_init(
function()
update_mining_speed(game.forces.player)
end
)
function MiningEfficiency.get_extra_map_info(config)
return [[Mining Efficiency, increase your mining efficiency by researching mining productivity!
Efficiency increase per level: ]] .. config.mining_speed_productivity_multiplier .. '%'
end
function MiningEfficiency.on_init()
update_mining_speed(game.forces.player)
end
return MiningEfficiency

View File

@ -50,8 +50,7 @@ end
--[[--
Registers all event handlers.
]]
function ScatteredResources.register(cfg)
local config = cfg.features.ScatteredResources
function ScatteredResources.register(config)
function sum(t)
local sum = 0
for _, v in pairs(t) do
@ -95,4 +94,9 @@ function ScatteredResources.register(cfg)
global.ScatteredResources.can_spawn_resources = true
end
function ScatteredResources.get_extra_map_info(config)
return [[Scattered Resources, resources are everywhere!
Scans of the mine have shown greater amounts of resources to be deeper in the mine]]
end
return ScatteredResources

View File

@ -16,14 +16,14 @@ function SetupPlayer.register(config)
Event.add(defines.events.on_player_created, function (event)
local player = game.players[event.player_index]
for _, item in pairs(config.features.SetupPlayer.starting_items) do
for _, item in pairs(config.starting_items) do
player.insert(item)
end
player.teleport({x = 0, y = 0})
Debug.cheat(function()
player.force.manual_mining_speed_modifier = config.features.SetupPlayer.cheats.manual_mining_speed_modifier
player.force.manual_mining_speed_modifier = config.cheats.manual_mining_speed_modifier
end)
end)
end

View File

@ -34,8 +34,8 @@ local function handle_noise(name, surface, position)
Task.set_timeout_in_ticks(1, do_mine, {surface = surface, position = position})
if ('water' == name) then
-- water is lower because for some odd reason it doesn't always want to mine it properly
Task.set_timeout_in_ticks(5, do_spawn_tile, { surface = surface, tile = { name = 'deepwater-green', position = position}})
-- water is slower because for some odd reason it doesn't always want to mine it properly
Task.set_timeout_in_ticks(3, do_spawn_tile, { surface = surface, tile = { name = 'deepwater-green', position = position}})
return
end
@ -52,9 +52,7 @@ end
local room_noise_minimum_distance_sq
function SimpleRoomGenerator.register(cfg)
local config = cfg.features.SimpleRoomGenerator
function SimpleRoomGenerator.register(config)
room_noise_minimum_distance_sq = config.room_noise_minimum_distance * config.room_noise_minimum_distance
local function get_noise(surface, x, y)
@ -90,4 +88,8 @@ function SimpleRoomGenerator.register(cfg)
end
end
function SimpleRoomGenerator.get_extra_map_info(config)
return 'Simple Room Generator, digging around might open rooms!'
end
return SimpleRoomGenerator

View File

@ -18,7 +18,7 @@ local daytime
]]
function StartingZone.register(config)
local callback_token
local starting_zone_size = config.features.StartingZone.starting_size
local starting_zone_size = config.starting_size
local function on_chunk_generated(event)
local start_point_area = {{-1, -1}, {0, 0}}
@ -68,16 +68,15 @@ function StartingZone.register(config)
Event.add_removable(defines.events.on_chunk_generated, callback_token)
daytime = config.features.StartingZone.daytime
daytime = config.daytime
end
Event.on_init(
function()
local surface = game.surfaces.nauvis
function StartingZone.on_init()
local surface = game.surfaces.nauvis
surface.daytime = daytime
surface.freeze_daytime = 1
end
surface.daytime = daytime
surface.freeze_daytime = 1
end
)
return StartingZone

View File

@ -2,6 +2,7 @@
local Config = require 'map_gen.Diggy.Config'
local Debug = require 'map_gen.Diggy.Debug'
local ScenarioInfo = require 'info'
local Event = require 'utils.event'
require 'utils.list_utils'
require 'utils.utils'
@ -60,23 +61,26 @@ function Scenario.register(debug)
local extra_map_info = ''
each_enabled_feature(
function(feature_name, feature_data)
function(feature_name, feature_config)
local feature = require ('map_gen.Diggy.Feature.' .. feature_name)
if ('function' ~= type(feature.register)) then
error('Feature ' .. feature_name .. ' did not define a register function.')
end
feature.register(Config)
feature.register(feature_config)
if ('function' == type(feature.extra_map_info)) then
extra_map_info = extra_map_info .. '\n' .. feature.extra_map_info(Config)
if ('function' == type(feature.get_extra_map_info)) then
extra_map_info = extra_map_info .. feature.get_extra_map_info(feature_config) .. '\n\n'
end
if ('function' == type(feature.on_init)) then
Event.on_init(feature.on_init)
end
end
)
ScenarioInfo.set_map_name('Diggy')
ScenarioInfo.set_map_description('Dig your way through!')
-- Be careful though, the cave might collapse!\nUse stone walls, stone path and concrete to reinforce the cave.
ScenarioInfo.set_map_extra_info(extra_map_info)
scenario_registered = true

View File

@ -215,6 +215,8 @@ function Template.market(surface, position, force, currency_item, market_invento
text = ' Market',
position = position,
})
script.raise_event(Template.events.on_placed_entity, {entity = market})
end
return Template

View File

@ -91,7 +91,7 @@ sand_shape = b.apply_entity(sand_shape, do_ores)
water_shape = b.change_tile(water_shape, true, 'water')
local oil = b.resource(b.full_shape, 'crude-oil', value(500000, 2500))
local oil = b.resource(b.full_shape, 'crude-oil', value(300000, 2000))
local function do_oil(x, y, world)
if math.random(16384) == 1 then
local e = oil(x, y, world)

View File

@ -0,0 +1,15 @@
local b = require 'map_gen.shared.builders'
local beach = require 'map_gen.presets.beach'
local start_pound = b.circle(6)
start_pound = b.translate(start_pound, 0, -16)
start_pound = b.change_tile(start_pound, true, 'water')
beach = b.translate(beach, 0, -64)
local map = b.any {start_pound, beach, b.translate(b.flip_y(beach), -51200, 0)}
map = b.rotate(map, degrees(45))
return map

View File

@ -69,6 +69,7 @@ require "map_gen.combined.diggy"
--shape = require "map_gen.presets.line_and_tree"
--shape = require "map_gen.presets.square_spiral"
--shape = require "map_gen.presets.beach"
--shape = require "map_gen.presets.double_beach"
--shape = require "map_gen.presets.factory"
--shape = require "map_gen.presets.triangle_of_death"
--shape = require "map_gen.presets.world_map"

View File

@ -143,7 +143,15 @@ local function on_capsule_used(event)
end
end
local function on_player_joined(event)
local player = game.players[event.player_index]
if string.match(player.name,"^[Ili1|]+$") then
game.ban_player(player) --No reason given, to not give them any hints to change their name
end
end
Event.add(defines.events.on_player_ammo_inventory_changed, ammo_changed)
Event.add(defines.events.on_player_joined_game, on_player_joined)
Event.add(defines.events.on_player_deconstructed_area, on_player_deconstructed_area)
--Event.add(defines.events.on_player_mined_entity, on_player_mined_item)
Event.add(defines.events.on_player_used_capsule, on_capsule_used)

View File

@ -25,7 +25,8 @@ Module.donators = {
Module.welcome_messages = {
['Linaori'] = 'I present to you Linaori of house Refactorio, Lady of the Void, Remover of Spaghetti, Queen of the Endless Nauvis, Breaker of Biters and Mother of Code!',
['Valansch'] = 'Welcome Valansch, <insert custom welcome message here>.',
['der-dave.com'] = "Dave doesn't want a welcome message."
['der-dave.com'] = 'Dave doesn\'t want a welcome message.',
['robertkruijt'] = 'The general of the army has arived!'
}
return Module

View File

@ -979,5 +979,24 @@ return {
['crayzz2'] = true,
['Gerkiz'] = true,
['piterfersin'] = true,
['SiMoZ_287'] = true
['SiMoZ_287'] = true,
['SSeltmann'] = true,
['AbsoluteZeroIs0K'] = true,
['jufacto'] = true,
['okan009'] = true,
['CounterfeitThe'] = true,
['TZsec'] = true,
['jamesh92'] = true,
['Flameoguy'] = true,
['Toledini'] = true,
['alnmike'] = true,
['Krzys132'] = true,
['jrz126'] = true,
['Rothguard'] = true,
['Rascher'] = true,
['XeoXius'] = true,
['InphinitePhractals'] = true,
['Breadface'] = true,
['safariursis'] = true,
['Marucan'] = true
}