1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-09-16 09:16:22 +02:00

Merge branch 'develop' into dev_diggy_compound_clusters

This commit is contained in:
Rdjrjqouqcu
2018-11-15 20:10:43 -05:00
13 changed files with 1444 additions and 1263 deletions

View File

@@ -4,9 +4,6 @@ require 'utils.utils'
require 'utils.list_utils'
require 'utils.math'
local Game = require 'utils.game'
local Event = require 'utils.event'
require 'map_gen.shared.perlin_noise'
require 'map_layout'
@@ -16,6 +13,7 @@ require 'features.bot'
-- Library modules which, if missing, will cause other feature modules to fail
require 'features.base_data'
require 'features.follow'
require 'features.player_create'
require 'features.user_groups'
-- Feature modules, each can be disabled
@@ -37,7 +35,7 @@ require 'features.custom_commands'
-- GUIs the order determines the order they appear from left to right.
-- These can be safely disabled. Some map presets will add GUI modules themselves.
require 'features.gui.info'
local info = require 'features.gui.info'
require 'features.gui.player_list'
require 'features.gui.poll'
require 'features.gui.tag_group'
@@ -46,27 +44,3 @@ require 'features.gui.blueprint_helper'
require 'features.gui.paint'
require 'features.gui.score'
require 'features.gui.popup'
local function player_created(event)
local player = Game.get_player_by_index(event.player_index)
if not player or not player.valid then
return
end
if (global.scenario.config.fish_market.enable) then
player.insert {name = MARKET_ITEM, count = 10}
end
player.insert {name = 'iron-gear-wheel', count = 8}
player.insert {name = 'iron-plate', count = 16}
player.print('Welcome to our Server. You can join our Discord at: redmew.com/discord')
player.print('Click the question mark in the top left corner for server infomation and map details.')
player.print('And remember.. Keep Calm And Spaghetti!')
local gui = player.gui
gui.top.style = 'slot_table_spacing_horizontal_flow'
gui.left.style = 'slot_table_spacing_vertical_flow'
end
Event.add(defines.events.on_player_created, player_created)

View File

@@ -3,6 +3,10 @@
local Game = require 'utils.game'
local Event = require 'utils.event'
local prefix = '## - '
global.mention_enabled = true
local hodor_messages = {
{'Hodor.', 16},
{'Hodor?', 16},
@@ -72,6 +76,7 @@ end
local function hodor(event)
local message = event.message:lower()
if message:match('hodor') then
local index = math.random(1, message_weight_sum)
local message_weight_sum = 0
@@ -86,12 +91,12 @@ local function hodor(event)
-- player_index is nil if the message came from the server,
-- and indexing Game.players with nil is apparently an error.
local player = Game.get_player_by_index(event.player_index)
local player_index = event.player_index
if not player_index then
return
end
local player = Game.get_player_by_index(event.player_index)
if not player or not player.valid then
return
end
@@ -115,6 +120,54 @@ local function hodor(event)
end
end
end
-- Gives a sound notification to a mentioned player using #[player-name]
if global.mention_enabled then
local missing_player_string
local not_found = 0
local admin_call = false
for word in event.message:gmatch('#%S+') do
local lower_word = word:lower()
if lower_word == '#admin' or lower_word == '#moderator' then
admin_call = true
end
local cannot_mention = {}
for _, p in ipairs(game.connected_players) do
if admin_call and p.admin then
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned #admin!', {r = 1, g = 1, b = 0, a = 1})
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
end
if not admin_call and '#'..p.name == word then
if p.name == player.name then
player.print(prefix..'Can\'t mention yourself!', {r = 1, g = 0, b = 0, a = 1})
break;
end
p.print(prefix..Game.get_player_by_index(event.player_index).name..' mentioned you!', {r = 1, g = 1, b = 0, a = 1})
p.play_sound{path='utility/new_objective', volume_modifier = 1 }
if _DEBUG then
player.print(prefix..'Successful mentioned '..p.name, {r = 0, g = 1, b = 0, a = 1})
end
elseif not admin_call then
not_found = not_found + 1
table.insert(cannot_mention, (word .. ', '))
end
end
for _, pname in ipairs(cannot_mention) do
missing_player_string = missing_player_string~=nil and missing_player_string .. pname or pname
end
admin_call = false
end
if missing_player_string ~= nil then
missing_player_string = string.sub(missing_player_string, 1, (string.len(missing_player_string)-2))
if not_found > 1 then
player.print(prefix..'Players not found: ' .. missing_player_string, {r = 1, g = 1, b = 0, a = 1})
else
player.print(prefix..'Player not found: ' .. missing_player_string, {r = 1, g = 1, b = 0, a = 1})
end
end
end
end
Event.add(defines.events.on_console_chat, hodor)

View File

@@ -491,60 +491,6 @@ local function jail_player(cmd)
Report.jail(player, cmd['parameter'])
end
local function unjail_player(cmd)
local default_group = 'Default'
local player = game.player
-- Check if the player can run the command
if player and not player.admin then
Utils.cant_run(cmd.name)
return
end
-- Check if the target is valid (copied from the invoke command)
local target = cmd['parameter']
if target == nil then
Game.player_print('Usage: /unjail <player>')
return
end
local target_player = game.players[target]
if not target_player then
Game.player_print('Unknown player.')
return
end
local permissions = game.permissions
-- Check if the permission group exists, if it doesn't, create it.
local permission_group = permissions.get_group(default_group)
if not permission_group then
permission_group = permissions.create_group(default_group)
end
local jail_permission_group = permissions.get_group('Jail')
if (not jail_permission_group) or target_player.permission_group ~= jail_permission_group then
Game.player_print('The player ' .. target .. ' is already not in Jail.')
return
end
-- Move player
permission_group.add_player(target)
-- Set player to a non-shooting state (solves a niche case where players jailed while shooting will be locked into a shooting state)
target_player.shooting_state.state = 0
-- Check that it worked
if target_player.permission_group == permission_group then
-- Let admin know it worked, let target know what's going on.
Game.player_print(target .. ' has been returned to the default group. They have been advised of this.')
target_player.print('Your ability to perform actions has been restored')
else
-- Let admin know it didn't work.
Game.player_print(
'Something went wrong in the unjailing of ' ..
target .. '. You can still change their group via /permissions and inform them.'
)
end
end
local function all_tech()
if game.player then
game.player.force.research_all_technologies()
@@ -647,34 +593,11 @@ commands.add_command(
commands.add_command(
'unjail',
'<player> restores ability for a player to perform actions. (Admins only)',
unjail_player
Report.unjail_player
)
commands.add_command('a', 'Admin chat. Messages all other admins (Admins only)', admin_chat)
local function report(cmd)
local reporting_player = game.player
if reporting_player then
local params = {}
for param in string.gmatch(cmd.parameter, '%S+') do
table.insert(params, param)
end
if #params < 2 then
reporting_player.print('Please enter then name of the offender and the reason for the report.')
return nil
end
local reported_player_name = params[1] or ''
local reported_player = game.players[reported_player_name]
if not reported_player then
reporting_player.print(reported_player_name .. ' does not exist.')
return nil
end
Report.report(reporting_player, reported_player, string.sub(cmd.parameter, string.len(params[1]) + 2))
end
end
commands.add_command('report', '<griefer-name> <message> Reports a user to admins', report)
commands.add_command('report', '<griefer-name> <message> Reports a user to admins', Report.cmd_report)
commands.add_command(
'showreports',

View File

@@ -706,6 +706,10 @@ Gui.on_custom_close(
local Public = {}
function Public.show_info(player)
toggle(player)
end
function Public.get_map_name()
return editable_info[map_name_key]
end

View File

@@ -0,0 +1,30 @@
local Game = require 'utils.game'
local Event = require 'utils.event'
local info = require 'features.gui.info'
local function player_created(event)
local player = Game.get_player_by_index(event.player_index)
if not player or not player.valid then
return
end
if (global.scenario.config.fish_market.enable) then
player.insert {name = MARKET_ITEM, count = 10}
end
player.insert {name = 'iron-gear-wheel', count = 8}
player.insert {name = 'iron-plate', count = 16}
player.print('Trouble chatting? Change the keybinding in:')
player.print('Options -> Controls -> Toggle Lua console')
local gui = player.gui
gui.top.style = 'slot_table_spacing_horizontal_flow'
gui.left.style = 'slot_table_spacing_vertical_flow'
if info ~= nil then
info.show_info({player = player})
end
end
Event.add(defines.events.on_player_created, player_created)

View File

@@ -9,6 +9,8 @@ local report_close_button_name = Gui.uid_name()
local report_tab_button_name = Gui.uid_name()
local jail_offender_button_name = Gui.uid_name()
local report_body_name = Gui.uid_name()
local prefix = '------------------NOTICE-------------------'
local prefix_e = '--------------------------------------------'
global.reports = {}
global.player_report_data = {}
@@ -78,8 +80,8 @@ Module.show_reports = function(player)
end
end
local report_body = report_frame.add {type = "scroll-pane", name = report_body_name, horizontal_scroll_policy = "never", vertical_scroll_policy="never"}
report_frame.add {type = 'button', name = report_close_button_name, caption = 'Close'}
report_frame.add {type = 'button', name = report_close_button_name, caption = 'Close' }
draw_report(report_body, #reports)
end
@@ -104,6 +106,28 @@ function Module.report(reporting_player, reported_player, message)
end
end
function Module.cmd_report(cmd)
local reporting_player = game.player
if reporting_player then
local params = {}
for param in string.gmatch(cmd.parameter, '%S+') do
table.insert(params, param)
end
if #params < 2 then
reporting_player.print('Please enter then name of the offender and the reason for the report.')
return nil
end
local reported_player_name = params[1] or ''
local reported_player = game.players[reported_player_name]
if not reported_player then
reporting_player.print(reported_player_name .. ' does not exist.')
return nil
end
Module.report(reporting_player, reported_player, string.sub(cmd.parameter, string.len(params[1]) + 2))
end
end
function Module.jail(player, target)
-- Set the name of the jail permission group
local jail_name = 'Jail'
@@ -123,10 +147,10 @@ function Module.jail(player, target)
end
if target_player.permission_group == permission_group then
player.print('The player ' .. target .. ' is already in Jail.')
player.print('The player ' .. target .. ' is already in jail.')
return
end
-- Set all permissions to disabled
for action_name, _ in pairs(defines.input_action) do
permission_group.set_allows_action(defines.input_action[action_name], false)
@@ -135,7 +159,6 @@ function Module.jail(player, target)
permission_group.set_allows_action(defines.input_action.write_to_console, true)
permission_group.set_allows_action(defines.input_action.edit_permission_group, true)
-- Kick player out of vehicle
target_player.driving=false
-- Add player to jail group
@@ -146,20 +169,82 @@ function Module.jail(player, target)
while target_player.get_inventory(defines.inventory.player_guns)[target_player.character.selected_gun_index].valid_for_read do
target_player.remove_item(target_player.get_inventory(defines.inventory.player_guns)[target_player.character.selected_gun_index])
end
target_player.print('Your active weapon has been removed because you were shooting while jailed. Your gun will *not* be returned to you in the event of being unjailed.')
target_player.print(prefix)
target_player.print('Your active weapon has been removed because you were shooting while jailed.')
target_player.print('Your gun will *not* be returned to you.')
target_player.print(prefix_e)
end
-- Check that it worked
if target_player.permission_group == permission_group then
-- Let admin know it worked, let target know what's going on.
player.print(target .. ' has been jailed. They have been advised of this.')
target_player.print('You have been placed in jail by a server admin. The only action you can currently perform is chatting. Please respond to inquiries from the admin.')
target_player.print(prefix)
target_player.print('You have been placed in jail by a server admin. The only action avaliable to you is chatting.')
target_player.print('Please respond to inquiries from the admins.', {r = 1, g = 1, b = 0, a = 1})
target_player.print(prefix_e)
else
-- Let admin know it didn't work.
player.print('Something went wrong in the jailing of ' .. target .. '. You can still change their group via /permissions.')
end
end
function Module.unjail_player(cmd)
local default_group = 'Default'
local player = game.player
-- Check if the player can run the command
if player and not player.admin then
Utils.cant_run(cmd.name)
return
end
-- Check if the target is valid (copied from the invoke command)
local target = cmd['parameter']
if target == nil then
Game.player_print('Usage: /unjail <player>')
return
end
local target_player = game.players[target]
if not target_player then
Game.player_print('Unknown player.')
return
end
local permissions = game.permissions
-- Check if the permission group exists, if it doesn't, create it.
local permission_group = permissions.get_group(default_group)
if not permission_group then
permission_group = permissions.create_group(default_group)
end
local jail_permission_group = permissions.get_group('Jail')
if (not jail_permission_group) or target_player.permission_group ~= jail_permission_group then
Game.player_print('The player ' .. target .. ' is already not in Jail.')
return
end
-- Move player
permission_group.add_player(target)
-- Set player to a non-shooting state (solves a niche case where players jailed while shooting will be locked into a shooting state)
target_player.shooting_state.state = 0
-- Check that it worked
if target_player.permission_group == permission_group then
-- Let admin know it worked, let target know what's going on.
Game.player_print(target .. ' has been returned to the default group. They have been advised of this.')
target_player.print(prefix)
target_player.print('Your ability to perform actions has been restored', {r = 0, g = 1, b = 0, a = 1})
target_player.print(prefix_e)
else
-- Let admin know it didn't work.
Game.player_print(
'Something went wrong in the unjailing of ' ..
target .. '. You can still change their group via /permissions and inform them.'
)
end
end
Gui.on_custom_close(
report_frame_name,
function(event)
@@ -179,7 +264,7 @@ Gui.on_click(
function(event)
Module.jail(event.player, string.sub(event.element.caption, 6))
end
)
)
Gui.on_click(
report_tab_button_name,
@@ -200,7 +285,7 @@ local reporting_input_name = Gui.uid_name()
Module.spawn_reporting_popup = function(player, reported_player)
local center = player.gui.center
local center = player.gui.center
local reporting_popup = center[reporting_popup_name]
if reporting_popup and reporting_popup.valid then
@@ -219,14 +304,13 @@ Module.spawn_reporting_popup = function(player, reported_player)
reporting_popup.add {
type = 'label',
caption = 'Report message:'
}
}
local input = reporting_popup.add {type = 'text-box', name=reporting_input_name}
input.style.width = 400
input.style.height = 85
local button_flow = reporting_popup.add {type = "flow"}
button_flow.add {type = "button", name = reporting_submit_button_name, caption="Submit"}
button_flow.add {type = "button", name = reporting_cancel_button_name, caption="Cancel"}
end
Gui.on_custom_close(
@@ -251,11 +335,13 @@ Gui.on_click(
local msg = frame[reporting_input_name].text
local data = Gui.get_data(frame)
local reported_player_index = data["reported_player_index"]
local print = event.player.print
Gui.destroy(frame)
Module.report(event.player, Game.get_player_by_index(reported_player_index), msg)
event.player.print("Sucessfully reported " .. Game.get_player_by_index(reported_player_index).name)
print(prefix)
print("You have successfully reported the player: " .. Game.get_player_by_index(reported_player_index).name)
print(prefix_e)
end
)

View File

@@ -97,7 +97,7 @@ function Debug.print_grid_value(value, surface, position, scale, offset, immutab
if type(immutable) ~= 'boolean' then
immutable = false
end
if not is_string then
scale = scale or 1
offset = offset or 0
@@ -148,4 +148,77 @@ function Debug.print_grid_value(value, surface, position, scale, offset, immutab
}.active = false
end
--[[--
Prints a colored value on a location. When given a color_value and a delta_color,
will change the color of the text from the base to base + value * delta. This will
make the color of the text range from 'base_color' to 'base_color + delta_color'
as the color_value ranges from 0 to 1
@param value of number to be displayed
@param surface LuaSurface
@param position Position {x, y}
@param scale float
@param offset float position offset
@param immutable bool if immutable, only set, never do a surface lookup, values never change
@param color_value float How far along the range of values of colors the value is to be displayed
@param base_color {r,g,b} The color for the text to be if color_value is 0
@param delta_color {r,g,b} The amount to correct the base_color if color_value is 1
@param under_bound {r,g,b} The color to be used if color_value < 0
@param over_bound {r,g,b} The color to be used if color_value > 1
]]
function Debug.print_colored_grid_value(value, surface, position, scale, offset, immutable,
color_value, base_color, delta_color, under_bound, over_bound)
local is_string = type(value) == 'string'
-- default values:
local color = base_color or {r = 1, g = 1, b = 1}
local d_color = delta_color or {r = 0, g = 0, b = 0}
local u_color = under_bound or color
local o_color = over_bound or color
if (color_value < 0) then
color = u_color
elseif (color_value > 1) then
color = o_color
else
color = { r = color.r + color_value * d_color.r,
g = color.g + color_value * d_color.g,
b = color.b + color_value * d_color.b }
end
text = value
if type(immutable) ~= 'boolean' then
immutable = false
end
if not is_string then
offset = offset or 0
position = {x = position.x + offset, y = position.y + offset}
-- round at precision of 2
text = floor(100 * value) * 0.01
if (0 == text) then
text = '0.00'
end
end
if not immutable then
local text_entity = surface.find_entity('flying-text', position)
if text_entity then
text_entity.text = text
text_entity.color = color
return
end
end
surface.create_entity{
name = 'flying-text',
color = color,
text = text,
position = position
}.active = false
end
return Debug

View File

@@ -467,7 +467,9 @@ local function add_fraction(stress_map, x, y, fraction)
end
if (enable_stress_grid) then
local surface = game.surfaces[stress_map.surface_index]
Debug.print_grid_value(value, surface, {x = x, y = y}, 4, 0.5)
Debug.print_colored_grid_value(value, surface, {x = x, y = y}, 4, 0.5, false,
value / stress_threshold_causing_collapse, {r = 0, g = 1, b = 0}, {r = 1, g = -1, b = 0},
{r = 0, g = 1, b = 0}, {r = 1, g = 1, b = 1})
end
return value
end

View File

@@ -124,8 +124,8 @@ local function update_market_contents(market)
for _, unlockable in pairs(config.unlockables) do
local stone_unlock = calculate_level(unlockable.level)
local is_in_range = stone_unlock > stone_tracker.previous_stone_sent_to_surface and stone_unlock <= stone_tracker.stone_sent_to_surface
if (is_in_range and stone_tracker.current_level == old_level) then
if (stone_tracker.current_level == old_level) then
while (calculate_level(stone_tracker.current_level) < stone_tracker.stone_sent_to_surface) do
if (calculate_level(stone_tracker.current_level+1) <= stone_tracker.stone_sent_to_surface) then
stone_tracker.current_level = stone_tracker.current_level + 1
@@ -149,7 +149,9 @@ local function update_market_contents(market)
})
end
end
MarketExchange.update_gui()
if (old_level < stone_tracker.current_level) then
for _, buffs in pairs(config.buffs) do
if (buffs.prototype.name == 'mining_speed') then
@@ -463,15 +465,15 @@ end
local function toggle(event)
local player = event.player
local center = player.gui.center
local frame = center['Diggy.MarketExchange.Frame']
local left = player.gui.left
local frame = left['Diggy.MarketExchange.Frame']
if (frame) then
Gui.destroy(frame)
return
end
frame = center.add({name = 'Diggy.MarketExchange.Frame', type = 'frame', direction = 'vertical'})
frame = left.add({name = 'Diggy.MarketExchange.Frame', type = 'frame', direction = 'vertical'})
local market_progressbars = frame.add({type = 'flow', direction = 'vertical'})
local market_list_heading = frame.add({type = 'flow', direction = 'horizontal'})
@@ -503,7 +505,6 @@ local function toggle(event)
Gui.set_data(frame, data)
player.opened = frame
end
local function on_player_created(event)
@@ -519,6 +520,18 @@ Gui.on_custom_close('Diggy.MarketExchange.Frame', function (event)
event.element.destroy()
end)
function MarketExchange.update_gui()
for _, p in ipairs(game.connected_players) do
local frame = p.gui.left['Diggy.MarketExchange.Frame']
if frame and frame.valid then
local data = {player = p}
toggle(data)
toggle(data)
end
end
end
function MarketExchange.on_init()
Task.set_timeout_in_ticks(50, on_market_timeout_finished, {
surface = game.surfaces.nauvis,

View File

@@ -1,5 +1,13 @@
-- Inspired/copied from Beach.
--[[
Inspired/copied from Beach/Double beach by GrilledHam
Creates a diagonal, wavy ribbon world with only tiles. Vanilla ore and biter generation are unaffected.
Post-mortum analysis after 2018-11-15 run:
Exchange string used was: >>>eNptUT1IAzEY/T7T01pFCnYRVBy6VkQdFKQXQXAQR6FuXnupHLR3ctcO6qCDgoMiiIsudhXBzUFcBEEUFKpObhUXB0VF0EWoSZv0SvFB3r18L/l+cgBhGAIAQtoDKcfIBIgWSjkLC8yNOS7ju9aUmzdZzLGE1Wwyj7k5QkjAtCrfELNZdjGWNDymEaLNu4bn8XDQch1bZgh4hm3ymOblHFsEtJzLmDjVlncN28pn5UHA5tHP4upaL4hVXoGBclksroq8RbE4EJAHFLRUxkqnAVYnAPrGEXE5cjz5tLSrY9Xvp1J8yEjiTEZK61IkjqTYuJCCHiixosQ2xaEKvnRfVGvleGZZJEh9UTXXhIm49XZS+LksxvH38PN+Ojmno9UzMx3Ov8e52SKmaqrR/p7AqZoAVM6SLq1HHW9vBF511MSNiCA6wul8igCGO7gqbHLq6wbVWlyliVBMV/CtJnlW4kFvnCNKcUwk7xV0JahSsNYZSjlLq0aX7/Krg1Bf3vSHu1YVL+pKN/QQVT0M039GaIhE6x4+JOqYNXohtSb4CxZb1I7/WwI+PvSdROfdH4nTkzI=<<<
With seed: 2963296099
The players expanded the base easily and had too much access to resources. The biter frequency should be increased and the ore richness and/or size decreased.
There was a lot of space in the North-South direction for building, so play_area_width should be turned down significantly.
]]--
local b = require 'map_gen.shared.builders'
local perlin = require 'map_gen.shared.perlin_noise'
local Global = require 'utils.global'

View File

@@ -23,7 +23,7 @@ Module.donators = {
['shoghicp'] = d.rank + d.train,
['DuelleuD'] = d.rank + d.train,
['henrycn1997'] = d.rank + d.train,
['Raiguard'] = d.rank + d.train
['Raiguard'] = d.rank + d.train,
}
Module.welcome_messages = {
@@ -32,7 +32,8 @@ Module.welcome_messages = {
['der-dave.com'] = "Dave doesn't want a welcome message.",
['plague006'] = 'plague wrote this dumb message you have to read. If you want your own dumb on-join message be sure to donate on Patreon!',
['shoghicp'] = 'Need more servers!',
['aldldl'] = 'ALo\'s Here'
['aldldl'] = 'ALo\'s Here',
['Raiguard'] = 'I am... was... God. The one you call \'The Almighty\'. The creator of Factories. But now, I am dead. The Biters killed me. I am sorry.',
}
return Module

View File

@@ -35,4 +35,8 @@ return {
color = {r = 0, g = 0, b = 0, a = 0.5},
chat_color = {r = 0, g = 127, b = 0, a = 0.5}
},
['Raiguard'] = {
color = {r = 35, g = 140, b = 130, a = 0.5},
chat_color = {r = 35, g = 140, b = 130, a = 0.5}
}
}

File diff suppressed because it is too large Load Diff