Merge branch 'hotfix/5.1.2' into dev

This commit is contained in:
Cooldude2606
2019-03-22 22:04:58 +00:00
11 changed files with 60 additions and 27 deletions

View File

@@ -1,3 +1,6 @@
--- This is a very simple config file which adds a admin only auth function
-- not much to change here its more so it can be enabled and disabled from ./config/file_loader.lua
-- either way you can change the requirements to be "admin" if you wanted to
local Commands = require 'expcore.commands'
Commands.add_authenticator(function(player,command,tags,reject)

View File

@@ -1,8 +1,13 @@
--- This file contains some common command param parse functions
-- this file is less of a config and more of a requirement but you may wish to change how some behave
-- as such you need to be confident with lua but you edit this config file
-- use Commands.add_parse('name',function(input,player,reject) end) to add a parse
-- see ./expcore/commands.lua for more details
local Commands = require 'expcore.commands'
local Game = require 'utils.game'
--[[
>>>>Adds parses:
>>>>Adds Parses:
boolean
string-options - options: array
string-max-length - max_length: number

20
config/file_loader.lua Normal file
View File

@@ -0,0 +1,20 @@
--- This contains a list of all files that will be loaded and the order they are loaded in
-- to stop a file from loading add "--" in front of it, remove the "--" to have the file be loaded
-- config files should be loaded after all modules are loaded
-- core files should be required by modules and not be present in this list
return {
--'example.file_not_loaded',
'modules.factorio-control', -- base factorio free play scenario
-- Game Commands
'modules.commands.me',
'modules.commands.kill',
'modules.commands.admin-chat',
'modules.commands.tag',
'modules.commands.teleport',
'modules.commands.cheat-mode',
'modules.commands.interface',
'modules.commands.help',
-- Config Files
'config.command_auth_admin', -- commands tags with admin_only are blocked for non admins
'config.permission_groups', -- loads some predefined permission groups
}

View File

@@ -1,3 +1,7 @@
--- Use this file to add new permission groups to the game
-- start with Permission_Groups.new_group('name')
-- then use either :allow_all() or :disallow_all() to set the default for non specified actions
-- then use :allow{} and :disallow{} to specify certain actions to allow/disallow
local Event = require 'utils.event'
local Game = require 'utils.game'
local Permission_Groups = require 'expcore.permission_groups'
@@ -104,9 +108,9 @@ local function assign_group(player)
local current_group_name = player.permission_group and player.permission_group.name or 'None'
if player.admin then
Permission_Groups.set_player_group(player,'Admin')
elseif player.online_time > trusted_time and current_group_name == 'Trusted' then
elseif player.online_time > trusted_time or current_group_name == 'Trusted' then
Permission_Groups.set_player_group(player,'Trusted')
elseif player.online_time > standard_time and current_group_name == 'Guest' then
elseif player.online_time > standard_time or current_group_name == 'Standard' then
Permission_Groups.set_player_group(player,'Standard')
else
Permission_Groups.set_player_group(player,'Guest')

View File

@@ -1,4 +1,8 @@
-- If you're looking to configure anything, you want config.lua. Nearly everything in this file is dictated by the config.
--- Please go to ./config if you want to change settings, each file is commented with what it does
-- if it is not in ./config then you should not attempt to change it unless you know what you are doing
-- all files which are loaded (including the config files) are present in ./config/file_loader.lua
-- this file is the landing point for all scenarios please DO NOT edit directly, further comments are to aid development
-- Info on the data lifecycle and how we use it: https://github.com/Refactorio/RedMew/wiki/The-data-lifecycle
require 'resources.data_stages'
@@ -14,34 +18,35 @@ require 'utils.math'
Debug = require 'utils.debug'
require 'resources.version'
local files = {
'modules.factorio-control',
'modules.commands.me',
'modules.commands.kill',
'modules.commands.admin-chat',
'modules.commands.tag',
'modules.commands.teleport',
'modules.commands.cheat-mode',
'modules.commands.interface',
'modules.commands.help',
'config.permission_groups'
}
-- Global require function used to extract parts of a module, because simply being in common is not good enough
ext_require = require('expcore.common').ext_require
-- Loads all files in array above and logs progress
local total_files = string.format('%3d',#files)
-- Please go to config/file_loader.lua to edit the files that are loaded
local files = require 'config.file_loader'
-- Loads all files from the config and logs that they are loaded
local total_file_count = string.format('%3d',#files)
local errors = {}
for index,path in pairs(files) do
log(string.format('[INFO] Loading files %3d/%s',index,total_files))
-- Loads the next file in the list
log(string.format('[INFO] Loading files %3d/%s',index,total_file_count))
local success,file = pcall(require,path)
-- error checking
-- Error Checking
if not success then
-- Failed to load a file
log('[ERROR] Failed to load file: '..path)
log('[ERROR] '..file)
table.insert(errors,'[ERROR] '..path..' :: '..file)
elseif type(file) == 'string' and file:find('not found') then
-- Returned a file not found message
log('[ERROR] File not found: '..path)
table.insert(errors,'[ERROR] '..path..' :: Not Found')
end
end
-- Logs all errors again to make it make it easy to find
log('[INFO] All files loaded with '..#errors..' errors:')
for _,error in pairs(errors) do log(error) end -- logs all errors again to make it make it easy to find
for _,error in pairs(errors) do log(error) end

View File

@@ -162,7 +162,7 @@
]]
local Game = require 'utils.game'
local player_return = require('expcore.common').player_return
local player_return = ext_require('expcore.common','player_return')
local Commands = {
defines={ -- common values are stored error like signals

View File

@@ -1,6 +1,5 @@
local Commands = require 'expcore.commands'
require 'config.command_parse_general'
require 'config.command_auth_admin'
Commands.new_command('admin-chat','Sends a message in chat that only admins can see.')
:add_param('message',false) -- the message to send in the admin chat

View File

@@ -1,6 +1,5 @@
local Commands = require 'expcore.commands'
require 'config.command_parse_general'
require 'config.command_auth_admin'
Commands.new_command('toggle-cheat-mode','Toggles cheat mode for your player, or another player.')
:add_param('player',true,'player') -- player to toggle chest mode of, can be nil for self

View File

@@ -1,7 +1,6 @@
local Commands = require 'expcore.commands'
local Global = require 'utils.global'
local Common = require 'expcore.common'
require 'config.command_auth_admin'
-- modules that are loaded into the interface env to be accessed
local interface_modules = {

View File

@@ -1,6 +1,5 @@
local Commands = require 'expcore.commands'
require 'config.command_parse_general'
require 'config.command_auth_admin'
Commands.new_command('kill','Kills yourself or another player.')
:add_param('player',true,'player-alive') -- the player to kill, must be alive to be valid

View File

@@ -1,11 +1,11 @@
local Commands = require 'expcore.commands'
require 'config.command_parse_general'
require 'config.command_auth_admin'
local function teleport(from_player,to_player)
local surface = to_player.surface
local position = surface.find_non_colliding_position('player',to_player.position,32,1)
if not position then return false end -- return false if no new position
if from_player.driving then from_player.driving = false end -- kicks a player out a vehicle if in one
from_player.teleport(position,surface)
return true
end