-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
394 changed files
with
6,978 additions
and
916 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
-- not_luadoc=true | ||
function _log(...) log(...) end -- do not remove this is used for smaller verbose lines | ||
Manager = require("FactorioSoftmodManager") | ||
Manager.setVerbose{ | ||
selfInit=true, -- called while the manager is being set up | ||
moduleLoad=false, -- when a module is required by the manager | ||
moduleInit=false, -- when and within the initation of a module | ||
modulePost=false, -- when and within the post of a module | ||
moduleEnv=false, -- during module runtime, this is a global option set within each module for fine control | ||
eventRegistered=false, -- when a module registers its event handlers | ||
errorCaught=true, -- when an error is caught during runtime | ||
output=Manager._verbose -- can be: can be: print || log || other function | ||
-- If you're looking to configure anything, you want config.lua. Nearly everything in this file is dictated by the config. | ||
|
||
-- Info on the data lifecycle and how we use it: https://github.com/Refactorio/RedMew/wiki/The-data-lifecycle | ||
require 'resources.data_stages' | ||
_LIFECYCLE = _STAGE.control -- Control stage | ||
|
||
-- Overrides the _G.print function | ||
require 'utils.print_override' | ||
|
||
-- Omitting the math library is a very bad idea | ||
require 'utils.math' | ||
|
||
-- Global Debug and make sure our version file is registered | ||
Debug = require 'utils.debug' | ||
require 'resources.version' | ||
|
||
local files = { | ||
'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', | ||
} | ||
Manager() -- can be Manager.loadModules() if called else where | ||
|
||
-- Loads all files in array above and logs progress | ||
local total_files = string.format('%3d',#files) | ||
local errors = {} | ||
for index,path in pairs(files) do | ||
log(string.format('[INFO] Loading files %3d/%s',index,total_files)) | ||
local success,file = pcall(require,path) | ||
-- error checking | ||
if not success then | ||
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 | ||
log('[ERROR] File not found: '..path) | ||
table.insert(errors,'[ERROR] '..path..' :: Not Found') | ||
end | ||
end | ||
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 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
local Colours = require 'resources.color_presets' | ||
local Game = require 'utils.game' | ||
|
||
local Public = {} | ||
|
||
--- Compare types faster for faster validation of prams | ||
-- @usage is_type('foo','string') -- return true | ||
-- @usage is_type('foo') -- return false | ||
-- @param v the value to be tested | ||
-- @tparam[opt=nil] string test_type the type to test for if not given then it tests for nil | ||
-- @treturn boolean is v of type test_type | ||
function Public.type_check(value,test_type) | ||
return test_type and value and type(value) == test_type or not test_type and not value or false | ||
end | ||
|
||
--- Will return a value of any type to the player/server console, allows colour for in-game players | ||
-- @usage player_return('Hello, World!') -- returns 'Hello, World!' to game.player or server console | ||
-- @usage player_return('Hello, World!','green') -- returns 'Hello, World!' to game.player with colour green or server console | ||
-- @usage player_return('Hello, World!',nil,player) -- returns 'Hello, World!' to the given player | ||
-- @param value any value of any type that will be returned to the player or console | ||
-- @tparam[opt=defines.colour.white] ?defines.color|string colour the colour of the text for the player, ignored when printing to console | ||
-- @tparam[opt=game.player] LuaPlayer player the player that return will go to, if no game.player then returns to server | ||
function Public.player_return(value,colour,player) | ||
colour = Public.type_check(colour,'table') and colour or Colours[colour] ~= Colours.white and Colours[colour] or Colours.white | ||
player = player or game.player | ||
-- converts the value to a string | ||
local returnAsString | ||
if Public.type_check(value,'table') then | ||
if Public.type_check(value.__self,'userdata') then | ||
-- value is userdata | ||
returnAsString = 'Cant Display Userdata' | ||
elseif Public.type_check(value[1],'string') and string.find(value[1],'.+[.].+') and not string.find(value[1],'%s') then | ||
-- value is a locale string | ||
returnAsString = value | ||
elseif getmetatable(value) ~= nil and not tostring(value):find('table: 0x') then | ||
-- value has a tostring meta method | ||
returnAsString = tostring(value) | ||
else | ||
-- value is a table | ||
returnAsString = serpent.block(value) | ||
end | ||
elseif Public.type_check(value,'function') then | ||
-- value is a function | ||
returnAsString = 'Cant Display Functions' | ||
else returnAsString = tostring(value) end | ||
-- returns to the player or the server | ||
if player then | ||
-- allows any valid player identifier to be used | ||
player = Game.get_player_from_any(player) | ||
if not player then error('Invalid Player given to player_return',2) end | ||
-- plays a nice sound that is different to normal message sound | ||
player.play_sound{path='utility/scenario_message'} | ||
player.print(returnAsString,colour) | ||
else rcon.print(returnAsString) end | ||
end | ||
|
||
return Public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
local Commands = require 'expcore.commands' | ||
local Game = require 'utils.game' | ||
|
||
--[[ | ||
>>>>Adds parses: | ||
boolean | ||
string-options - options: array | ||
string-max-length - max_length: number | ||
number | ||
integer | ||
number-range - range_min: number, range_max: number | ||
integer-range - range_min: number, range_max: number | ||
player | ||
player-online | ||
player-alive | ||
force | ||
surface | ||
]] | ||
|
||
Commands.add_parse('boolean',function(input,player,reject) | ||
if not input then return end -- nil check | ||
input = input:lower() | ||
if input == 'yes' | ||
or input == 'y' | ||
or input == 'true' | ||
or input == '1' then | ||
return true | ||
else | ||
return false | ||
end | ||
end) | ||
|
||
Commands.add_parse('string-options',function(input,player,reject,options) | ||
if not input then return end -- nil check | ||
input = input:lower() | ||
for option in options do | ||
if input == option:lower() then | ||
return true | ||
end | ||
end | ||
return reject{'reject-string-options',options:concat(', ')} | ||
end) | ||
|
||
Commands.add_parse('string-max-length',function(input,player,reject,max_length) | ||
if not input then return end -- nil check | ||
local length = input:len() | ||
if length > max_length then | ||
return reject{'expcore-commands.reject-string-max-length',max_length} | ||
else | ||
return input | ||
end | ||
end) | ||
|
||
Commands.add_parse('number',function(input,player,reject) | ||
if not input then return end -- nil check | ||
local number = tonumber(input) | ||
if not number then | ||
return reject{'expcore-commands.reject-number'} | ||
else | ||
return number | ||
end | ||
end) | ||
|
||
Commands.add_parse('integer',function(input,player,reject) | ||
if not input then return end -- nil check | ||
local number = tonumber(input) | ||
if not number then | ||
return reject{'expcore-commands.reject-number'} | ||
else | ||
return math.floor(number) | ||
end | ||
end) | ||
|
||
Commands.add_parse('number-range',function(input,player,reject,range_min,range_max) | ||
local number = Commands.parse('number',input,player,reject) | ||
if not number then return end -- nil check | ||
if number < range_min or number > range_max then | ||
return reject{'expcore-commands.reject-number-range',range_min,range_max} | ||
else | ||
return number | ||
end | ||
end) | ||
|
||
Commands.add_parse('integer-range',function(input,player,reject,range_min,range_max) | ||
local number = Commands.parse('integer',input,player,reject) | ||
if not number then return end -- nil check | ||
if number < range_min or number > range_max then | ||
return reject{'expcore-commands.reject-number-range',range_min,range_max} | ||
else | ||
return number | ||
end | ||
end) | ||
|
||
Commands.add_parse('player',function(input,player,reject) | ||
if not input then return end -- nil check | ||
local input_player = Game.get_player_from_any(input) | ||
if not input_player then | ||
return reject{'expcore-commands.reject-player',input} | ||
else | ||
return input_player | ||
end | ||
end) | ||
|
||
Commands.add_parse('player-online',function(input,player,reject) | ||
local input_player = Commands.parse('player',input,player,reject) | ||
if not input_player then return end -- nil check | ||
if not input_player.connected then | ||
return reject{'expcore-commands.reject-player-online'} | ||
else | ||
return input_player | ||
end | ||
end) | ||
|
||
Commands.add_parse('player-alive',function(input,player,reject) | ||
local input_player = Commands.parse('player-online',input,player,reject) | ||
if not input_player then return end -- nil check | ||
if not input_player.character or not input_player.character.health or input_player.character.health <= 0 then | ||
return reject{'expcore-commands.reject-player-alive'} | ||
else | ||
return input_player | ||
end | ||
end) | ||
|
||
Commands.add_parse('force',function(input,player,reject) | ||
if not input then return end -- nil check | ||
local force = game.forces[input] | ||
if not force then | ||
return reject{'expcore-commands.reject-force'} | ||
else | ||
return force | ||
end | ||
end) | ||
|
||
Commands.add_parse('surface',function(input,player,reject) | ||
if not input then return end | ||
local surface = game.surfaces[input] | ||
if not surface then | ||
return reject{'expcore-commands.reject-surface'} | ||
else | ||
return surface | ||
end | ||
end) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[expcore-commands] | ||
unauthorized=401 - Unbefugt: Zugang verweigert. Du hast keinen Zugriff auf diese Befehle! | ||
reject-number-range=ungültige Reichweite, Min: __1__, Max: __2__ | ||
reject-string-max-length=ungültige Länge, Max: __1__ | ||
reject-player=ungültiger Spieler Name, __1__ , Versuche "Tab" zu benutzen, damit sich der Name automatisch vervollständigt. | ||
reject-player-online=Der betroffene Spieler ist offline, Befehl konnte nicht ausgeführt werden. | ||
reject-player-alive=Der betroffene Spieler ist Tod, Befehl konnte nicht ausgeführt werden. | ||
invalid-inputs=ungültige Eingabe, /__1__ __2__ | ||
command-ran=Befehl ausgeführt. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[expcore-commands] | ||
unauthorized=Unauthorized, Access is denied due to invalid credentials | ||
reject-string-options=Invalid Option, Must be one of: __1__ | ||
reject-string-max-length=Invalid Length, Max: __1__ | ||
reject-number=Invalid Number | ||
reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__ | ||
reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name | ||
reject-player-online=Player is offline. | ||
reject-player-alive=Player is dead. | ||
reject-force=Invaild Force Name | ||
reject-surface=Invaild surface Name | ||
invalid-inputs=Invalid Input, /__1__ __2__ | ||
invalid-param=Invalid Param "__1__"; __2__ | ||
command-help=__1__ - __2__ | ||
command-ran=Command Complete | ||
command-fail=Command failed to run: __1__ | ||
command-error-log-format=[ERROR] command/__1__ :: __2__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[expcore-commands] | ||
unauthorized=401 - Onbevoegd: toegang wordt geweigerd vanwege ongeldige inloggegevens | ||
reject-number-range=Onjuiste radius, Min: __1__, Max: __2__ | ||
reject-string-max-length=Onjuiste lengte, Max: __1__ | ||
reject-player=Onjuiste naam, __1__ , probeer tab te gebruiken om de naam automatisch in te vullen | ||
reject-player-online=Speler is offline. | ||
reject-player-alive=Speler is dood. | ||
invalid-inputs=Onjuiste invoer, /__1__ __2__ | ||
command-ran=Commando uitgevoerd. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[expcore-commands] | ||
unauthorized=401 - Otillåten: Tillgång nekas på grund av otillräcklig säkerhetsprövning. | ||
reject-number-range=Invalid räckvid, Min: __1__, Max: __2__ | ||
reject-string-max-length=ogiltig längd, Max: __1__ | ||
reject-player=Ogiltigt spelarnamn, __1__ , försök använda tab-tangenten för att auto-slutföra namn. | ||
reject-player-online=Spelare är offline. Kommando misslyckades med att köras. | ||
reject-player-alive=Spelare är död. Kommando misslyckades med att köras. | ||
invalid-inputs=Igiltig inmatning, /__1__ __2__ | ||
command-ran=Kommandot slutfört |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[exp-commands] | ||
kill-already-dead=You are already dead. | ||
admin-chat-format=[Admin Chat] [color=__3__]__1__: __2__ | ||
tp-no-position-found=No position to teleport to was found, please try again later. | ||
tp-to-self=Player can not be teleported to themselves. | ||
chelp-title=Help results for "__1__": | ||
chelp-footer=(__1__ results found; page __2__ of __3__) | ||
chelp-format=/__1__ __2__ - __3__ __4__ | ||
chelp-alias=Alias: __1__ | ||
chelp-out-of-range=__1__ is an invalid page number. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[expcore-commands] | ||
unauthorized=Unauthorized, Access is denied due to invalid credentials | ||
reject-string-options=Invalid Option, Must be one of: __1__ | ||
reject-string-max-length=Invalid Length, Max: __1__ | ||
reject-number=Invalid Number | ||
reject-number-range=Invalid Range, Min (inclusive): __1__, Max (inclusive): __2__ | ||
reject-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name | ||
reject-player-online=Player is offline. | ||
reject-player-alive=Player is dead. | ||
reject-force=Invaild Force Name | ||
reject-surface=Invaild surface Name | ||
invalid-inputs=Invalid Input, /__1__ __2__ | ||
invalid-param=Invalid Param "__1__"; __2__ | ||
command-help=__1__ - __2__ | ||
command-ran=Command Complete | ||
command-fail=Command failed to run: __1__ | ||
command-error-log-format=[ERROR] command/__1__ :: __2__ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.