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

Merge pull request #764 from plague006/split_commands

Split commands into their respective modules
This commit is contained in:
Matthew 2019-02-18 20:18:34 -05:00 committed by GitHub
commit cf661952b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 44 additions and 42 deletions

View File

@ -41,7 +41,7 @@ global.config = {
},
-- time before a player gets the auto-trusted rank, allowing them access to the deconstructions planner, nukes, etc.
rank_system = {
time_for_trust = 3*60*60*60, -- 3 hours
time_for_trust = 3 * 60 * 60 * 60, -- 3 hours
everyone_is_regular = false
},
-- saves players' lives if they have a small-plane in their inventory, also adds the small-plane to the market and must therefor be loaded first
@ -94,7 +94,6 @@ global.config = {
-- the coordinates at which the standard market will be created
standard_market_location = {x = 0, y = -5},
currency = currency,
-- defines the chance that killing an entity will drop coins and the min and max it can drop upon death
entity_drop_amount = {
['biter-spawner'] = {low = 5, high = 15, chance = 1},
@ -102,7 +101,6 @@ global.config = {
['small-worm-turret'] = {low = 2, high = 8, chance = 1},
['medium-worm-turret'] = {low = 5, high = 15, chance = 1},
['big-worm-turret'] = {low = 10, high = 20, chance = 1},
-- default is 0, no chance of coins dropping from biters/spitters
['small-biter'] = {low = 1, high = 5, chance = 0},
['small-spitter'] = {low = 1, high = 2, chance = 0},
@ -290,6 +288,10 @@ global.config = {
-- brightness is a number between 0.15 and 1
use_fixed_brightness = false,
fixed_brightness = 0.5
},
-- enables a command which allows for an end-game event
apocalypse = {
enabled = true
}
}

View File

@ -82,6 +82,9 @@ end
if config.day_night.enabled then
require 'map_gen.shared.day_night'
end
if config.apocalypse.enabled then
require 'features.apocalypse'
end
-- GUIs
-- The order determines the order they appear from left to right.

View File

@ -3,7 +3,6 @@ local Token = require 'utils.token'
local Global = require 'utils.global'
local Rank = require 'features.rank_system'
local Report = require 'features.report'
local Apocalypse = require 'features.apocalypse'
local Utils = require 'utils.core'
local Game = require 'utils.game'
local Event = require 'utils.event'
@ -498,17 +497,6 @@ Command.add(
revive_ghosts
)
-- Commands with no functions, only calls to other modules
Command.add(
'apocalypse',
{
description = "This really ends the map. When you first run it, the game will save. When run a second time, the apocalypse will begin.",
required_rank = Ranks.admin,
},
Apocalypse.begin_apocalypse
)
Command.add(
'destroy',
{

View File

@ -2,10 +2,12 @@ local Task = require 'utils.task'
local Token = require 'utils.token'
local Game = require 'utils.game'
local Global = require 'utils.global'
local Command = require 'utils.command'
local Toast = require 'features.gui.toast'
local RS = require 'map_gen.shared.redmew_surface'
local HailHydra = require 'map_gen.shared.hail_hydra'
local Color = require 'resources.color_presets'
local Ranks = require 'resources.ranks'
-- Constants
local hail_hydra_data = {
@ -97,4 +99,13 @@ function Public.begin_apocalypse(_, player)
Task.set_timeout(15, biter_spawn_token, {})
end
Command.add(
'apocalypse',
{
description = "This really ends the map. When you first run it, the game will save. When run a second time, the apocalypse will begin.",
required_rank = Ranks.admin,
},
Public.begin_apocalypse
)
return Public

View File

@ -3,7 +3,6 @@ local Timestamp = require 'utils.timestamp'
local Command = require 'utils.command'
local Settings = require 'utils.redmew_settings'
local Utils = require 'utils.core'
local Report = require 'features.report'
local Server = require 'features.server'
local Walkabout = require 'features.walkabout'
local PlayerStats = require 'features.player_stats'
@ -372,18 +371,6 @@ Command.add(
print_player_info
)
-- Commands with no functions, only calls to other modules
Command.add(
'report',
{
description = 'Reports a user to admins',
arguments = {'player', 'message'},
capture_excess_arguments = true
},
Report.report_command
)
-- No man's land / free for all
Command.add(
'redmew-setting-set',

View File

@ -2,6 +2,7 @@ local Gui = require 'utils.gui'
local Utils = require 'utils.core'
local Game = require 'utils.game'
local Global = require 'utils.global'
local Command = require 'utils.command'
local Popup = require 'features.gui.popup'
local Color = require 'resources.color_presets'
@ -34,6 +35,19 @@ Global.register(
end
)
local function report_command(args, player)
local reported_player_name = args.player
local reported_player = game.players[reported_player_name]
if not reported_player then
Game.player_print(reported_player_name .. ' does not exist.')
return nil
end
Module.report(player, reported_player, args.message)
Game.player_print('Your report has been sent.')
end
local function draw_report(parent, report_id)
local report = report_data[report_id]
if report_id == 0 or not report then
@ -138,19 +152,6 @@ function Module.report(reporting_player, reported_player, message)
end
end
function Module.report_command(args, player)
local reported_player_name = args.player
local reported_player = game.players[reported_player_name]
if not reported_player then
Game.player_print(reported_player_name .. ' does not exist.')
return nil
end
Module.report(player, reported_player, args.message)
Game.player_print('Your report has been sent.')
end
--- Places a target in jail
-- @param target_player <LuaPlayer> the target to jail
-- @param player <LuaPlayer|nil> the admin as LuaPlayer or server as nil
@ -424,4 +425,14 @@ Gui.on_click(
end
)
Command.add(
'report',
{
description = 'Reports a user to admins',
arguments = {'player', 'message'},
capture_excess_arguments = true
},
report_command
)
return Module

View File

@ -149,7 +149,7 @@ function Command.add(command_name, options, callback)
local player = game.player
local player_name = player and player.valid and player.name or '<server>'
if not player or not player.valid then
print = _G.print
print = log
if not allowed_by_server then
print(format("The command '%s' is not allowed to be executed by the server.", command_name))