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

Added a basic RedMew configuration setup (#502)

* Added a basic RedMew configuration setup
This commit is contained in:
Lynn 2018-12-06 12:18:52 +01:00 committed by Valansch
parent 21ecab0a59
commit bbfcdd4629
14 changed files with 227 additions and 275 deletions

View File

@ -56,7 +56,7 @@ local STD_BASE_CONTROL = 'lua52c+factorio+factorio_control+factorio_defines+fact
--[Assume Factorio Control stage as default]--
-------------------------------------------------------------------------------
std = STD_CONTROL
globals = {'print', 'math', 'table', '_DEBUG', '_CHEATS', 'MARKET_ITEM', 'ServerCommands'} -- RedMew-specific globals
globals = {'print', 'math', 'table', '_DEBUG', '_CHEATS', 'ServerCommands'} -- RedMew-specific globals
max_line_length = LINE_LENGTH
not_globals = NOT_GLOBALS

View File

@ -1,6 +1,5 @@
_DEBUG = false
_CHEATS = false
MARKET_ITEM = 'coin'
global.config = {
-- The title of the map
@ -15,23 +14,85 @@ global.config = {
-- New Scenario Features, appears in the "What's new" tab
new_info_key = 'Nothing is new. The world is at peace',
-- adds a player list icon and keeps track of data.
player_list = {
enable_coin_col = true,
enabled = true,
show_coin_column = true,
},
-- enables the poll system
poll = {
enabled = true,
},
-- enables players to create and join tags
tag_group = {
enabled = true,
},
-- enables players to create and prioritize tasks
tasklist = {
enabled = true,
},
-- enables the blueprint helper
blueprint_helper = {
enabled = true,
},
-- enables score and tracking thereof
score = {
enabled = true,
},
-- adds a paint brush
paint = {
enable = true,
enabled = true,
},
-- adds a fish market
fish_market = {
enable = true,
enabled = true,
market_item = 'coin',
},
-- automatically marks mines for deconstruction when they are depleted
-- currently not working with mods
auto_deconstruct = {
enabled = true,
},
-- adds anti-nuke griefing
nuke_control = {
enabled = true,
enable_autokick = true,
enable_autoban = true,
-- how long a player must be on the server to be allowed to use the nuke
nuke_min_time_hours = 3,
},
hodor = true,
auto_respond = true,
mentions = true,
-- adds a meltdown feature, requiring precise management
reactor_meltdown = {
enabled = true,
-- when enabled, controls whether it's on by default. State can be controlled with the /meltdown command.
on_by_default = false,
},
-- adds hodor responses to messages
hodor = {
enabled = true,
},
-- enable RedMew auto respond messages
auto_respond = {
enabled = true,
},
-- enable the mentioning system, which notifies a player when their name is mentioned
mentions = {
enabled = true,
},
}
return global.config

View File

@ -2,7 +2,7 @@
require 'utils.math'
-- Map layout and config dictate the map you play and the settings in it
require 'config'
local config = require 'config'
require 'map_layout'
-- Specific to RedMew hosts, can be disabled safely if not hosting on RedMew servers
@ -15,17 +15,27 @@ require 'features.player_create'
require 'features.user_groups'
-- Feature modules, each can be disabled safely
require 'features.autodeconstruct'
require 'features.chat_triggers'
if config.auto_deconstruct.enabled then
require 'features.autodeconstruct'
end
if config.hodor.enabled or config.auto_respond.enabled or config.mentions.enabled then
require 'features.chat_triggers'
end
require 'features.corpse_util'
require 'features.custom_commands'
require 'features.donator_messages'
require 'features.train_saviour'
require 'features.fish_market'
if config.fish_market.enabled then
require 'features.fish_market'
end
require 'features.free_item_logging'
require 'features.nuke_control'
if config.nuke_control.enabled then
require 'features.nuke_control'
end
require 'features.player_colors'
require 'features.reactor_meltdown'
if config.reactor_meltdown.enabled then
require 'features.reactor_meltdown'
end
require 'features.train_station_names'
require 'features.walkabout'
@ -33,11 +43,25 @@ require 'features.walkabout'
-- These can be safely disabled if you want less GUI items.
-- Some map presets will add GUI modules themselves.
require 'features.gui.info'
require 'features.gui.player_list'
require 'features.gui.poll'
require 'features.gui.tag_group'
require 'features.gui.tasklist'
require 'features.gui.blueprint_helper'
require 'features.gui.paint'
require 'features.gui.score'
if config.player_list.enabled then
require 'features.gui.player_list'
end
if config.poll.enabled then
require 'features.gui.poll'
end
if config.tag_group.enabled then
require 'features.gui.tag_group'
end
if config.tasklist.enabled then
require 'features.gui.tasklist'
end
if config.blueprint_helper.enabled then
require 'features.gui.blueprint_helper'
end
if config.paint.enabled then
require 'features.gui.paint'
end
if config.score.enabled then
require 'features.gui.score'
end
require 'features.gui.popup'

View File

@ -131,16 +131,14 @@ local function mentions(event)
end
end
local function on_console_chat(event)
if global.config.hodor then
hodor(event)
end
if global.config.auto_respond then
auto_respond(event)
end
if global.config.mentions then
mentions(event)
end
if global.config.hodor.enabled then
Event.add(defines.events.on_console_chat, hodor)
end
Event.add(defines.events.on_console_chat, on_console_chat)
if global.config.auto_respond.enabled then
Event.add(defines.events.on_console_chat, auto_respond)
end
if global.config.mentions.enabled then
Event.add(defines.events.on_console_chat, mentions)
end

View File

@ -8,13 +8,6 @@ It will spawn a few tiles north of the current position where your character is.
---MewMew---
!! now with speed boost item addon from air20 !!
to be added(maybe)
fix pet health at refresh
make pet faster
make pet follow you moar
--]]
local Event = require 'utils.event'
local Token = require 'utils.token'
@ -97,14 +90,6 @@ local function pre_player_mined_item(event)
end
local entity_drop_amount = {
--[[['small-biter'] = {low = -62, high = 1},
['small-spitter'] = {low = -62, high = 1},
['medium-biter'] = {low = -14, high = 1},
['medium-spitter'] = {low = -14, high = 1},
['big-biter'] = {low = -2, high = 1},
['big-spitter'] = {low = -2, high = 1},
['behemoth-biter'] = {low = 1, high = 1},
['behemoth-spitter'] = {low = 1, high = 1}, ]]
['biter-spawner'] = {low = 5, high = 15},
['spitter-spawner'] = {low = 5, high = 15},
['small-worm-turret'] = {low = 2, high = 8},
@ -137,43 +122,14 @@ local function fish_drop_entity_died(event)
Task.set_timeout_in_ticks(1, spill_items, {count = count, surface = entity.surface, position = entity.position})
end
end
--
--[[
local function pet(player, entity_name)
if not player then
player = game.connected_players[1]
else
player = game.players[player]
end
if not entity_name then
entity_name = 'small-biter'
end
if not global.player_pets then
global.player_pets = {}
end
local surface = player.surface
local pos = player.position
pos.y = pos.y + 1
local x = 1
x = x + #global.player_pets
global.player_pets[x] = {}
global.player_pets[x].entity = surface.create_entity {name = entity_name, position = pos, force = 'player'}
global.player_pets[x].owner = player.index
global.player_pets[x].id = x
end
]]--
local function reset_player_runningspeed(player)
local function reset_player_running_speed(player)
player.character_running_speed_modifier = global.player_speed_boost_records[player.index].pre_boost_modifier
global.player_speed_boost_records[player.index] = nil
end
local function boost_player_runningspeed(player, market)
local function boost_player_running_speed(player, market)
if global.player_speed_boost_records == nil then
global.player_speed_boost_records = {}
end
@ -196,7 +152,7 @@ local function boost_player_runningspeed(player, market)
if global.player_speed_boost_records[player.index].boost_lvl >= 4 then
game.print(string.format(boost_msg[global.player_speed_boost_records[player.index].boost_lvl], player.name))
reset_player_runningspeed(player)
reset_player_running_speed(player)
player.character.die(player.force, market)
return
end
@ -204,12 +160,12 @@ local function boost_player_runningspeed(player, market)
player.print(string.format(boost_msg[global.player_speed_boost_records[player.index].boost_lvl], player.name))
end
local function reset_player_miningspeed(player)
local function reset_player_mining_speed(player)
player.character_mining_speed_modifier = global.player_mining_boost_records[player.index].pre_mining_boost_modifier
global.player_mining_boost_records[player.index] = nil
end
local function boost_player_miningspeed(player, market)
local function boost_player_mining_speed(player, market)
if global.player_mining_boost_records == nil then
global.player_mining_boost_records = {}
end
@ -232,7 +188,7 @@ local function boost_player_miningspeed(player, market)
if global.player_mining_boost_records[player.index].boost_lvl >= 4 then
game.print(string.format(boost_msg[global.player_mining_boost_records[player.index].boost_lvl], player.name))
reset_player_miningspeed(player)
reset_player_mining_speed(player)
player.character.die(player.force, market)
return
end
@ -257,12 +213,12 @@ local function market_item_purchased(event)
if event.offer_index == 1 then -- Temporary speed bonus
local player = Game.get_player_by_index(player_index)
boost_player_runningspeed(player, market)
boost_player_running_speed(player, market)
end
if event.offer_index == 2 then -- Temporary mining bonus
local player = Game.get_player_by_index(player_index)
boost_player_miningspeed(player, market)
boost_player_mining_speed(player, market)
end
if event.offer_index == 3 then -- train saviour item
@ -270,52 +226,6 @@ local function market_item_purchased(event)
local train_savior_item = Market_items[offer_index].item
player.insert {name = train_savior_item, count = event.count}
end
--[[
if event.offer_index == 2 then
player.remove_item({name="small-plane", count=event.count})
local chance = 4
local x = math.random(1,3)
if x < 3 then
local x = math.random(1,chance)
if x < chance then
rolled_pet = "small-biter"
else
local x = math.random(1,chance)
if x < chance then
rolled_pet = "medium-biter"
else
local x = math.random(1,chance)
if x < chance then
rolled_pet = "big-biter"
else
rolled_pet = "behemoth-biter"
end
end
end
else
local x = math.random(1,chance)
if x < chance then
rolled_pet = "small-spitter"
else
local x = math.random(1,chance)
if x < chance then
rolled_pet = "medium-spitter"
else
local x = math.random(1,chance)
if x < chance then
rolled_pet = "big-spitter"
else
rolled_pet = "behemoth-spitter"
end
end
end
end
local str = string.format("%s bought his very own pet %s at the fish market!!", player.name, rolled_pet)
game.print(str)
pet(event.player_index, rolled_pet)
end
--]]
end
if not global.pet_command_rotation then
@ -323,13 +233,14 @@ if not global.pet_command_rotation then
end
local function on_180_ticks()
if game.tick % 900 == 0 then
local tick = game.tick
if tick % 900 == 0 then
if global.player_speed_boost_records then
for k, v in pairs(global.player_speed_boost_records) do
if game.tick - v.start_tick > 3000 then
if tick - v.start_tick > 3000 then
local player = Game.get_player_by_index(k)
if player.connected and player.character then
reset_player_runningspeed(player)
reset_player_running_speed(player)
end
end
end
@ -337,68 +248,15 @@ local function on_180_ticks()
if global.player_mining_boost_records then
for k, v in pairs(global.player_mining_boost_records) do
if game.tick - v.start_tick > 6000 then
if tick - v.start_tick > 6000 then
local player = Game.get_player_by_index(k)
if player.connected and player.character then
reset_player_miningspeed(player)
reset_player_mining_speed(player)
end
end
end
end
end
--[[
if global.player_pets then
for _, pets in pairs(global.player_pets) do
local player = game.players[pets.owner]
if
pcall(
function()
local x = pets.entity.name
end
)
then
if global.pet_command_rotation % 15 == 0 then
local surface = player.surface
local pet_pos = pets.entity.position
local pet_name = pets.entity.name
local pet_direction = pets.entity.direction
pets.entity.destroy()
pets.entity =
surface.create_entity {
name = pet_name,
position = pet_pos,
direction = pet_direction,
force = 'player'
}
end
if global.pet_command_rotation % 2 == 1 then
pets.entity.set_command(
{
type = defines.command.go_to_location,
destination = player.position,
distraction = defines.distraction.none
}
)
else
local fake_pos = pets.entity.position
pets.entity.set_command(
{
type = defines.command.go_to_location,
destination = fake_pos,
distraction = defines.distraction.none
}
)
end
else
global.player_pets[pets.id] = nil
local str = player.name .. '´s pet died ;_;'
game.print(str)
end
end
global.pet_command_rotation = global.pet_command_rotation + 1
end
]]--
end
local function fish_player_crafted_item(event)
@ -408,16 +266,25 @@ local function fish_player_crafted_item(event)
end
end
local function init()
if global.config.fish_market.enable then
commands.add_command('market', 'Places a fish market near you. (Admins only)', spawn_market)
local function player_created(event)
local player = Game.get_player_by_index(event.player_index)
Event.on_nth_tick(180, on_180_ticks)
Event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item)
Event.add(defines.events.on_entity_died, fish_drop_entity_died)
Event.add(defines.events.on_market_item_purchased, market_item_purchased)
Event.add(defines.events.on_player_crafted_item, fish_player_crafted_item)
if not player or not player.valid then
return
end
player.insert {name = market_item, count = 10}
end
local function init()
commands.add_command('market', 'Places a fish market near you. (Admins only)', spawn_market)
Event.on_nth_tick(180, on_180_ticks)
Event.add(defines.events.on_pre_player_mined_item, pre_player_mined_item)
Event.add(defines.events.on_entity_died, fish_drop_entity_died)
Event.add(defines.events.on_market_item_purchased, market_item_purchased)
Event.add(defines.events.on_player_crafted_item, fish_player_crafted_item)
Event.add(defines.events.on_player_created, player_created)
end
Event.on_init(init)

View File

@ -380,90 +380,101 @@ but you will lose a small plane. You can get planes from the market.
}
train_savior_label.style.single_line = false
grid.add {type = 'sprite', sprite = 'entity/player'}
local player_list = grid.add {type = 'label', caption = 'Player\nlist'}
player_list.style.font = 'default-listbox'
player_list.style.single_line = false
local player_list_label =
if global.config.player_list.enabled then
grid.add {type = 'sprite', sprite = 'entity/player'}
local player_list = grid.add {type = 'label', caption = 'Player\nlist'}
player_list.style.font = 'default-listbox'
player_list.style.single_line = false
local player_list_label =
grid.add {
type = 'label',
caption = [[
type = 'label',
caption = [[
Lists all players on the server and shows some stats. You can sort the list by
clicking on the column headers. You can also poke people, which throws a random
noun in the chat.]]
}
player_list_label.style.single_line = false
grid.add {type = 'sprite', sprite = 'item/programmable-speaker'}
local poll = grid.add {type = 'label', caption = 'Polls'}
poll.style.font = 'default-listbox'
local poll_label =
}
player_list_label.style.single_line = false
end
if global.config.poll.enabled then
grid.add {type = 'sprite', sprite = 'item/programmable-speaker'}
local poll = grid.add {type = 'label', caption = 'Polls'}
poll.style.font = 'default-listbox'
local poll_label =
grid.add {
type = 'label',
caption = [[
type = 'label',
caption = [[
Polls help players get consensus for major actions. Want to improve an important
build? Make a poll to check everyone is ok with that. You need to be a regular
to make new polls.]]
}
poll_label.style.single_line = false
}
poll_label.style.single_line = false
end
local tag_button = grid.add {type = 'label', caption = 'tag'}
local tag_button_style = tag_button.style
tag_button_style.font = 'default-listbox'
tag_button_style.font_color = {r = 0, g = 0, b = 0}
local tag = grid.add {type = 'label', caption = 'Tags'}
tag.style.font = 'default-listbox'
local tag_label =
if global.config.tag_group.enabled then
local tag_button = grid.add {type = 'label', caption = 'tag'}
local tag_button_style = tag_button.style
tag_button_style.font = 'default-listbox'
tag_button_style.font_color = {r = 0, g = 0, b = 0}
local tag = grid.add {type = 'label', caption = 'Tags'}
tag.style.font = 'default-listbox'
local tag_label =
grid.add {
type = 'label',
caption = [[
type = 'label',
caption = [[
You can assign yourself a role with tags to let other players know what you are
doing. Or just use the tag as decoration. Regulars can create new custom tags,
be sure to show off your creatively.]]
}
tag_label.style.single_line = false
}
tag_label.style.single_line = false
end
grid.add {type = 'sprite', sprite = 'item/repair-pack'}
local task = grid.add {type = 'label', caption = 'Tasks'}
task.style.font = 'default-listbox'
local task_label =
if global.config.tasklist.enabled then
grid.add {type = 'sprite', sprite = 'item/repair-pack'}
local task = grid.add {type = 'label', caption = 'Tasks'}
task.style.font = 'default-listbox'
local task_label =
grid.add {
type = 'label',
caption = [[
type = 'label',
caption = [[
Not sure what you should be working on, why not look at the tasks and see what
needs doing. Regulars can add new tasks.]]
}
task_label.style.single_line = false
}
task_label.style.single_line = false
end
grid.add {type = 'sprite', sprite = 'item/blueprint'}
local blueprint = grid.add {type = 'label', caption = 'BP\nhelper'}
local blueprint_style = blueprint.style
blueprint_style.font = 'default-listbox'
blueprint_style.single_line = false
blueprint_style.width = 55
local blueprint_label =
if global.config.blueprint_helper.enabled then
grid.add {type = 'sprite', sprite = 'item/blueprint'}
local blueprint = grid.add {type = 'label', caption = 'BP\nhelper'}
local blueprint_style = blueprint.style
blueprint_style.font = 'default-listbox'
blueprint_style.single_line = false
blueprint_style.width = 55
local blueprint_label =
grid.add {
type = 'label',
caption = [[
type = 'label',
caption = [[
The Blueprint helper lets you flip blueprints horizontally or vertically and lets you
converter the entities used in the blueprint e.g. turn yellow belts into red belts.]]
}
blueprint_label.style.single_line = false
}
blueprint_label.style.single_line = false
end
grid.add {type = 'sprite', sprite = 'item/rocket-silo'}
local score = grid.add {type = 'label', caption = 'Score'}
score.style.font = 'default-listbox'
local score_label =
if global.config.score.enabled then
grid.add {type = 'sprite', sprite = 'item/rocket-silo'}
local score = grid.add {type = 'label', caption = 'Score'}
score.style.font = 'default-listbox'
local score_label =
grid.add {
type = 'label',
caption = [[
type = 'label',
caption = [[
Shows number of rockets launched and biters liberated.]]
}
score_label.style.single_line = false
}
score_label.style.single_line = false
end
end
},
{
tab_button = function(parent, player)
tab_button = function(parent)
local button = parent.add {type = 'button', name = tab_button_name, caption = "What's New"}
return button
end,

View File

@ -41,9 +41,6 @@ local filter_table_close_button_name = Gui.uid_name()
global.paint_brushes_by_player = {}
local function player_build_tile(event)
if not global.config.paint.enable then
return
end
if event.item.name ~= brush_tool then
return
end
@ -75,9 +72,6 @@ local function player_build_tile(event)
end
local function player_joined(event)
if not global.config.paint.enable then
return
end
local player = Game.get_player_by_index(event.player_index)
if not player or not player.valid then
return

View File

@ -15,7 +15,6 @@ local poke_cooldown_time = 240 -- in ticks.
local sprite_time_step = 54000 -- in ticks
local symbol_asc = ''
local symbol_desc = ''
local normal_color = {r = 1, g = 1, b = 1}
local focus_color = {r = 1, g = 0.55, b = 0.1}
local rank_colors = {
{r = 1, g = 1, b = 1}, -- Guest
@ -313,7 +312,7 @@ local column_builders = {
local player_index = player.index
return {
count = PlayerStats.get_death_count(player_index),
causes = PlayerStats.get_all_death_counts_by_casue(player_index)
causes = PlayerStats.get_all_death_counts_by_cause(player_index)
}
end,
sort = function(a, b)
@ -448,7 +447,7 @@ local function get_default_player_settings()
distance_heading_name
}
local offset = 6
if global.config.player_list.enable_coin_col then
if global.config.player_list.show_coin_column then
columns[6] = coin_heading_name
offset = 7
end

View File

@ -11,14 +11,11 @@ local function player_created(event)
return
end
if (global.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 this map created by the RedMew team. 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('Click the question mark in the top left corner for server information and map details.')
player.print(table.get_random_weighted(join_msgs, 1, 2))
local gui = player.gui

View File

@ -131,8 +131,8 @@ function Public.get_death_count(player_index)
return player_deaths[player_index].count
end
-- Returns a dictionary of casue_name -> count
function Public.get_all_death_counts_by_casue(player_index)
-- Returns a dictionary of cause_name -> count
function Public.get_all_death_counts_by_cause(player_index)
return player_deaths[player_index].causes or {}
end

View File

@ -6,7 +6,7 @@
local Event = require 'utils.event'
local Game = require 'utils.game'
global.reactors_enabled = false
global.reactors_enabled = global.config.reactor_meltdown.on_by_default
global.wastelands = {}
global.reactors = {}
local wasteland_duration_seconds = 300

View File

@ -1,4 +1,7 @@
local Poll = require 'features.gui.poll'
local Poll = {send_poll_result_to_discord = function () end}
if global.config.poll.enabled then
Poll = require 'features.gui.poll'
end
local UserGroups = require 'features.user_groups'
local Token = require 'utils.token'
local Server = require 'features.server'

View File

@ -42,10 +42,8 @@ function Scenario.register()
return
end
global.config.player_list.enable_coin_col = false
if global.config then
global.config.fish_market.enable = nil
end
global.config.player_list.show_coin_column = false
global.config.fish_market.enabled = false
local extra_map_info = ''

View File

@ -1,4 +1,4 @@
local market_item = MARKET_ITEM or 'coin'
local market_item = global.config.fish_market.market_item or 'coin'
return {
market_item = market_item,