diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..522fac32 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Factorio-luacheckrc"] + path = Factorio-luacheckrc + url = https://github.com/Nexela/Factorio-luacheckrc diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..2e87afff --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,31 @@ +{ + "cSpell.enabledLanguageIds": [ + "asciidoc", + "c", + "cpp", + "csharp", + "css", + "go", + "handlebars", + "html", + "jade", + "javascript", + "javascriptreact", + "json", + "latex", + "less", + "lua", + "markdown", + "php", + "plaintext", + "pub", + "python", + "restructuredtext", + "rust", + "scss", + "text", + "typescript", + "typescriptreact", + "yml" + ] +} \ No newline at end of file diff --git a/Boiler Print Module b/Boiler Print Module index 7601a711..b53932ae 100644 --- a/Boiler Print Module +++ b/Boiler Print Module @@ -2,21 +2,21 @@ -- @module ThisModule@X.Y.Z -- @author -- @license --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Module = require('Module@>X.Y.Z') -local SubModule = require('Collection.Submodule@^X.Y.Z') +local Module = require('Module') +local SubModule = require('Collection.Submodule') local OptModule -- OptModule@^X.Y.Z --- Local Varibles +-- Local Variables -- Module Define local module_verbose = false local ThisModule = { on_init=function(self) - if loaded_modules['OptModule@^X.Y.Z'] then OptModule = require('OptModule@^X.Y.Z') end - if loaded_modules['OptModule2@^X.Y.Z'] then require(module_path..'/src/module2',{self=self}) end + if loaded_modules['OptModule'] then OptModule = require('OptModule') end + if loaded_modules['OptModule2'] then require(module_path..'/src/module2',{self=self}) end --code end, on_post=function() @@ -34,4 +34,4 @@ local global = global{ -- Event Handlers Define -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/Factorio-luacheckrc b/Factorio-luacheckrc new file mode 160000 index 00000000..0c0518d1 --- /dev/null +++ b/Factorio-luacheckrc @@ -0,0 +1 @@ +Subproject commit 0c0518d165b0fcee714f9e00b014afd7aba9fbee diff --git a/FactorioSoftmodManager.lua b/FactorioSoftmodManager.lua index a93ce44b..3b7cc1a7 100644 --- a/FactorioSoftmodManager.lua +++ b/FactorioSoftmodManager.lua @@ -7,7 +7,7 @@ local moduleIndex = require("/modules/index") local Manager = {} -- this is a constant that is used to represent the server -SERVER = setmetatable({index=0,name='',online_time=0,afk_time=0,print=print,admin=true},{__index=function(tbl,key) if type(game.players[1][key]) == 'function' then return function() end else return nil end end}) +SERVER = setmetatable({index=0,name='',online_time=0,afk_time=0,print=print,admin=true,valid=true,__self={}},{__index=function(tbl,key) if type(game.players[1][key]) == 'function' then return function() end else return nil end end}) --- Setup for metatable of the Manager to force read only nature -- @usage Manager() -- runs Manager.loadModdules() @@ -74,9 +74,9 @@ Manager.verbose = function(rtn,action) local settings = Manager.setVerbose local state = Manager.currentState if Manager.error and state == Manager.error.__crash then return end - -- if ran in a module the the global module_name is present + -- if ran in a module the the global moduleName is present local rtn = type(rtn) == table and serpent.line(rtn) or tostring(rtn) - if module_name then rtn='['..module_name..'] '..rtn + if moduleName then rtn='['..moduleName..'] '..rtn else rtn='[FSM] '..rtn end -- module_verbose is a local override for a file, action is used in the manager to describe an extra type, state is the current state -- if action is true then it will always trigger verbose @@ -178,10 +178,10 @@ Manager.global=setmetatable({__defaults={},__global={ -- creates varible link to global and module information, use of a metatable is for already formed globals local Global = _G.global local metatable = getmetatable(metatable_src) - local module_name = type(default) == 'string' and default or metatable and metatable._module_name or module_name - local module_path = type(default) == 'string' and moduleIndex[default] or metatable and metatable._module_path or module_path + local moduleName = type(default) == 'string' and default or metatable and metatable._moduleName or moduleName + local module_path = type(default) == 'string' and Manager.loadModules.__load[default] or metatable and metatable._module_path or module_path -- if there is no name or path then it will return and unedited version of global - if not module_path or not module_name then return _G.global end + if not module_path or not moduleName then return _G.global end -- edits the link to global to be the corrected dir, path varible is also created local path = 'global' for dir in module_path:gmatch('%a+') do @@ -190,14 +190,14 @@ Manager.global=setmetatable({__defaults={},__global={ Global = rawget(Global,dir) end -- the default value is set if there was a default given - if type(default) == 'table' then Manager.verbose('Default global has been set for: global'..string.sub(module_path:gsub('/','.')),2) rawset(rawget(tbl,'__defaults'),tostring(module_name),default) end + if type(default) == 'table' then Manager.verbose('Default global has been set for: global'..string.sub(module_path:gsub('/','.')),2) rawset(rawget(tbl,'__defaults'),tostring(moduleName),default) end -- if the default value is true then it will reset the global to its default - if default == true and rawget(rawget(tbl,'__defaults'),tostring(module_name)) then + if default == true and rawget(rawget(tbl,'__defaults'),tostring(moduleName)) then Manager.verbose('Reset Global Dir to default: '..path) -- cant set it to be equle otherwise it will lose its global propeity local function deepcopy(tbl) if type(tbl) ~= 'table' then return tbl end local rtn = {} for key,value in pairs(tbl) do rtn[key] = deepcopy(value) end return rtn end for key,value in pairs(Global) do rawset(Global,key,nil) end - for key,value in pairs(rawget(rawget(tbl,'__defaults'),tostring(module_name))) do rawset(Global,key,deepcopy(value)) end + for key,value in pairs(rawget(rawget(tbl,'__defaults'),tostring(moduleName))) do rawset(Global,key,deepcopy(value)) end end -- the metatable is remade if not already present metatable = metatable or { @@ -212,7 +212,7 @@ Manager.global=setmetatable({__defaults={},__global={ end return next_pair, tbl, nil end, - _module_path=module_path,_module_name=module_name + _module_path=module_path,_moduleName=moduleName } return setmetatable(Global,metatable) end, @@ -286,7 +286,7 @@ Manager.require = setmetatable({ },{ __metatable=false, __index=function(tbl,key) return tbl(key,nil,true) end, - __call=function(tbl,path,env,mute) + __call=function(tbl,path,env,mute,noLoad) local raw_require = rawget(tbl,'__require') local env = env or {} -- runs in a sand box becuase sandbox everything @@ -295,23 +295,23 @@ Manager.require = setmetatable({ if success then return unpack(data) else if type(path) ~= 'string' then error('Path supplied must be a string; got: '..type(path),2) return end - -- else it assums the path was a module name and checks index for the module - if moduleIndex[path] then return rawget(Manager.loadModules,path) end - if moduleIndex[path:gsub('?','')] then return rawget(Manager.loadModules,path) end - -- if its not listed then it tries to remove a version tag and tries again - local path_no_version = path:find('@') and path:sub(1,path:find('@')-1) or path - if moduleIndex[path_no_version] then return rawget(Manager.loadModules,path_no_version) end - -- still no then it will look for all modules that include this one in the name (like a collection) - local collection = {} - for module_name,path in pairs(moduleIndex) do - if module_name:find('@') and module_name:sub(1,module_name:find('@')-1) == path_no_version then return rawget(Manager.loadModules,module_name) end - if module_name:find(path_no_version) then - local start, _end = module_name:find(path_no_version) - collection[module_name:sub(_end+2)] = rawget(Manager.loadModules,module_name) + local override = {} + local softmod = override + local path = path:find('@') and path:sub(1,path:find('@')-1) or path + -- tries to load the module from the modeul index + if moduleIndex[path] and not noLoad or Manager.loadModules.__load[path] then softmod = Manager.loadModules[path] end + -- will then look for any submodules if there are any; only once every module is loaded + for moduleName,subpath in pairs(moduleIndex) do + if moduleName:find(path) == 1 and moduleName ~= path then + local start, _end = moduleName:find(path) + local subname = moduleName:sub(_end+2) + -- does not add the module if it is a subsubmodule; or the key already exitsts + if not softmod then softmod = {} end + if not subname:find('.',nil,true) and not softmod[subname] then softmod[subname] = Manager.require(moduleName,nil,true,true) end end end - -- if there is any keys in the collection the collection is returned else the errors with the require error - for _ in pairs(collection) do return collection end + -- if there is any keys in the softmod it is returned else the errors with the require error + if override ~= softmod then return softmod end if mute then return false else error(data,2) end end end @@ -324,95 +324,134 @@ require = Manager.require -- @usage #Manager.loadModules -- returns the number of modules loaded -- @usage tostring(Manager.loadModules) -- returns a formatted list of all modules loaded -- @usage pairs(Manager.loadModules) -- loops over the loaded modules moduleName, module -Manager.loadModules = setmetatable({}, +Manager.loadModules = setmetatable({ + __load=setmetatable({},{__call=function(self,moduleName) + -- check to provent multiple calls + if self[moduleName] then return end + self[moduleName] = true + self = Manager.loadModules + -- loads the module and its dependices if there are not loaded + local load = moduleIndex[moduleName] + if not load then return end + local path = table.remove(load,1) + Manager.verbose('Loading module: "'..moduleName..'"; path: '..path) + -- loads the parent module + if moduleName:find('.',nil,true) then + local revModuleName = moduleName:reverse() + local start, _end = revModuleName:find('.',nil,true) + local parentName = revModuleName:sub(_end+1):reverse() + Manager.verbose('Loading module parent: "'..parentName..'" for: "'..moduleName..'"; path: '..path) + self.__load(parentName) + end + -- loads the dependices + Manager.verbose('Loading module dependices for: "'..moduleName..'"; path: '..path) + for _,depName in pairs(load) do self.__load(depName) end + self.__load[moduleName] = path + -- runs the module in a sandbox env + local success, module, sandbox = Manager.sandbox(Manager.require.__require,{moduleName=setupModuleName(moduleName),module_path=path},path..'/control') + -- extracts the module into a global index table for later use + if success then + -- verbose to notifie of any globals that were attempted to be created + local globals = '' + for key,value in pairs(sandbox) do globals = globals..key..', ' end + if globals ~= '' then Manager.verbose('Globals caught in "'..moduleName..'": '..globals:sub(1,-3),'errorCaught') end + Manager.verbose('Successfully loaded: "'..moduleName..'"; path: '..path) + -- if it is not a table or nil then it will set up a metatable on it + local currentType = type(rawget(self,moduleName)) + if currentType ~= 'nil' and currentType ~= 'table' then + -- if it is a function then it is still able to be called even if more keys are going to be added + -- if it is a string then it will act like one; if it is a number well thats too many metatable indexs + self[moduleName] = setmetatable({__old=self[moduleName]},{ + __call=function(self,...) if type(self.__old) == 'function' then self.__old(...) else return self.__old end end, + __tostring=function(self) return self.__old end, + __concat=function(self,val) return self.__old..val end + }) + end + -- if you prefere module_exports can be used rather than returning the module + local appendAs = sandbox.module_exports or table.remove(module,1) + if not self[moduleName] then self[moduleName] = appendAs -- if nil it just sets the value + else for key,value in pairs(appendAs) do self[moduleName][key] = value end end -- else it appends the new values + -- if there is a module by this name in _G ex table then it will be indexed to the new module + if rawget(_G,moduleName) and type(rawget(self,moduleName)) == 'table' then setmetatable(rawget(_G,moduleName),{__index=self[moduleName]}) end + if type(rawget(self,moduleName)) == 'table' then self[moduleName]._module_path = path self[moduleName]._moduleName = moduleName end + -- loads the submodule for this softmod + Manager.verbose('Loading submodules for: "'..moduleName..'"; path: '..path) + for subModName,_ in pairs(moduleIndex) do + if subModName:find(moduleName) == 1 and subModName ~= moduleName then self.__load(subModName) end + end + else + Manager.verbose('Failed load: "'..moduleName..'"; path: '..path..' ('..module..')','errorCaught') + for event_name,callbacks in pairs(Manager.event) do Manager.verbose('Removed Event Handler: "'..moduleName..'/'..Manager.event.names[event_name],'eventRegistered') callbacks[moduleName] = nil end + end + end}), + __init=setmetatable({},{__call=function(self,moduleName) + -- check to provent multiple calls + if self[moduleName] or not Manager.loadModules.__load[moduleName] then return end + self[moduleName] = true + self = Manager.loadModules + -- calls on_init for each module + -- looks for init so that init or on_init can be used + local data = self[moduleName] + if type(data) == 'table' and data.init and data.on_init == nil then data.on_init = data.init data.init = nil end + if type(data) == 'table' and data.on_init and type(data.on_init) == 'function' then + Manager.verbose('Initiating module: "'..moduleName..'"') + local success, err = Manager.sandbox(data.on_init,{moduleName=setupModuleName(moduleName),module_path=Manager.loadModules.__load[tostring(moduleName)]},data) + if success then + Manager.verbose('Successfully Initiated: "'..moduleName..'"') + else + Manager.verbose('Failed Initiation: "'..moduleName..'" ('..err..')','errorCaught') + end + -- clears the init function so it cant be used in runtime + data.on_init = nil + end + end}), + __post=setmetatable({},{__call=function(self,moduleName) + -- check to provent multiple calls + if self[moduleName] or not Manager.loadModules.__init[moduleName] then return end + self[moduleName] = true + self = Manager.loadModules + -- calls on_post for each module + -- looks for post so that post or on_post can be used + local data = self[moduleName] + if type(data) == 'table' and data.post and data.on_post == nil then data.on_post = data.post data.post = nil end + if type(data) == 'table' and data.on_post and type(data.on_post) == 'function' then + Manager.verbose('Post for module: "'..moduleName..'"') + local success, err = Manager.sandbox(data.on_post,{moduleName=setupModuleName(moduleName),module_path=Manager.loadModules.__load[tostring(moduleName)]},data) + if success then + Manager.verbose('Successful post: "'..moduleName..'"') + else + Manager.verbose('Failed post: "'..moduleName..'" ('..err..')','errorCaught') + end + -- clears the post function so it cant be used in runtime + data.on_post = nil + end + end}) + }, { __metatable=false, - __index=Manager.require, - __call=function(tbl) - -- ReadOnlyManager used to trigger verbose change + __index=function(self,moduleName) + -- will load one module if it is not already loaded, will not init during load state or post + self.__load(moduleName) + if (ReadOnlyManager.currentState == 'moduleLoad') then return end + self.__init(moduleName) + if (ReadOnlyManager.currentState == 'moduleInit') then return end + self.__post(moduleName) + return rawget(self,moduleName) + end, + __call=function(self) + -- goes though the index looking for modules to load ReadOnlyManager.currentState = 'moduleLoad' - -- goes though the index looking for modules - for module_name,path in pairs(moduleIndex) do - Manager.verbose('Loading module: "'..module_name..'"; path: '..path) - -- runs the module in a sandbox env - local success, module, sandbox = Manager.sandbox(Manager.require.__require,{module_name=setupModuleName(module_name),module_path=path},path..'/control') - -- extracts the module into a global index table for later use - if success then - -- verbose to notifie of any globals that were attempted to be created - local globals = '' - for key,value in pairs(sandbox) do globals = globals..key..', ' end - if globals ~= '' then Manager.verbose('Globals caught in "'..module_name..'": '..globals:sub(1,-3),'errorCaught') end - Manager.verbose('Successfully loaded: "'..module_name..'"; path: '..path) - -- sets that it has been loaded and adds to the loaded index - -- if you prefere module_exports can be used rather than returning the module - if type(tbl[module_name]) == 'nil' then - -- if it is a new module then creat the new index - if sandbox.module_exports and type(sandbox.module_exports) == 'table' - then tbl[module_name] = sandbox.module_exports - else tbl[module_name] = table.remove(module,1) end - elseif type(tbl[module_name]) == 'table' then - -- if this module adds onto an existing one then append the keys - if sandbox.module_exports and type(sandbox.module_exports) == 'table' - then for key,value in pairs(sandbox.module_exports) do tbl[module_name][key] = value end - else for key,value in pairs(table.remove(module,1)) do tbl[module_name][key] = value end end - else - -- if it is a function then it is still able to be called even if more keys are going to be added - -- if it is a string then it will act like one; if it is a number well thats too many metatable indexs - tbl[module_name] = setmetatable({__old=tbl[module_name]},{ - __call=function(tbl,...) if type(tbl.__old) == 'function' then tbl.__old(...) else return tbl.__old end end, - __tostring=function(tbl) return tbl.__old end, - __concat=function(tbl,val) return tbl.__old..val end - }) - -- same as above for adding the keys to the table - if sandbox.module_exports and type(sandbox.module_exports) == 'table' - then for key,value in pairs(sandbox.module_exports) do tbl[module_name][key] = value end - else for key,value in pairs(table.remove(module,1)) do tbl[module_name][key] = value end end - end - -- if there is a module by this name in _G ex table then it will be indexed to the new module - if rawget(_G,module_name) and type(tbl[module_name]) == 'table' then setmetatable(rawget(_G,module_name),{__index=tbl[module_name]}) end - if type(tbl[module_name]) == 'table' then tbl[module_name]._module_path = path tbl[module_name]._module_name = module_name end - else - Manager.verbose('Failed load: "'..module_name..'"; path: '..path..' ('..module..')','errorCaught') - for event_name,callbacks in pairs(Manager.event) do Manager.verbose('Removed Event Handler: "'..module_name..'/'..Manager.event.names[event_name],'eventRegistered') callbacks[module_name] = nil end - end - end - -- new state for the manager to allow control of verbose - ReadOnlyManager.currentState = 'moduleInit' + for moduleName,path in pairs(moduleIndex) do self.__load(moduleName) end -- runs though all loaded modules looking for on_init function; all other modules have been loaded use this to load extra code based on opttial dependies - for module_name,data in pairs(tbl) do - -- looks for init so that init or on_init can be used - if type(data) == 'table' and data.init and data.on_init == nil then data.on_init = data.init data.init = nil end - if type(data) == 'table' and data.on_init and type(data.on_init) == 'function' then - Manager.verbose('Initiating module: "'..module_name..'"') - local success, err = Manager.sandbox(data.on_init,{module_name=setupModuleName(module_name),module_path=moduleIndex[tostring(module_name)]},data) - if success then - Manager.verbose('Successfully Initiated: "'..module_name..'"') - else - Manager.verbose('Failed Initiation: "'..module_name..'" ('..err..')','errorCaught') - end - -- clears the init function so it cant be used in runtime - data.on_init = nil - end + ReadOnlyManager.currentState = 'moduleInit' + for moduleName,path in pairs(self) do + if moduleName ~= '__load' and moduleName ~= '__init' and moduleName ~= '__post' then self.__init(moduleName) end end - -- new state for the manager to allow control of verbose - ReadOnlyManager.currentState = 'modulePost' -- runs though all loaded modules looking for on_post function; all other modules have been loaded and inited, do not load extra code in this time only altar your own data - for module_name,data in pairs(tbl) do - -- looks for post so that post or on_post can be used - if type(data) == 'table' and data.post and data.on_post == nil then data.on_post = data.post data.post = nil end - if type(data) == 'table' and data.on_post and type(data.on_post) == 'function' then - Manager.verbose('Post for module: "'..module_name..'"') - local success, err = Manager.sandbox(data.on_post,{module_name=setupModuleName(module_name),module_path=moduleIndex[tostring(module_name)]},data) - if success then - Manager.verbose('Successful post: "'..module_name..'"') - else - Manager.verbose('Failed post: "'..module_name..'" ('..err..')','errorCaught') - end - -- clears the post function so it cant be used in runtime - data.on_post = nil - end + ReadOnlyManager.currentState = 'modulePost' + for moduleName,path in pairs(self) do + if moduleName ~= '__load' and moduleName ~= '__init' and moduleName ~= '__post' then self.__post(moduleName) end end - -- this could also be called runtime ReadOnlyManager.currentState = 'moduleEnv' end, __len=function(tbl) @@ -421,13 +460,13 @@ Manager.loadModules = setmetatable({}, for key,value in pairs(tbl) do rtn = rtn + 1 end - return rtn + return rtn-3 end, __tostring=function(tbl) -- a concat of all the loaded modules local rtn = 'Load Modules: ' for key,value in pairs(tbl) do - rtn=rtn..key..', ' + if key ~= '__load' and key ~= '__init' and key ~= '__post' then rtn=rtn..key..', ' end end return rtn:sub(1,-3) end @@ -555,7 +594,7 @@ Manager.event = setmetatable({ __load=script.on_load, __config=script.on_configuration_changed, events=defines.events, - error_chache={} + error_cache={} },{ __metatable=false, __call=function(tbl,event_name,new_callback,...) @@ -575,26 +614,26 @@ Manager.event = setmetatable({ -- other wise raise the event and call every callback; no use of script.raise_event due to override local event_functions = tbl.__events[event_name] if type(event_functions) == 'table' then - for module_name,callback in pairs(event_functions) do + for moduleName,callback in pairs(event_functions) do -- loops over the call backs and which module it is from - if type(callback) ~= 'function' then error('Invalid Event Callback: "'..event_name..'/'..module_name..'"') end - local success, err = Manager.sandbox(callback,{module_name=setupModuleName(module_name),module_path=moduleIndex[tostring(module_name)]},new_callback,...) + if type(callback) ~= 'function' then error('Invalid Event Callback: "'..event_name..'/'..moduleName..'"') end + local success, err = Manager.sandbox(callback,{moduleName=setupModuleName(moduleName),module_path=Manager.loadModules.__load[tostring(moduleName)]},new_callback,...) if not success then - local chache = tbl.error_chache - local error_message = 'Event Failed: "'..module_name..'/'..tbl.names[event_name]..'" ('..err..')' - if not chache[error_message] then Manager.verbose(error_message,'errorCaught') error(error_message) end + local cache = tbl.error_cache + local error_message = 'Event Failed: "'..moduleName..'/'..tbl.names[event_name]..'" ('..err..')' + if not cache[error_message] then Manager.verbose(error_message,'errorCaught') error(error_message) end if tbl.names[event_name] == 'on_tick' then - if not chache[error_message] then chache[error_message] = {game.tick,1} end - if chache[error_message][1] >= game.tick-10 then chache[error_message] = {game.tick,chache[error_message][2]+1} - else chache[error_message] = nil end - if chache[error_message] and chache[error_message][2] > 100 then + if not cache[error_message] then cache[error_message] = {game.tick,1} end + if cache[error_message][1] >= game.tick-10 then cache[error_message] = {game.tick,cache[error_message][2]+1} + else cache[error_message] = nil end + if cache[error_message] and cache[error_message][2] > 100 then Manager.verbose('There was an error happening every tick for 100 ticks, the event handler has been removed!','errorCaught') - event_functions[module_name] = nil + event_functions[moduleName] = nil end end end -- if stop constant is returned then stop further processing - if err == rawget(tbl,'__stop') then Manager.verbose('Event Haulted By: "'..module_name..'"','errorCaught') break end + if err == rawget(tbl,'__stop') then Manager.verbose('Event Haulted By: "'..moduleName..'"','errorCaught') break end end end end, @@ -602,7 +641,7 @@ Manager.event = setmetatable({ -- handles the creation of new event handlers if type(value) ~= 'function' and type(value) ~= nil then error('Attempted to set a non function value to an event',2) end -- checks for a global module name that is present - local module_name = module_name or 'FSM' + local moduleName = moduleName or 'FSM' -- converts the key to a number index for the event Manager.verbose('Added Handler: "'..tbl.names[key]..'"','eventRegistered') -- checks that the event has a valid table to store callbacks; if its not valid it will creat it and register a real event handler @@ -611,18 +650,18 @@ Manager.event = setmetatable({ elseif key < 0 then rawget(tbl,tbl.names[key])(function(...) tbl(key,...) end) else rawget(tbl,'__event')(key,function(...) tbl(key,...) end) end rawset(rawget(tbl,'__events'),key,{}) end - -- adds callback to Manager.event.__events[event_id][module_name] - rawset(rawget(rawget(tbl,'__events'),key),tostring(module_name),value) + -- adds callback to Manager.event.__events[event_id][moduleName] + rawset(rawget(rawget(tbl,'__events'),key),tostring(moduleName),value) end, __index=function(tbl,key) -- few redirect key local redirect={register=tbl,dispatch=tbl,remove=function(event_id) tbl[event_name]=nil end} if rawget(redirect,key) then return rawget(redirect,key) end -- proforms different look ups depentding weather the current module has an event handler registered - if module_name then + if moduleName then -- first looks for the event callback table and then under the module name; does same but converts the key to a number; no handler regisered so returns the converted event id - return rawget(rawget(tbl,'__events'),key) and rawget(rawget(rawget(tbl,'__events'),key),tostring(module_name)) - or rawget(rawget(tbl,'__events'),rawget(tbl,'names')[key]) and rawget(rawget(rawget(tbl,'__events'),rawget(tbl,'names')[key]),tostring(module_name)) + return rawget(rawget(tbl,'__events'),key) and rawget(rawget(rawget(tbl,'__events'),key),tostring(moduleName)) + or rawget(rawget(tbl,'__events'),rawget(tbl,'names')[key]) and rawget(rawget(rawget(tbl,'__events'),rawget(tbl,'names')[key]),tostring(moduleName)) or rawget(tbl,'names')[key] else -- if there is no module present then it will return the full list of regisered handlers; or other wise the converted event id @@ -655,7 +694,7 @@ Manager.event = setmetatable({ rawset(Manager.event,'names',setmetatable({},{ __index=function(tbl,key) if type(key) == 'number' or tonumber(key) then - -- if it is a number then it will first look in the chache + -- if it is a number then it will first look in the cache if rawget(tbl,key) then return rawget(tbl,key) end -- if it is a core event then it will simply return if key == -1 then rawset(tbl,key,'__init') @@ -667,7 +706,7 @@ rawset(Manager.event,'names',setmetatable({},{ if id == key then rawset(tbl,key,event) end end end - -- returns the value from the chache after being loaded in + -- returns the value from the cache after being loaded in return rawget(tbl,key) -- if it is a string then no reverse look up is required else @@ -702,7 +741,7 @@ script.on_load(function(...) end) --over rides for the base values; can be called though Event Event=setmetatable({},{__call=Manager.event,__index=function(tbl,key) return Manager.event[key] or script[key] or error('Invalid Index To Table Event') end}) -script.mod_name = setmetatable({},{__index=_G.module_name}) +script.mod_name = setmetatable({},{__index=_G.moduleName}) script.on_event=Manager.event script.raise_event=Manager.event script.on_init=function(callback) Manager.event(-1,callback) end diff --git a/README.md b/README.md index 633aee5f..c0a87fbb 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Fork - - CodeFactor + + CodeFactor Discord diff --git a/control.lua b/control.lua index c5e46030..1c352a55 100644 --- a/control.lua +++ b/control.lua @@ -6,7 +6,7 @@ Manager.setVerbose{ 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=true, -- during module runtime, this is a global option set within each module for fine control + 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 diff --git a/doc/modules/ExpGamingCore.Gui.Center.html b/doc/modules/ExpGamingCore.Gui.Center.html index d979fb13..b6b0f202 100644 --- a/doc/modules/ExpGamingCore.Gui.Center.html +++ b/doc/modules/ExpGamingCore.Gui.Center.html @@ -206,7 +206,7 @@

Returns:

    - boelon + boolean based on if it successed or not
@@ -244,7 +244,7 @@

Returns:

    - boelon + boolean based on if it successed or not
diff --git a/doc/modules/ExpGamingCore.Sync.html b/doc/modules/ExpGamingCore.Sync.html index 9b2b75c9..291dd92b 100644 --- a/doc/modules/ExpGamingCore.Sync.html +++ b/doc/modules/ExpGamingCore.Sync.html @@ -87,7 +87,7 @@ Prints to chat as if it were a player -
emit_embeded (args) + emit_embedded (args) Logs an embed to the json.data we use a js script to add things we cant here @@ -135,7 +135,7 @@ EmitEmbededParamaters - Outline of the paramaters accepted by Sync.emit_embeded + Outline of the paramaters accepted by Sync.emit_embedded

Fields

@@ -262,8 +262,8 @@
- - emit_embeded (args) + + emit_embedded (args)
Logs an embed to the json.data we use a js script to add things we cant here @@ -273,7 +273,7 @@
  • args table - a table which contains everything that the embeded will use + a table which contains everything that the embedded will use
@@ -286,7 +286,7 @@

Usage:

    -
    Sync.emit_embeded{title='BAN',color='0x0',description='A player was banned' ... }
    +
    Sync.emit_embedded{title='BAN',color='0x0',description='A player was banned' ... }
@@ -592,7 +592,7 @@ EmitEmbededParamaters
- Outline of the paramaters accepted by Sync.emit_embeded + Outline of the paramaters accepted by Sync.emit_embedded

Fields:

diff --git a/locale/de/ExpGamingAdmin.Warnings.cfg b/locale/de/ExpGamingAdmin.Warnings.cfg index 3a62ea44..c48f518a 100644 --- a/locale/de/ExpGamingAdmin.Warnings.cfg +++ b/locale/de/ExpGamingAdmin.Warnings.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=This Warnings Was Given By: __1__ player-warning=__1__ was given a warning by __2__ reason: __3__ temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset diff --git a/modules/ExpGamingAdmin/AdminLib/locale/de.cfg b/locale/de/ExpGamingAdmin.cfg similarity index 100% rename from modules/ExpGamingAdmin/AdminLib/locale/de.cfg rename to locale/de/ExpGamingAdmin.cfg diff --git a/locale/en/ExpGamingAdmin.Warnings.cfg b/locale/en/ExpGamingAdmin.Warnings.cfg index 6378521b..01715fc7 100644 --- a/locale/en/ExpGamingAdmin.Warnings.cfg +++ b/locale/en/ExpGamingAdmin.Warnings.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=This warning was given by: __1__ player-warning=__1__ was given a warning by __2__ for: __3__ remove-warn=One of your warnings expired. You have __1__ warnings left, next warning will be removed in __2__ diff --git a/modules/ExpGamingAdmin/AdminLib/locale/en.cfg b/locale/en/ExpGamingAdmin.cfg similarity index 100% rename from modules/ExpGamingAdmin/AdminLib/locale/en.cfg rename to locale/en/ExpGamingAdmin.cfg diff --git a/locale/fr/ExpGamingAdmin.Warnings.cfg b/locale/fr/ExpGamingAdmin.Warnings.cfg index 3a62ea44..c48f518a 100644 --- a/locale/fr/ExpGamingAdmin.Warnings.cfg +++ b/locale/fr/ExpGamingAdmin.Warnings.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=This Warnings Was Given By: __1__ player-warning=__1__ was given a warning by __2__ reason: __3__ temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset diff --git a/modules/ExpGamingAdmin/AdminLib/locale/fr.cfg b/locale/fr/ExpGamingAdmin.cfg similarity index 100% rename from modules/ExpGamingAdmin/AdminLib/locale/fr.cfg rename to locale/fr/ExpGamingAdmin.cfg diff --git a/locale/nl/ExpGamingAdmin.Warnings.cfg b/locale/nl/ExpGamingAdmin.Warnings.cfg index 69b8004e..104ef981 100644 --- a/locale/nl/ExpGamingAdmin.Warnings.cfg +++ b/locale/nl/ExpGamingAdmin.Warnings.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=Deze waarschuwing is gegeven door: __1__ player-warning=__1__ is gewaarschuwd door __2__ met de reden: __3__ temp-ban=__1__ is verbannen door __2__ en is gejailed tot de volgende reset. diff --git a/modules/ExpGamingAdmin/AdminLib/locale/nl.cfg b/locale/nl/ExpGamingAdmin.cfg similarity index 100% rename from modules/ExpGamingAdmin/AdminLib/locale/nl.cfg rename to locale/nl/ExpGamingAdmin.cfg diff --git a/locale/sv-SE/ExpGamingAdmin.Warnings.cfg b/locale/sv-SE/ExpGamingAdmin.Warnings.cfg index b130aac3..9358b9cf 100644 --- a/locale/sv-SE/ExpGamingAdmin.Warnings.cfg +++ b/locale/sv-SE/ExpGamingAdmin.Warnings.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=Den här varningen gavs av: __1__ player-warning=__1__ var tillfälligt bannlyst av __2__ och kommer att förbli i fängelset tills nästa återställning (reset) remove-warn=En av dina varningar har gått ut. Du har __1__ varning kvar, nästa varning kommer at tas bort om __2__ diff --git a/modules/ExpGamingAdmin/AdminLib/locale/sv-SE.cfg b/locale/sv-SE/ExpGamingAdmin.cfg similarity index 100% rename from modules/ExpGamingAdmin/AdminLib/locale/sv-SE.cfg rename to locale/sv-SE/ExpGamingAdmin.cfg diff --git a/modules/AdvancedStartingItems/control.lua b/modules/AdvancedStartingItems/control.lua index 5b55ee9e..31c1e718 100644 --- a/modules/AdvancedStartingItems/control.lua +++ b/modules/AdvancedStartingItems/control.lua @@ -2,9 +2,9 @@ -- @module AdvancedStartingItems@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule --- Local Varibles +-- Local Variables local items = { ['iron-plate']=function(player,made) if tick_to_min(game.tick) < 5 then return 8 else return (made*10)/math.pow(tick_to_min(game.tick),2) end end, ['copper-plate']=function(player,made) if tick_to_min(game.tick) < 5 then return 0 else return (made*8)/math.pow(tick_to_min(game.tick),2) end end, @@ -12,9 +12,9 @@ local items = { ['iron-gear-wheel']=function(player,made) if tick_to_min(game.tick) < 5 then return 0 else return (made*6)/math.pow(tick_to_min(game.tick),2) end end, ['steel-plate']=function(player,made) if tick_to_min(game.tick) < 5 then return 0 else return(made*4)/math.pow(tick_to_min(game.tick),2) end end, ['pistol']=function(player,made) if player.force.item_production_statistics.get_input_count('submachine-gun') > 5 then return 0 else return 1 end end, - ['submachine-gun']=function(player,made) if made > 5 then return 1 else return 0 end end, + ['submachine-gun']=function(player,made) if made > 5 then return 1 else return 0 end end, ['firearm-magazine']=function(player,made) if player.force.item_production_statistics.get_input_count('piercing-rounds-magazine') > 100 then return 0 else return 10 end end, - ['piercing-rounds-magazine']=function(player,made) if made > 100 then return 10 else return 0 end end, + ['piercing-rounds-magazine']=function(player,made) if made > 100 then return 10 else return 0 end end, ['light-armor']=function(player,made) if made > 5 and player.force.item_production_statistics.get_input_count('heavy-armor') <= 5 then return 1 else return 0 end end, ['heavy-armor']=function(player,made) if made > 5 then return 1 else return 0 end end, ['burner-mining-drill']=function(player,made) if tick_to_min(game.tick) < 5 then return 4 else return 0 end end, @@ -28,7 +28,7 @@ local module_verbose = false local ThisModule = {} -- Event Handlers Define -Event.register(defines.events.on_player_created, function(event) +script.on_event(defines.events.on_player_created, function(event) local player = game.players[event.player_index] if event.player_index == 1 then player.force.friendly_fire = false @@ -42,4 +42,4 @@ Event.register(defines.events.on_player_created, function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/AdvancedStartingItems/softmod.json b/modules/AdvancedStartingItems/softmod.json index 4a888080..dc9653e1 100644 --- a/modules/AdvancedStartingItems/softmod.json +++ b/modules/AdvancedStartingItems/softmod.json @@ -1,20 +1,20 @@ { - "name": "AdvancedStartingItems", - "version": "4.0.0", - "type": "Module", - "description": "Adds a better method of player starting items based on production levels.", - "location": "", - "keywords": [ - "Inventory", - "Start", - "Items", - "Player", - "Advanced", - "Useful", - "Balaced" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": {} -} \ No newline at end of file + "name": "AdvancedStartingItems", + "version": "4.0.0", + "description": "Adds a better method of player starting items based on production levels.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Inventory", + "Start", + "Items", + "Player", + "Advanced", + "Useful", + "Balaced" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": {}, + "submodules": {} +} diff --git a/modules/ChatPopup/control.lua b/modules/ChatPopup/control.lua index 798af9a9..c22c1564 100644 --- a/modules/ChatPopup/control.lua +++ b/modules/ChatPopup/control.lua @@ -2,11 +2,11 @@ -- @module ChatPopup@4.0.0 -- @author badgamernl -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ChatPopup +-- @alias ChatPopup -- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') -local Color = require('FactorioStdLib.Color@^0.8.0') +local Game = require('FactorioStdLib.Game') +local Color = require('FactorioStdLib.Color') local ChatPopup = {} @@ -19,7 +19,7 @@ function ChatPopup.sendFlyingText(player, text) for i=1, #text, chunkSize do chunks[#chunks+1] = text:sub(i,i+chunkSize - 1) end - -- Itterate over text chunks and create them as floating text centered above the player + -- Iterate over text chunks and create them as floating text centered above the player -- Disabled false centering because of not being able to disable scaling: (1 / 7.9 * #value) for i,value in ipairs(chunks) do _player.surface.create_entity{ @@ -31,11 +31,11 @@ function ChatPopup.sendFlyingText(player, text) end end -Event.register(defines.events.on_console_chat, function(event) +script.on_event(defines.events.on_console_chat, function(event) local player = game.players[event.player_index] if not player then return end if not event.message then return end - + -- Send message player send to player itself local message = player.name .. ': ' .. event.message ChatPopup.sendFlyingText(player, message) @@ -50,7 +50,7 @@ Event.register(defines.events.on_console_chat, function(event) end end end - + end) return ChatPopup \ No newline at end of file diff --git a/modules/ChatPopup/softmod.json b/modules/ChatPopup/softmod.json index 63950b1a..273ab7d9 100644 --- a/modules/ChatPopup/softmod.json +++ b/modules/ChatPopup/softmod.json @@ -1,15 +1,21 @@ { "name": "ChatPopup", "version": "4.0.0", - "type": "Module", "description": "Creates flying text above player when they send a message.", - "location": "", - "keywords": ["Chat", "Popup", "Mention", "Floating", "Text"], + "location": "FSM_ARCHIVE", + "keywords": [ + "Chat", + "Popup", + "Mention", + "Floating", + "Text" + ], "author": "badgamernl", "contact": "badgamernl@gmail.com", "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", "dependencies": { - "FactorioStdLib.Game": "0.8.0", + "FactorioStdLib.Game": "^0.8.0", "FactorioStdLib.Color": "^0.8.0" - } + }, + "submodules": {} } diff --git a/modules/DamagePopup/control.lua b/modules/DamagePopup/control.lua index 0d58802a..b75b2003 100644 --- a/modules/DamagePopup/control.lua +++ b/modules/DamagePopup/control.lua @@ -1,20 +1,20 @@ ---- When a entibty is damaged y a player it will show how much damage you've dealth, When a player gets attacked by a entity it will popup the player's health in color. +--- When a entity is damaged y a player it will show how much damage you've death, When a player gets attacked by a entity it will popup the player's health in color. -- @module DamagePopup@4.0.0 -- @author badgamernl -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais DamagePopup +-- @alias DamagePopup -- Module Require -local Color = require('FactorioStdLib.Color@^0.8.0') +local Color = require('FactorioStdLib.Color') local DamagePopup = {} -Event.register(defines.events.on_entity_damaged, function(event) +script.on_event(defines.events.on_entity_damaged, function(event) local entity = event.entity local cause = event.cause local damage = event.original_damage_amount local health = entity.health - -- local pre_attack_health = health + damage -- Didn't use it after all, maybe usefull later + -- local pre_attack_health = health + damage -- Didn't use it after all, maybe useful later local color = defines.textcolor.crit @@ -36,7 +36,7 @@ Event.register(defines.events.on_entity_damaged, function(event) entity.surface.create_entity{ name="flying-text", color=defines.textcolor.med, - text='-'..damage, + text='-'..math.floor(damage), -- cooldude2606 added floor for damage amount position=entity.position } end diff --git a/modules/DamagePopup/softmod.json b/modules/DamagePopup/softmod.json index e0a482db..a5ea4de0 100644 --- a/modules/DamagePopup/softmod.json +++ b/modules/DamagePopup/softmod.json @@ -1,14 +1,19 @@ { "name": "DamagePopup", "version": "4.0.0", - "type": "Module", "description": "When a entibty is damaged y a player it will show how much damage you've dealth, When a player gets attacked by a entity it will popup the player's health in color.", - "location": "", - "keywords": ["Damage", "Popup", "Floating", "Text"], + "location": "FSM_ARCHIVE", + "keywords": [ + "Damage", + "Popup", + "Floating", + "Text" + ], "author": "badgamernl", "contact": "badgamernl@gmail.com", "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", "dependencies": { "FactorioStdLib.Color": "^0.8.0" - } + }, + "submodules": {} } diff --git a/modules/DeathMarkers/control.lua b/modules/DeathMarkers/control.lua index 3b47970a..051e5eb3 100644 --- a/modules/DeathMarkers/control.lua +++ b/modules/DeathMarkers/control.lua @@ -2,7 +2,7 @@ -- @module DeathMarkers@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Define local module_verbose = false @@ -14,7 +14,7 @@ local global = global{ } -- Event Handlers Define -Event.register(defines.events.on_player_died, function(event) +script.on_event(defines.events.on_player_died, function(event) local player = game.players[event.player_index] local tag = player.force.add_chart_tag(player.surface,{ position=player.position, @@ -24,7 +24,7 @@ Event.register(defines.events.on_player_died, function(event) table.insert(global.corpses,tag) end) -Event.register(defines.events.on_tick, function(event) +script.on_event(defines.events.on_tick, function(event) if (game.tick%3600) ~= 0 then return end if not global.corpses then global.corpses = {} end local key = 1 @@ -42,4 +42,4 @@ Event.register(defines.events.on_tick, function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/DeathMarkers/softmod.json b/modules/DeathMarkers/softmod.json index 7329b46e..ac58f593 100644 --- a/modules/DeathMarkers/softmod.json +++ b/modules/DeathMarkers/softmod.json @@ -1,17 +1,17 @@ { - "name": "DeathMarkers", - "version": "4.0.0", - "type": "Module", - "description": "Adds markers to the map when a player dies and removes it when the body is removed.", - "location": "", - "keywords": [ - "Death", - "Marker", - "Body", - "Map" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": {} -} \ No newline at end of file + "name": "DeathMarkers", + "version": "4.0.0", + "description": "Adds markers to the map when a player dies and removes it when the body is removed.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Death", + "Marker", + "Body", + "Map" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": {}, + "submodules": {} +} diff --git a/modules/DeconControl/control.lua b/modules/DeconControl/control.lua index 5583af5d..2976cb33 100644 --- a/modules/DeconControl/control.lua +++ b/modules/DeconControl/control.lua @@ -2,20 +2,20 @@ -- @module DeconControl@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') -local Server = require('ExpGamingCore.Server@^4.0.0') +local Game = require('FactorioStdLib.Game') +local Server = require('ExpGamingCore.Server') local Role -- ExpGamingCore.Role@^4.0.0 -local Admin -- ExpGamingAdmin.AdminLib@^4.0.0 +local Admin -- ExpGamingAdmin@^4.0.0 -- Module Define local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end - if loaded_modules['ExpGamingAdmin.AdminLib@^4.0.0'] then Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end + if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end end } @@ -23,40 +23,40 @@ local ThisModule = { Event.register(-1,function(event) Server.new_thread{ name='tree-decon', - data={trees={},chache={},clear=0} + data={trees={},cache={},clear=0} }:on_event('tick',function(self) local trees = self.data.trees - if self.data.clear ~= 0 and self.data.clear < game.tick then self.data.chache = {} self.data.clear = 0 end + if self.data.clear ~= 0 and self.data.clear < game.tick then self.data.cache = {} self.data.clear = 0 end if #trees == 0 then return end for i = 0,math.ceil(#trees/10) do local tree = table.remove(trees,1) if tree and tree.valid then tree.destroy() end end end):on_event(defines.events.on_marked_for_deconstruction,function(self,event) - local chache = self.data.chache[event.player_index] - if not chache then + local cache = self.data.cache[event.player_index] + if not cache then local player = Game.get_player(event) if not player then return end if not Role then - if player.admin then self.data.chache[event.player_index] = {'tree-decon',false} - else self.data.chache[event.player_index] = {'decon',false} end + if player.admin then self.data.cache[event.player_index] = {'tree-decon',false} + else self.data.cache[event.player_index] = {'decon',false} end else - if Role.allowed(player,'tree-decon') then self.data.chache[event.player_index] = {'tree-decon',false} - elseif not Role.allowed(player,'decon') then self.data.chache[event.player_index] = {'no-decon',false} - else self.data.chache[event.player_index] = {'decon',false} end + if Role.allowed(player,'tree-decon') then self.data.cache[event.player_index] = {'tree-decon',false} + elseif not Role.allowed(player,'decon') then self.data.cache[event.player_index] = {'no-decon',false} + else self.data.cache[event.player_index] = {'decon',false} end end - chache = self.data.chache[event.player_index] + cache = self.data.cache[event.player_index] end if not event.entity.last_user or event.entity.name == 'entity-ghost' then - if chache[1] == 'tree-decon' then + if cache[1] == 'tree-decon' then table.insert(self.data.trees,event.entity) self.data.clear = game.tick + 10 end else - if chache[1] == 'no-decon' then + if cache[1] == 'no-decon' then event.entity.cancel_deconstruction('player') - if not chache[2] then - chache[2] = true + if not cache[2] then + cache[2] = true local player = Game.get_player(event) player_return({'DeconControl.player-print'},defines.textcolor.crit,player) Role.print(Role.meta.groups.Admin.lowest,{'DeconControl.rank-print',player.name},defines.textcolor.info) @@ -69,4 +69,4 @@ Event.register(-1,function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/DeconControl/softmod.json b/modules/DeconControl/softmod.json index 26fbc4bb..2f33a047 100644 --- a/modules/DeconControl/softmod.json +++ b/modules/DeconControl/softmod.json @@ -1,25 +1,26 @@ { - "name": "DeconControl", - "version": "4.0.0", - "type": "Module", - "description": "Allows control over decon rights, if ExpGamingCore.Role is not installed it will allow admins to instant remove trees and thats it.", - "location": "", - "keywords": [ - "Trees", - "Decon", - "Protection", - "Admin", - "Tool", - "Report" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "ExpGamingCore.Server": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingLib": "^4.0.0", - "ExpGamingAdmin.Warnings": "?^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - } -} \ No newline at end of file + "name": "DeconControl", + "version": "4.0.0", + "description": "Allows control over decon rights, if ExpGamingCore.Role is not installed it will allow admins to instant remove trees and thats it.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Trees", + "Decon", + "Protection", + "Admin", + "Tool", + "Report" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "ExpGamingCore.Server": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingLib": "^4.0.0", + "ExpGamingAdmin.Warnings": "?^4.0.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingAdmin": "?^4.0.0" + }, + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/AdminLib/softmod.json b/modules/ExpGamingAdmin/AdminLib/softmod.json deleted file mode 100644 index b04915d1..00000000 --- a/modules/ExpGamingAdmin/AdminLib/softmod.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "AdminLib", - "version": "4.0.0", - "type": "Submodule", - "description": "The base functions required to make the others work.", - "location": "", - "keywords": [ - "lib", - "ExpGaming", - "Admin" - ], - "dependencies": { - "FactorioStdLib": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Ban/control.lua b/modules/ExpGamingAdmin/Ban/control.lua index 01bb8031..0a5f1935 100644 --- a/modules/ExpGamingAdmin/Ban/control.lua +++ b/modules/ExpGamingAdmin/Ban/control.lua @@ -2,13 +2,13 @@ -- @module ExpGamingAdmin.Ban@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local AdminGui = require('ExpGamingAdmin.Gui@^4.0.0') -local Server = require('ExpGamingCore.Server@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Admin = require('ExpGamingAdmin') +local AdminGui = require('ExpGamingAdmin.Gui') +local Server = require('ExpGamingCore.Server') +local Game = require('FactorioStdLib.Game') local Color -- FactorioStdLib.Color@^0.8.0 local Sync -- ExpGamingCore.Sync@^4.0.0 @@ -16,22 +16,22 @@ local Sync -- ExpGamingCore.Sync@^4.0.0 local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end - if loaded_modules['FactorioStdLib.Color@^0.8.0'] then Sync = require('FactorioStdLib.Color@^0.8.0') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end end } -- Function Define -AdminGui.add_button('ban','utility/danger_icon',{'ExpGamingAdmin.tooltip-ban'},function(player,byPlayer) - Admin.open(byPlayer,player,'ban') +AdminGui.add_button('Ban','utility/danger_icon',{'ExpGamingAdmin.tooltip-ban'},function(player,byPlayer) + Admin.open(byPlayer,player,'Ban') end) function Admin.ban(player,by_player,reason) - local player = Game.get_player(player) + player = Game.get_player(player) local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '' - local reason = Admin.create_reason(reason,by_player_name) + reason = Admin.create_reason(reason,by_player_name) Admin.set_banned(player,true) - if Sync then Sync.emit_embeded{ + if Sync then Sync.emit_embedded{ title='Player Ban', color=Color.to_hex(defines.textcolor.crit), description='There was a player banned.', @@ -46,4 +46,4 @@ end Admin.add_action('Ban',Admin.ban) -- Module Return -return ThisModule \ No newline at end of file +return setmetatable(ThisModule,{__call=Admin.ban}) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Ban/softmod.json b/modules/ExpGamingAdmin/Ban/softmod.json index 6dbb8ba2..a055b3e5 100644 --- a/modules/ExpGamingAdmin/Ban/softmod.json +++ b/modules/ExpGamingAdmin/Ban/softmod.json @@ -1,23 +1,23 @@ { - "name": "Ban", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a custom ban function to the admin command set.", - "location": "", - "keywords": [ - "Ban", - "Admin", - "Set", - "ExpGaming" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "?^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Ban", + "version": "4.0.0", + "description": "Adds a custom ban function to the admin command set.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Ban", + "Admin", + "Set", + "ExpGaming" + ], + "dependencies": { + "ExpGamingAdmin.Gui": "^4.0.0", + "ExpGamingCore.Server": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "?^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingAdmin.ClearInventory": "?^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/ClearInventory/control.lua b/modules/ExpGamingAdmin/ClearInventory/control.lua index 5a5ae497..dea36113 100644 --- a/modules/ExpGamingAdmin/ClearInventory/control.lua +++ b/modules/ExpGamingAdmin/ClearInventory/control.lua @@ -1,19 +1,19 @@ ---- Adds a function to clear a players inventoy and move the items to spawn. +--- Adds a function to clear a players inventory and move the items to spawn. -- @module ExpGamingAdmin.ClearInventory@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Admin = require('ExpGamingAdmin') +local Game = require('FactorioStdLib.Game') -- Module Define local module_verbose = false local ThisModule = {} -- Function Define -local inventorys = { +local inventories = { defines.inventory.player_main, defines.inventory.player_quickbar, defines.inventory.player_trash, @@ -23,7 +23,7 @@ local inventorys = { } function Admin.move_item_to_spawn(item,surface,chests) - local chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {} + chests = chests or surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {} local chest = nil while not chest or not chest.get_inventory(defines.inventory.chest).can_insert(item) do chest = table.remove(chests,1) @@ -38,14 +38,14 @@ function Admin.move_item_to_spawn(item,surface,chests) end function Admin.move_inventory(player) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then return end local chests = player.surface.find_entities_filtered{area={{-10,-10},{10,10}},name='iron-chest'} or {} - for _,_inventory in pairs(inventorys) do + for _,_inventory in pairs(inventories) do local inventory = player.get_inventory(_inventory) if inventory then for item,count in pairs(inventory.get_contents()) do - local item = {name=item,count=count} + item = {name=item,count=count} chests = Admin.move_item_to_spawn(item,player.surface,chests) end inventory.clear() @@ -55,4 +55,4 @@ end Admin.add_action('Clear Inventory',Admin.move_inventory) -- Module Return -return ThisModule \ No newline at end of file +return setmetatable(ThisModule,{__call=Admin.move_inventory}) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/ClearInventory/softmod.json b/modules/ExpGamingAdmin/ClearInventory/softmod.json index 25bbd087..ae931353 100644 --- a/modules/ExpGamingAdmin/ClearInventory/softmod.json +++ b/modules/ExpGamingAdmin/ClearInventory/softmod.json @@ -1,20 +1,20 @@ { - "name": "ClearInventory", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a function to clear a players inventoy and move the items to spawn.", - "location": "", - "keywords": [ - "Spawn", - "Items", - "Admin", - "Move", - "Clear", - "Inventory" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.ClearInventory", + "version": "4.0.0", + "description": "Adds a function to clear a players inventoy and move the items to spawn.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Spawn", + "Items", + "Admin", + "Move", + "Clear", + "Inventory" + ], + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/Commands/control.lua b/modules/ExpGamingAdmin/Commands/control.lua index 18c3b1d2..73038cd6 100644 --- a/modules/ExpGamingAdmin/Commands/control.lua +++ b/modules/ExpGamingAdmin/Commands/control.lua @@ -3,7 +3,7 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') +local Admin = require('ExpGamingAdmin') --- Used to clear all parts of a player, removing warnings, reports, jail and temp ban -- @command clear-all @@ -16,10 +16,10 @@ end) return { on_init = function(self) - if loaded_modules['ExpGamingAdmin.TempBan'] then verbose('ExpGamingAdmin.TempBan is installed; Loading tempban src') require(module_path..'/src/tempban',{Admin=Admin}) end - if loaded_modules['ExpGamingAdmin.Jail'] then verbose('ExpGamingAdmin.Jail is installed; Loading tempban src') require(module_path..'/src/jail',{Admin=Admin}) end - if loaded_modules['ExpGamingAdmin.Warnings'] then verbose('ExpGamingAdmin.Warnings is installed; Loading tempban src') require(module_path..'/src/warnings',{Admin=Admin}) end - if loaded_modules['ExpGamingAdmin.Reports'] then verbose('ExpGamingAdmin.Reports is installed; Loading tempban src') require(module_path..'/src/reports',{Admin=Admin}) end - if loaded_modules['ExpGamingAdmin.ClearInventory'] then verbose('ExpGamingAdmin.ClearInventory is installed; Loading tempban src') require(module_path..'/src/clear',{Admin=Admin}) end + if loaded_modules['ExpGamingAdmin.TempBan'] then verbose('ExpGamingAdmin.TempBan is installed; Loading tempban src') require(module_path..'/src/tempban',{self=Admin}) end + if loaded_modules['ExpGamingAdmin.Jail'] then verbose('ExpGamingAdmin.Jail is installed; Loading tempban src') require(module_path..'/src/jail',{self=Admin}) end + if loaded_modules['ExpGamingAdmin.Warnings'] then verbose('ExpGamingAdmin.Warnings is installed; Loading tempban src') require(module_path..'/src/warnings',{self=Admin}) end + if loaded_modules['ExpGamingAdmin.Reports'] then verbose('ExpGamingAdmin.Reports is installed; Loading tempban src') require(module_path..'/src/reports',{self=Admin}) end + if loaded_modules['ExpGamingAdmin.ClearInventory'] then verbose('ExpGamingAdmin.ClearInventory is installed; Loading tempban src') require(module_path..'/src/clear',{self=Admin}) end end } \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Commands/softmod.json b/modules/ExpGamingAdmin/Commands/softmod.json index 434d27db..541a7255 100644 --- a/modules/ExpGamingAdmin/Commands/softmod.json +++ b/modules/ExpGamingAdmin/Commands/softmod.json @@ -1,28 +1,29 @@ { - "name": "Commands", - "version": "4.0.0", - "type": "Submodule", - "description": "Admins many of the admin featues which the script can use as in game commands.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.admin_4.0.0.zip", - "keywords": [ - "ExpGaming", - "Admin", - "Tools", - "Commands", - "Temp ban", - "Jail", - "Clear Inventory", - "Report", - "Warnings" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingAdmin.TempBan": "?^4.0.0", - "ExpGamingAdmin.Jail": "?^4.0.0", - "ExpGamingAdmin.Warnings": "?^4.0.0", - "ExpGamingAdmin.Reports": "^?4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Commands", + "version": "4.0.0", + "description": "Admins many of the admin featues which the script can use as in game commands.", + "location": "FSM_ARCHIVE", + "keywords": [ + "ExpGaming", + "Admin", + "Tools", + "Commands", + "Temp ban", + "Jail", + "Clear Inventory", + "Report", + "Warnings" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "ExpGamingCore.Command": "^4.0.0", + "ExpGamingAdmin.TempBan": "?^4.0.0", + "ExpGamingAdmin.Jail": "?^4.0.0", + "ExpGamingAdmin.Warnings": "?^4.0.0", + "ExpGamingAdmin.Reports": "?^4.0.0", + "ExpGamingAdmin.ClearInventory": "?^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/Commands/src/clear.lua b/modules/ExpGamingAdmin/Commands/src/clear.lua index 000cd2bb..ec6262a7 100644 --- a/modules/ExpGamingAdmin/Commands/src/clear.lua +++ b/modules/ExpGamingAdmin/Commands/src/clear.lua @@ -1,4 +1,4 @@ -local Admin = Admin +local Admin = self --- Clears a players inventory and moves it to chests in spawn -- @command clear-inv @@ -7,6 +7,6 @@ commands.add_command('clear-inv', 'Clears a player\'s invetory', { ['player'] = {true,'player-rank'} }, function(event,args) local player = args.player - if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end + if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end Admin.move_inventory(player) end) diff --git a/modules/ExpGamingAdmin/Commands/src/jail.lua b/modules/ExpGamingAdmin/Commands/src/jail.lua index 7fba90bc..7d60da06 100644 --- a/modules/ExpGamingAdmin/Commands/src/jail.lua +++ b/modules/ExpGamingAdmin/Commands/src/jail.lua @@ -1,5 +1,6 @@ -local Admin = Admin +local Admin = self local Role = require('ExpGamingCore.Role') +local Server = require('ExpGamingCore.Server') --- Used to jail a player which stops them from moving -- @command jail @@ -11,8 +12,8 @@ commands.add_command('jail', 'Jails a player', { }, function(event,args) local player = args.player local reason = args.reason - if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end - if Admin.is_banned(player) then player_return{'ExpGamingCore_Command.cant-report-ban',args.player} return commands.error end + if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player.name} return commands.error end + if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player.name} return commands.error end Admin.jail(player,event.player_index,reason) end) @@ -23,6 +24,7 @@ commands.add_command('unjail', 'Returns a player\'s old rank', { ['player']={true,'player'} }, function(event,args) local player = args.player - if Admin.is_banned(player) then player_return({'ExpGamingCore_Command.cant-report-ban',args.player}) return commands.error end + if Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end + Admin.set_banned(player,false) Server.interface(Role.revert,true,player,event.player_index,2) end) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Commands/src/reports.lua b/modules/ExpGamingAdmin/Commands/src/reports.lua index f53b9939..be67e7d8 100644 --- a/modules/ExpGamingAdmin/Commands/src/reports.lua +++ b/modules/ExpGamingAdmin/Commands/src/reports.lua @@ -1,5 +1,6 @@ -local Admin = Admin -local Role = require('ExpGamingCore.Role@^4.0.0') +local Admin = self +local Role = require('ExpGamingCore.Role') +local Game = require('FactorioStdLib.Game') --- Reports a player -- @command report @@ -12,10 +13,10 @@ commands.add_command('report', 'Reports a player', { local _player = Game.get_player(event) local player = args.player local reason = args.reason - if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end - if Role.allowed(player,'no-report') then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end - for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end end - for _,report in pairs(global.addons.reports.varified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player}) return commands.error end end + if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end + if Role.has_flag(player,'not_reportable') then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end + for _,report in pairs(global.addons.reports.reports) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end + for _,report in pairs(global.addons.reports.verified) do if report[1] == _player.name then player_return({'ExpGamingAdmin.cant-report',args.player.name}) return commands.error end end Admin.report(player,event.player_index,reason) end) @@ -23,7 +24,12 @@ end) -- @command clear-reports -- @param player the player to clear the reports of commands.add_command('clear-reports', 'Clears a player\'s reports', { - ['player'] = {true,Admin.is_not_banned} + ['player'] = {true,function(value) + local player,err = commands.validate['player'](value) + if err then return commands.error(err) end + local rtn = not Admin.is_banned(player) and player + if not rtn then return commands.error{'ExpGamingAdmin.cant-report-ban',value} end return rtn + end} }, function(event,args) Admin.clear_reports(args.player,event.player_index) end) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Commands/src/tempban.lua b/modules/ExpGamingAdmin/Commands/src/tempban.lua index 79919bba..8657d1ad 100644 --- a/modules/ExpGamingAdmin/Commands/src/tempban.lua +++ b/modules/ExpGamingAdmin/Commands/src/tempban.lua @@ -1,4 +1,4 @@ -local Admin = Admin +local Admin = self --- Used to temp ban a player and give a reason -- @command temp-ban @@ -10,6 +10,6 @@ commands.add_command('temp-ban', 'Temporarily ban a player', { }, function(event,args) local player = args.player local reason = args.reason - if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end + if Admin.is_banned(player) and Admin.is_banned(player,true) ~= 'jail' then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end Admin.temp_ban(player,event.player_index,reason) end) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Commands/src/warnings.lua b/modules/ExpGamingAdmin/Commands/src/warnings.lua index 277301a8..b3796656 100644 --- a/modules/ExpGamingAdmin/Commands/src/warnings.lua +++ b/modules/ExpGamingAdmin/Commands/src/warnings.lua @@ -1,5 +1,5 @@ -local Admin = Admin -local Role = require('ExpGamingCore.Role@^4.0.0') +local Admin = self +local Role = require('ExpGamingCore.Role') --- Gives a warning to a player -- @command warn @@ -11,8 +11,8 @@ commands.add_command('warn', 'Gives a player a warning', { }, function(event,args) local player = args.player local reason = args.reason - if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player} return commands.error end - if Role.allowed(player,'no-report') then player_return{'ExpGamingAdmin.cant-report',args.player} return commands.error end + if Admin.is_banned(player) then player_return{'ExpGamingAdmin.cant-report-ban',args.player.name} return commands.error end + if Role.has_flag(player,'not_reportable') then player_return{'ExpGamingAdmin.cant-report',args.player.name} return commands.error end Admin.give_warning(player,event.player_index,reason) end) @@ -23,6 +23,6 @@ commands.add_command('clear-warnings', 'Clears a player\'s warnings', { ['player'] = {true,'player'} }, function(event,args) local player = args.player - if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player}) return commands.error end - Admin.clear_warings(player,event.player_index) + if Admin.is_banned(player) then player_return({'ExpGamingAdmin.cant-report-ban',args.player.name}) return commands.error end + Admin.clear_warnings(player,event.player_index) end) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Gui/control.lua b/modules/ExpGamingAdmin/Gui/control.lua index dd63bd0e..7dd8c2e7 100644 --- a/modules/ExpGamingAdmin/Gui/control.lua +++ b/modules/ExpGamingAdmin/Gui/control.lua @@ -2,21 +2,20 @@ -- @module ExpGamingAdmin.Gui@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais AdminGui +-- @alias AdminGui -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Role = require('ExpGamingCore.Role@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Admin = require('ExpGamingAdmin') +local Gui = require('ExpGamingCore.Gui') +local Role = require('ExpGamingCore.Role') +local Game = require('FactorioStdLib.Game') local playerInfo -- ExpGamingPlayer.playerInfo@^4.0.0 -local mod_gui = require('mod-gui') -- Module Define local module_verbose = false local AdminGui = { on_init=function() - if loaded_modules['ExpGamingPlayer.playerInfo@^4.0.0'] then playerInfo = require('ExpGamingPlayer@^4.0.0') + if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') else playerInfo = function(player,frame) frame.add{ type='label', @@ -30,7 +29,7 @@ local AdminGui = { function Admin.open(player,pre_select_player,pre_select_action) Gui.center.clear(player) - Admin.center.open(player,pre_select_player,pre_select_action) + Admin.center(player,pre_select_player,pre_select_action) end -- Function Define @@ -42,7 +41,7 @@ function AdminGui.add_button(name,caption,tooltip,callback) tooltip=tooltip }:on_event('click',function(event) local parent = event.element.parent - pre_select_player = parent.player and parent.player.caption or nil + local pre_select_player = parent.player and parent.player.caption or nil callback(pre_select_player,event.player_index) end) end @@ -68,12 +67,12 @@ function AdminGui.draw(frame,filter_buttons) end -- Gui Define -local function _players(_player,root_frame,state) +local function get_players(_player,root_frame,state) local players = {'Select Player'} local _players = state and game.players or game.connected_players for _,player in pairs(_players) do if player.name ~= _player.name then - if Admin.is_banned and Admin.is_banned(player) then else + if not Admin.is_banned or not Admin.is_banned(player) then table.insert(players,player.name) end end @@ -82,14 +81,14 @@ local function _players(_player,root_frame,state) end local online_check = Gui.inputs.add_checkbox('online-check-admin-commands',false,'Show Offline',false,function(player,element) - element.parent['player-drop-down-admin-commands'].items = _players(player,element.parent,true) + element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,true) element.parent['player-drop-down-admin-commands'].selected_index = 1 end,function(player,element) - element.parent['player-drop-down-admin-commands'].items = _players(player,element.parent,false) + element.parent['player-drop-down-admin-commands'].items = get_players(player,element.parent,false) element.parent['player-drop-down-admin-commands'].selected_index = 1 end) -local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',_players,1,function(player,selected,items,element) +local player_drop_down = Gui.inputs.add_drop_down('player-drop-down-admin-commands',get_players,1,function(player,selected,items,element) element.parent.parent.player.caption = selected local player_info_flow = element.parent.parent.info_flow player_info_flow.clear() @@ -131,7 +130,7 @@ local take_action = Gui.inputs{ local _role = Role.get_highest(_player) if role.index >= _role.index then dropdowns.warning.caption = {'ExpGamingAdmin.rank-high'} return end local _reason = dropdowns['reason-input-admin-commands'] and dropdowns['reason-input-admin-commands'].text - if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 20) then return end + if (_action == 'Jail' or _action == 'Kick' or _action == 'Ban' or _action == 'Temp Ban') and (_reason == 'Enter Reason' or string.len(_reason) < 10) then return end Admin.take_action(_action,_player,event.player_index,_reason) Gui.center.clear(event) end) @@ -140,26 +139,9 @@ Admin.center = Gui.center{ name='admin-commands', caption='utility/danger_icon', tooltip={'ExpGamingAdmin.tooltip'}, - open=function(event,pre_select_player,pre_select_action) - local _player = Game.get_player(pre_select_player) - local player = Game.get_player(event) - local _center = Gui.data.center['admin-commands'] - local center_flow = Gui.center.get_flow(player) - if center_flow[_center.name] then Gui.center.clear(player) return end - local center_frame = center_flow.add{ - name=_center.name, - type='frame', - direction='vertical', - style=mod_gui.frame_style - } - -- only edit i made was passing diffrent arguments to the draw function, try to avoid this - local success, err = pcall(_center.draw,center_frame,_player,pre_select_action) - if not success then error(err) end - player.opened=center_frame - end, - draw=function(frame,pre_select_player,pre_select_action) + draw=function(self,frame,pre_select_player,pre_select_action) frame.caption={'ExpGamingAdmin.name'} - local frame = frame.add{ + frame = frame.add{ type='flow', direction='horizontal' } @@ -183,7 +165,7 @@ Admin.center = Gui.center{ online_check:draw(dropdowns) local _drop = player_drop_down:draw(dropdowns) if pre_select_player then Gui.set_dropdown_index(_drop,pre_select_player.name) end - local _drop = action_drop_down:draw(dropdowns) + _drop = action_drop_down:draw(dropdowns) Gui.set_dropdown_index(_drop,pre_select_action) local _text = reason_input:draw(dropdowns) if pre_select_action == 'Jail' or pre_select_action == 'Kick' or pre_select_action == 'Ban' then @@ -191,7 +173,7 @@ Admin.center = Gui.center{ end if pre_select_player then playerInfo(pre_select_player,player_info_flow,true) end _text.style.width = 200 - local label = dropdowns.add{ + label = dropdowns.add{ name='warning', type='label', caption='', @@ -200,21 +182,21 @@ Admin.center = Gui.center{ label.style.single_line = false label.style.width = 200 take_action:draw(dropdowns) - local _caption = pre_select_player and pre_select_player.name or '' + local caption = pre_select_player and pre_select_player.name or '' frame.add{ name='player', type='label', - caption=_caption + caption=caption }.style.visible = false - local _caption = pre_select_action or '' + caption = pre_select_action or '' frame.add{ name='action', type='label', - caption=_caption + caption=caption }.style.visible = false end } -- Module Return -- calling will draw the admin buttons to that frame -return setmetatable(AdminGui,{__call=function(self,...) self.draw(...) end}) \ No newline at end of file +return setmetatable(AdminGui,{__call=function(self,...) return self.draw(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Gui/softmod.json b/modules/ExpGamingAdmin/Gui/softmod.json index 41c4f2bd..97fc27d7 100644 --- a/modules/ExpGamingAdmin/Gui/softmod.json +++ b/modules/ExpGamingAdmin/Gui/softmod.json @@ -1,21 +1,23 @@ { - "name": "Gui", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a gui that can be used to access all the admin commands.", - "location": "", - "keywords": [ - "Admin", - "ExpGaming", - "Commands", - "Gui" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingPlayer": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Gui", + "version": "4.0.0", + "description": "Adds a gui that can be used to access all the admin commands.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Admin", + "ExpGaming", + "Commands", + "Gui" + ], + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingPlayer": "?^4.0.0", + "ExpGamingPlayer.playerInfo": "?^4.0.0", + "mod-gui": "*", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/Jail/control.lua b/modules/ExpGamingAdmin/Jail/control.lua index 54c2c608..e868d943 100644 --- a/modules/ExpGamingAdmin/Jail/control.lua +++ b/modules/ExpGamingAdmin/Jail/control.lua @@ -2,14 +2,13 @@ -- @module ExpGamingAdmin.Jail@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local AdminGui = require('ExpGamingAdmin.Gui@^4.0.0') -local Server = require('ExpGamingCore.Server@^4.0.0') -local Role = require('ExpGamingCore.Role@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Admin = require('ExpGamingAdmin') +local AdminGui = require('ExpGamingAdmin.Gui') +local Server = require('ExpGamingCore.Server') +local Role = require('ExpGamingCore.Role') local Color -- FactorioStdLib.Color@^0.8.0 local Sync -- ExpGamingCore.Sync@^4.0.0 @@ -17,34 +16,35 @@ local Sync -- ExpGamingCore.Sync@^4.0.0 local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end - if loaded_modules['FactorioStdLib.Color@^0.8.0'] then Sync = require('FactorioStdLib.Color@^0.8.0') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end end } -- Function Define AdminGui.add_button('jail','utility/clock',{'ExpGamingAdmin.tooltip-jail'},function(player,byPlayer) - Admin.open(byPlayer,player,'jail') + Admin.open(byPlayer,player,'Jail') end) function Admin.jail(player,by_player,reason) - local player = Game.get_player(player) - local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '' - local reason = Admin.create_reason(reason,by_player_name) - if Sync then Sync.emit_embeded{ + player, by_player = Admin.valid_players(player,by_player) + if not player then return end + reason = Admin.create_reason(reason,by_player.name) + Admin.set_banned(player,'jail') + if Sync then Sync.emit_embedded{ title='Player Jail', color=Color.to_hex(defines.textcolor.med), description='There was a player jailed.', ['Player:']='<>'..player.name, - ['By:']='<>'..by_player_name, + ['By:']='<>'..by_player.name, ['Reason:']=reason } end Role.meta.last_jail = player.name - Server.interface(Role.unassign,true,player,Role.get(player),by_player_name) - Server.interface(Role.assign,true,player,'Jail',by_player_name) + Server.interface(Role.assign,true,player,'Jail',by_player.name) + Server.interface(Role.unassign,true,player,Role.get(player),by_player.name) end Admin.add_action('Jail',Admin.jail) -- Module Return -return ThisModule \ No newline at end of file +return setmetatable(ThisModule,{__call=Admin.jail}) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Jail/softmod.json b/modules/ExpGamingAdmin/Jail/softmod.json index 42d83c70..c6dba711 100644 --- a/modules/ExpGamingAdmin/Jail/softmod.json +++ b/modules/ExpGamingAdmin/Jail/softmod.json @@ -1,24 +1,24 @@ { - "name": "Jail", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a jail function to the admin set, require ExpGamingRole to work.", - "location": "", - "keywords": [ - "Jail", - "Roles", - "Admin", - "ExpGaming" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "?^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Jail", + "version": "4.0.0", + "description": "Adds a jail function to the admin set, require ExpGamingRole to work.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Jail", + "Roles", + "Admin", + "ExpGaming" + ], + "dependencies": { + "ExpGamingAdmin.Gui": "^4.0.0", + "ExpGamingCore.Server": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "?^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingAdmin.ClearInventory": "?^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/Kick/control.lua b/modules/ExpGamingAdmin/Kick/control.lua index ad191a75..e36eef2e 100644 --- a/modules/ExpGamingAdmin/Kick/control.lua +++ b/modules/ExpGamingAdmin/Kick/control.lua @@ -2,13 +2,13 @@ -- @module ExpGamingAdmin.Kick@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local AdminGui = require('ExpGamingAdmin.Gui@^4.0.0') -local Server = require('ExpGamingCore.Server@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Admin = require('ExpGamingAdmin') +local AdminGui = require('ExpGamingAdmin.Gui') +local Server = require('ExpGamingCore.Server') +local Game = require('FactorioStdLib.Game') local Color -- FactorioStdLib.Color@^0.8.0 local Sync -- ExpGamingCore.Sync@^4.0.0 @@ -16,20 +16,20 @@ local Sync -- ExpGamingCore.Sync@^4.0.0 local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end - if loaded_modules['FactorioStdLib.Color@^0.8.0'] then Sync = require('FactorioStdLib.Color@^0.8.0') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end end } -- Function Define -AdminGui.add_button('kick','utility/warning_icon',{'ExpGamingAdmin.tooltip-kick'},function(player,byPlayer) - Admin.open(byPlayer,player,'kick') +AdminGui.add_button('Kick','utility/warning_icon',{'ExpGamingAdmin.tooltip-kick'},function(player,byPlayer) + Admin.open(byPlayer,player,'Kick') end) function Admin.kick(player,by_player,reason) - local player = Game.get_player(player) + player = Game.get_player(player) + reason = Admin.create_reason(reason,by_player_name) local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '' - local reason = Admin.create_reason(reason,by_player_name) - if Sync then Sync.emit_embeded{ + if Sync then Sync.emit_embedded{ title='Player Kick', color=Color.to_hex(defines.textcolor.high), description='There was a player kicked.', @@ -44,4 +44,4 @@ end Admin.add_action('Kick',Admin.kick) -- Module Return -return ThisModule \ No newline at end of file +return setmetatable(ThisModule,{__call=Admin.kick}) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Kick/softmod.json b/modules/ExpGamingAdmin/Kick/softmod.json index 8c290a95..26baa78c 100644 --- a/modules/ExpGamingAdmin/Kick/softmod.json +++ b/modules/ExpGamingAdmin/Kick/softmod.json @@ -1,23 +1,23 @@ { - "name": "Kick", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a kick function to the admin function set.", - "location": "", - "keywords": [ - "Admin", - "ExpGaming", - "Kick", - "Commands" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "?^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Kick", + "version": "4.0.0", + "description": "Adds a kick function to the admin function set.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Admin", + "ExpGaming", + "Kick", + "Commands" + ], + "dependencies": { + "ExpGamingAdmin.Gui": "^4.0.0", + "ExpGamingCore.Server": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "?^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingAdmin.ClearInventory": "?^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/Reports/control.lua b/modules/ExpGamingAdmin/Reports/control.lua index 320ccbbf..56fad0ba 100644 --- a/modules/ExpGamingAdmin/Reports/control.lua +++ b/modules/ExpGamingAdmin/Reports/control.lua @@ -2,121 +2,114 @@ -- @module ExpGamingAdmin.Reports@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local Server = require('ExpGamingCore.Server@^4.0.0') -local Role = require('ExpGamingCore.Role@^4.0.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') -local Color = require('FactorioStdLib.Color@^0.8.0') +local Admin = require('ExpGamingAdmin') +local Role = require('ExpGamingCore.Role') +local Gui = require('ExpGamingCore.Gui') +local Game = require('FactorioStdLib.Game') +local Color -- FactorioStdLib.Color@^0.8.0 local Sync -- ExpGamingCore.Sync@^4.0.0 -- Module Define local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end end } -- Global Define local global = global{ reports={}, - varified={} + verified={} } --- Local Varibles +-- Local Variables local report_to_warnings = 1 -- used in count_reports -local varified_to_warings = 3 -- used in count_reports +local verified_to_warnings = 3 -- used in count_reports local reports_needed_for_jail = 6 -- Function Define -local function valid_players(player,by_player) - local player = Game.get_player(player) - local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '' - return player, by_player_name -end - local function report_message(player,by_player,reason) - local player, by_player_name = valid_players(player,by_player) + player, by_player = Admin.valid_players(player,by_player) if not player then return end if Admin.is_banned(player,true) == 'report' then return end Role.print(Role.meta.groups.User.lowest,{'ExpGamingAdmin.low-print',player.name,reason},defines.textcolor.info,true) - Role.print(Role.meta.groups.Admin.lowest,{'ExpGamingAdmin.high-print',player.name,by_player_name,reason},defines.textcolor.med) - if Sync then Sync.emit_embeded{ + Role.print(Role.meta.groups.Admin.lowest,{'ExpGamingAdmin.high-print',player.name,by_player.name,reason},defines.textcolor.med) + if Sync then Sync.emit_embedded{ title='Player Report', color=Color.to_hex(defines.textcolor.med), description='A player was reported.', ['Player:']='<>'..player.name, - ['By:']='<>'..by_player_name, + ['By:']='<>'..by_player.name, ['Reason:']=reason } end end local function cheak_reports(player) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then return end local reports = Admin.count_reports(player) - if reports >= reports_needed_for_jail and global.actions[player.name] ~= 'report-jail' and Role.get_highest(player).group.name ~= 'Jail' then - global.actions[player.name] = actions.report + if reports >= reports_needed_for_jail and Role.get_highest(player).group.name ~= 'Jail' then Admin.jail(player,'','Too many user reports. Contact an Admin to be unjailed.') end end function Admin.count_reports(player) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then return 0 end local _count = 0 if global.reports[player.name] then - for _,report in pairs(global.reports[player.name]) do + for _ in pairs(global.reports[player.name]) do _count=_count+report_to_warnings end end - if global.varified[player.name] then - for _,report in pairs(global.varified[player.name]) do - _count=_count+varified_to_warings + if global.verified[player.name] then + for _ in pairs(global.verified[player.name]) do + _count=_count+verified_to_warnings end end return _count end function Admin.report(player,by_player,reason) - local player, by_player_name = valid_players(player,by_player) - if not player or Role.allowed(player,'no-report') then return end + player, by_player = Admin.valid_players(player,by_player) + if not player or Role.has_flag(player,'not_reportable') then return end if Admin.is_banned(by_player) or Role.has_flag(by_player,'is_jail') then return end - if Role.has_flag(by_player,'is_varified') then - global.varified[player.name] = global.varified[player.name] or {} - local reports = global.varified[player.name] + if Role.has_flag(by_player,'is_verified') then + global.verified[player.name] = global.verified[player.name] or {} + local reports = global.verified[player.name] for _,value in pairs(reports) do - if value[1] == by_player_name then return end + if value[1] == by_player.name then return end end - table.insert(reports,{by_player_name,reason}) + table.insert(reports,{by_player.name,reason}) else global.reports[player.name] = global.reports[player.name] or {} local reports = global.reports[player.name] for _,value in pairs(reports) do - if value[1] == by_player_name then return end + if value[1] == by_player.name then return end end - table.insert(reports,{by_player_name,reason}) + table.insert(reports,{by_player.name,reason}) end report_message(player,by_player,reason) cheak_reports(player) end function Admin.clear_reports(player,by_player,no_emit) - local player, by_player_name = valid_players(player,by_player) + player, by_player = Admin.valid_players(player,by_player) if not player then return end global.reports[player.name]={} - global.varified[player.name]={} + global.verified[player.name]={} if not no_emit and Sync then - Sync.emit_embeded{ + Sync.emit_embedded{ title='Player Clear', color=Color.to_hex(defines.textcolor.low), description='A player had their reports cleared.', ['Player:']='<>'..player.name, - ['By:']='<>'..by_player_name, + ['By:']='<>'..by_player.name, } end end @@ -166,4 +159,4 @@ Admin.report_btn = Gui.inputs{ end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Reports/softmod.json b/modules/ExpGamingAdmin/Reports/softmod.json index 0b6081f5..4aee29bb 100644 --- a/modules/ExpGamingAdmin/Reports/softmod.json +++ b/modules/ExpGamingAdmin/Reports/softmod.json @@ -1,24 +1,25 @@ { - "name": "Reports", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a report system into the game that can also push notifactions to discord.", - "location": "", - "keywords": [ - "Report", - "Player", - "Admin", - "ExpGaming", - "Player List", - "Commands" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Reports", + "version": "4.0.0", + "description": "Adds a report system into the game that can also push notifactions to discord.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Report", + "Player", + "Admin", + "ExpGaming", + "Player List", + "Commands" + ], + "dependencies": { + "ExpGamingCore.Server": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "?^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/Teleport/control.lua b/modules/ExpGamingAdmin/Teleport/control.lua index ed685f2b..f745add4 100644 --- a/modules/ExpGamingAdmin/Teleport/control.lua +++ b/modules/ExpGamingAdmin/Teleport/control.lua @@ -2,22 +2,22 @@ -- @module ExpGamingAdmin.Teleport@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local AdminGui = require('ExpGamingAdmin.Gui@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Admin = require('ExpGamingAdmin') +local AdminGui = require('ExpGamingAdmin.Gui') +local Game = require('FactorioStdLib.Game') -- Module Define local module_verbose = false local ThisModule = {} -- Function Define -AdminGui.add_button('goto','utility/export_slot',{'ExpGamingAdmin.tooltip-go-to'},function(player,byPlayer) +AdminGui.add_button('Go To','utility/export_slot',{'ExpGamingAdmin.tooltip-go-to'},function(player,byPlayer) Admin.go_to(player,byPlayer) end) -AdminGui.add_button('bring','utility/import_slot',{'ExpGamingAdmin.tooltip-bring'},function(player,byPlayer) +AdminGui.add_button('Bring','utility/import_slot',{'ExpGamingAdmin.tooltip-bring'},function(player,byPlayer) Admin.bring(player,byPlayer) end) @@ -40,4 +40,4 @@ Admin.add_action('Go To',Admin.go_to) Admin.add_action('Bring',Admin.bring) -- Module Return -return ThisModule \ No newline at end of file +return setmetatable(ThisModule,{__call=Admin.tp}) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Teleport/softmod.json b/modules/ExpGamingAdmin/Teleport/softmod.json index 069f2b68..2bebb4c4 100644 --- a/modules/ExpGamingAdmin/Teleport/softmod.json +++ b/modules/ExpGamingAdmin/Teleport/softmod.json @@ -1,22 +1,22 @@ { - "name": "Teleport", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds three function to admin: tp, bring and go to, these all move the player.", - "location": "", - "keywords": [ - "Tp", - "Bring", - "Go To", - "Admin", - "ExpGaming", - "Teleport", - "Commands" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Teleport", + "version": "4.0.0", + "description": "Adds three function to admin: tp, bring and go to, these all move the player.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Tp", + "Bring", + "Go To", + "Admin", + "ExpGaming", + "Teleport", + "Commands" + ], + "dependencies": { + "ExpGamingAdmin.Gui": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/TempBan/control.lua b/modules/ExpGamingAdmin/TempBan/control.lua index bd0c087d..5848fd5c 100644 --- a/modules/ExpGamingAdmin/TempBan/control.lua +++ b/modules/ExpGamingAdmin/TempBan/control.lua @@ -2,21 +2,22 @@ -- @module ExpGamingAdmin.KicTempBan@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local Server = require('ExpGamingCore.Server@^4.0.0') -local Role = require('ExpGamingCore.Role@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') -local Color = require('FactorioStdLib.Color@^0.8.0') +local Admin = require('ExpGamingAdmin') +local Server = require('ExpGamingCore.Server') +local Role = require('ExpGamingCore.Role') +local Game = require('FactorioStdLib.Game') +local Color -- FactorioStdLib.Color@^0.8.0 local Sync -- ExpGamingCore.Sync@^4.0.0 -- Module Define local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end end } @@ -26,7 +27,7 @@ function Admin.temp_ban(player,by_player,reason) local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '' if not player or Admin.is_banned(player) then return end Admin.set_banned(player,'temp') - if Sync then Sync.emit_embeded{ + if Sync then Sync.emit_embedded{ title='Player Temp-Ban', color=Color.to_hex(defines.textcolor.high), description='A player was jailed.', @@ -44,4 +45,4 @@ end Admin.add_action('Temp Ban',Admin.temp_ban) -- Module Return -return ThisModule \ No newline at end of file +return setmetatable(ThisModule,{__call=Admin.temp_ban}) \ No newline at end of file diff --git a/modules/ExpGamingAdmin/TempBan/softmod.json b/modules/ExpGamingAdmin/TempBan/softmod.json index ce736b34..64853ebb 100644 --- a/modules/ExpGamingAdmin/TempBan/softmod.json +++ b/modules/ExpGamingAdmin/TempBan/softmod.json @@ -1,24 +1,24 @@ { - "name": "TempBan", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.", - "location": "", - "keywords": [ - "Jail", - "Temp Ban", - "Admin", - "ExpGaming", - "Roles" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.TempBan", + "version": "4.0.0", + "description": "Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Jail", + "Temp Ban", + "Admin", + "ExpGaming", + "Roles" + ], + "dependencies": { + "ExpGamingCore.Server": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "?^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingAdmin.ClearInventory": "?^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/Warnings/control.lua b/modules/ExpGamingAdmin/Warnings/control.lua index 5514ad60..07cd6994 100644 --- a/modules/ExpGamingAdmin/Warnings/control.lua +++ b/modules/ExpGamingAdmin/Warnings/control.lua @@ -2,18 +2,18 @@ -- @module ExpGamingAdmin.Warnings@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local Server = require('ExpGamingCore.Server@^4.0.0') -local Role = require('ExpGamingCore.Role@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') -local Color = require('FactorioStdLib.Color@^0.8.0') +local Admin = require('ExpGamingAdmin') +local Server = require('ExpGamingCore.Server') +local Role = require('ExpGamingCore.Role') +local Game = require('FactorioStdLib.Game') +local Color -- FactorioStdLib.Color@^0.8.0 local Sync -- ExpGamingCore.Sync@^4.0.0 --- Local Varibles -local take_action = 8 -- below this number no action is taken, the first admin given warning jumps to this number +-- Local Variables +local take_action = 8 -- the first admin given warning jumps to this number, this case kick-warn is giving local remove_warnings_time = {} local min_time_to_remove_warning = 18000 -- this is in ticks local punishments = { @@ -22,14 +22,14 @@ local punishments = { {'nothing'}, {'nothing'}, {'nothing'}, - {'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.textcolor.info}, - {'message',{'ExpGamingAdmin-Warnings@4-0-0.message'},defines.textcolor.info}, - {'message',{'ExpGamingAdmin-Warnings@4-0-0.kick-warn'},defines.textcolor.med}, + {'message',{'ExpGamingAdmin-Warnings.message'},defines.textcolor.info}, + {'message',{'ExpGamingAdmin-Warnings.message'},defines.textcolor.info}, + {'message',{'ExpGamingAdmin-Warnings.kick-warn'},defines.textcolor.med}, {'kick'}, - {'message',{'ExpGamingAdmin-Warnings@4-0-0.temp-warn'},defines.textcolor.high}, + {'message',{'ExpGamingAdmin-Warnings.temp-warn'},defines.textcolor.high}, {'temp-ban'}, - {'message',{'ExpGamingAdmin-Warnings@4-0-0.ban-warn'},defines.textcolor.high}, - {'message',{'ExpGamingAdmin-Warnings@4-0-0.last-warn'},defines.textcolor.crit}, + {'message',{'ExpGamingAdmin-Warnings.ban-warn'},defines.textcolor.high}, + {'message',{'ExpGamingAdmin-Warnings.last-warn'},defines.textcolor.crit}, {'ban'} } @@ -37,10 +37,11 @@ local punishments = { local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end - if loaded_modules['ExpGamingAdmin.Reports@^4.0.0'] then + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['FactorioStdLib.Color'] then Color = require('FactorioStdLib.Color') end + if loaded_modules['ExpGamingAdmin.Reports'] then take_action = take_action + 1 - table.insert(punishments,take_action,{'report',{'ExpGamingAdmin-Warnings@4-0-0.reported'},defines.textcolor.med}) + table.insert(punishments,take_action,{'report',{'ExpGamingAdmin-Warnings.reported'},defines.textcolor.med}) end end, on_post=function() @@ -59,17 +60,11 @@ local ThisModule = { local global = global{} -- Function Define -local function valid_players(player,by_player) - local player = Game.get_player(player) - local by_player_name = Game.get_player(by_player) and Game.get_player(by_player).name or '' - return player, by_player_name -end - local function give_punishment(player,by_player,reason) - local player, by_player_name = valid_players(player,by_player) + player, by_player = Admin.valid_players(player,by_player) + reason = reason or 'No Other Reason' local warnings = Admin.get_warnings(player) local punishment = punishments[warnings] - local reason = reason or 'No Other Reason' if not punishment or punishment[1] == 'nothing' then return elseif punishment[1] == 'message' then local message = punishment[2] @@ -81,47 +76,45 @@ local function give_punishment(player,by_player,reason) player_return(message,colour,player) Admin.report(player,'',reason) elseif punishment[1] == 'kick' then - global.actions[player.name] = actions.kick Admin.kick(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason) elseif punishment[1] == 'temp-ban' then Admin.temp_ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason) elseif punishment[1] == 'ban' then - global.actions[player.name] = actions.ban Admin.ban(player,by_player,'Too Many Warnings: '..warnings-(take_action-1)..' Also: '..reason) end end function Admin.get_warnings(player) - local player = Game.get_player(player) + player = Game.get_player(player) return global[player.name] or 0 end function Admin.give_warning(player,by_player,reason,min) - local player, by_player_name = valid_players(player,by_player) + player, by_player = Admin.valid_players(player,by_player) if not player then return end - local min = Game.get_player(by_player) and take_action or min or 0 + min = Game.get_player(by_player) and Game.get_player(by_player) ~= SERVER and take_action or min or 0 local warnings = Admin.get_warnings(player) - if warnings < min then warnings = min end + if warnings < min then warnings = min-1 end warnings = warnings+1 global[player.name] = warnings if warnings > take_action then - player_return({'ExpGamingAdmin-Warnings@4-0-0.warning-given-by',by_player_name},defines.textcolor.info,player) - game.print({'ExpGamingAdmin-Warnings@4-0-0.player-warning',player.name,by_player_name,reason}) + player_return({'ExpGamingAdmin-Warnings.warning-given-by',by_player.name},defines.textcolor.info,player) + game.print({'ExpGamingAdmin-Warnings.player-warning',player.name,by_player.name,reason}) end give_punishment(player,by_player,reason) end -function Admin.clear_warings(player,by_player,no_emit) - local player, by_player_name = valid_players(player,by_player) +function Admin.clear_warnings(player,by_player,no_emit) + player, by_player = Admin.valid_players(player,by_player) if not player then return end - global[player.name]=0 + global[player.name]=nil if not no_emit and Sync then - Sync.emit_embeded{ + Sync.emit_embedded{ title='Player Clear', color=Color.to_hex(defines.textcolor.low), description='A player had their warnings cleared.', ['Player:']='<>'..player.name, - ['By:']='<>'..by_player_name, + ['By:']='<>'..by_player.name, } end end @@ -131,12 +124,12 @@ script.on_event(defines.events.on_tick,function(event) if (game.tick % min_time_to_remove_warning) == 0 then for name,warnings in pairs(global) do if warnings > 0 then - local role = Role.get(name) + local role = Role.get_highest(name) local time_to_remove = remove_warnings_time[role.index] if (game.tick % time_to_remove) == 0 then global[name]=warnings-1 - if global.warnings[name] > 5 then - player_return({'ExpGamingAdmin-Warnings@4-0-0.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.textcolor.low,name) + if global[name] > 5 then + player_return({'ExpGamingAdmin-Warnings.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.textcolor.low,name) end end end @@ -145,4 +138,4 @@ script.on_event(defines.events.on_tick,function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingAdmin/Warnings/locale/de.cfg b/modules/ExpGamingAdmin/Warnings/locale/de.cfg index 3a62ea44..c48f518a 100644 --- a/modules/ExpGamingAdmin/Warnings/locale/de.cfg +++ b/modules/ExpGamingAdmin/Warnings/locale/de.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=This Warnings Was Given By: __1__ player-warning=__1__ was given a warning by __2__ reason: __3__ temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset diff --git a/modules/ExpGamingAdmin/Warnings/locale/en.cfg b/modules/ExpGamingAdmin/Warnings/locale/en.cfg index 6378521b..01715fc7 100644 --- a/modules/ExpGamingAdmin/Warnings/locale/en.cfg +++ b/modules/ExpGamingAdmin/Warnings/locale/en.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=This warning was given by: __1__ player-warning=__1__ was given a warning by __2__ for: __3__ remove-warn=One of your warnings expired. You have __1__ warnings left, next warning will be removed in __2__ diff --git a/modules/ExpGamingAdmin/Warnings/locale/fr.cfg b/modules/ExpGamingAdmin/Warnings/locale/fr.cfg index 3a62ea44..c48f518a 100644 --- a/modules/ExpGamingAdmin/Warnings/locale/fr.cfg +++ b/modules/ExpGamingAdmin/Warnings/locale/fr.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=This Warnings Was Given By: __1__ player-warning=__1__ was given a warning by __2__ reason: __3__ temp-ban=__1__ was temp-ban by __2__ and will remain in jail untill next reset diff --git a/modules/ExpGamingAdmin/Warnings/locale/nl.cfg b/modules/ExpGamingAdmin/Warnings/locale/nl.cfg index 69b8004e..104ef981 100644 --- a/modules/ExpGamingAdmin/Warnings/locale/nl.cfg +++ b/modules/ExpGamingAdmin/Warnings/locale/nl.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=Deze waarschuwing is gegeven door: __1__ player-warning=__1__ is gewaarschuwd door __2__ met de reden: __3__ temp-ban=__1__ is verbannen door __2__ en is gejailed tot de volgende reset. diff --git a/modules/ExpGamingAdmin/Warnings/locale/sv-SE.cfg b/modules/ExpGamingAdmin/Warnings/locale/sv-SE.cfg index b130aac3..9358b9cf 100644 --- a/modules/ExpGamingAdmin/Warnings/locale/sv-SE.cfg +++ b/modules/ExpGamingAdmin/Warnings/locale/sv-SE.cfg @@ -1,4 +1,4 @@ -[ExpGamingAdmin-Warnings-4-0-0] +[ExpGamingAdmin-Warnings] warning-given-by=Den här varningen gavs av: __1__ player-warning=__1__ var tillfälligt bannlyst av __2__ och kommer att förbli i fängelset tills nästa återställning (reset) remove-warn=En av dina varningar har gått ut. Du har __1__ varning kvar, nästa varning kommer at tas bort om __2__ diff --git a/modules/ExpGamingAdmin/Warnings/softmod.json b/modules/ExpGamingAdmin/Warnings/softmod.json index 30442ad2..70c11140 100644 --- a/modules/ExpGamingAdmin/Warnings/softmod.json +++ b/modules/ExpGamingAdmin/Warnings/softmod.json @@ -1,26 +1,26 @@ { - "name": "Warnings", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a warning system into the admin set which can be used by admins and the script.", - "location": "", - "keywords": [ - "Warning", - "Admin", - "ExpGaming", - "Report", - "Kick", - "Punishments", - "Ban" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "ExpGamingAdmin.Reports": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" -} \ No newline at end of file + "name": "ExpGamingAdmin.Warnings", + "version": "4.0.0", + "description": "Adds a warning system into the admin set which can be used by admins and the script.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Warning", + "Admin", + "ExpGaming", + "Report", + "Kick", + "Punishments", + "Ban" + ], + "dependencies": { + "ExpGamingCore.Server": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "?^0.8.0", + "ExpGamingAdmin.Reports": "?^4.0.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingAdmin@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingAdmin/AdminLib/control.lua b/modules/ExpGamingAdmin/control.lua similarity index 56% rename from modules/ExpGamingAdmin/AdminLib/control.lua rename to modules/ExpGamingAdmin/control.lua index 493845e4..4d4f20e1 100644 --- a/modules/ExpGamingAdmin/AdminLib/control.lua +++ b/modules/ExpGamingAdmin/control.lua @@ -1,23 +1,29 @@ --- The base functions required to make the others work. --- @module ExpGamingAdmin.AdminLib@4.0.0 +-- @module ExpGamingAdmin@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais Admin +-- @alias Admin -- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') +local Color = require('FactorioStdLib.Color') local Role -- ExpGamingCore.Role@^4.0.0 local Sync -- ExpGamingCore.Sync@^4.0.0 +local Server -- ExpGamingCore.Server@^4.0.0 -- Module Define local module_verbose = false local Admin = { on_init=function() - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end - if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Admin','ExpGamingAdmin.AdminLib') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['ExpGamingCore.Server'] then + Server = require('ExpGamingCore.Server') + Server.add_module_to_interface('Admin','ExpGamingAdmin') + end end, actions={}, + action_functions={}, action_names={} } @@ -27,8 +33,14 @@ local global = global{ } -- Function Define +function Admin.valid_players(player,by_player) + player = Game.get_player(player) + by_player = Game.get_player(by_player) or SERVER + return player, by_player +end + function Admin.create_reason(reason,name) - local reason = reason or 'No Reason' + reason = reason or 'No Reason' if not string.find(string.lower(reason),string.lower(name)) then reason = reason..' - '..name end if Sync and Sync.info.date ~= '0000/00/00' and not string.find(string.lower(reason),Sync.info.date) then reason = reason..' - '..Sync.info.date end if not string.find(string.lower(reason),'appeal') then reason = reason..' - Vist www.explosivegaming.nl to appeal.' end @@ -36,20 +48,20 @@ function Admin.create_reason(reason,name) end function Admin.allowed(player) - local player = Game.get_player(player) + player = Game.get_player(player) if Role then return Role.allowed(player,'admin-commands') else return player.admin end end function Admin.set_banned(player,set) - local player=Game.get_player(player) + player = Game.get_player(player) if not player then return false end global.banned[player.name] = set end function Admin.is_banned(player,detail) - local player=Game.get_player(player) + player = Game.get_player(player) if not player then return false end local banned = global.banned[player.name] if banned == true then return true end @@ -60,28 +72,28 @@ end function Admin.add_action(action,callback) verbose('Added admin action: '..action) - table.insert(Admin.action_names,action) - Admin.actions[string.lower(action)] = callback + Admin.actions[string.lower(action)] = table.insert(Admin.action_names,action) + Admin.action_functions[string.lower(action)] = callback end function Admin.take_action(action,player,by_player,reason) + if Admin.action_functions[string.lower(action)] then Admin.action_functions[string.lower(action)](player,by_player,reason) end if Admin[action] then Admin[action](player,by_player,reason) end - if Admin.actions[string.lower(action)] then Admin.actions[string.lower(action)](player,by_player,reason) end end function Admin.clear_player(player,by_player) - local player, by_player_name = valid_players(player,by_player) + player, by_player = Admin.valid_players(player,by_player) if not player then return end - if Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player,by_player) end - if Admin.clear_warings then Admin.clear_warings(player,by_player,true) end + if Server and Admin.is_banned(player,true) == true then Server.interface(game.unban_player,true,player) end + if Admin.clear_warnings then Admin.clear_warnings(player,by_player,true) end if Admin.clear_reports then Admin.clear_reports(player,by_player,true) end - if Role.has_flag(player,'is_jail') then Server.interface(Role.revert,true,player,by_player,2) end - if Sync then Sync.emit_embeded{ + if Server and Role.has_flag(player,'is_jail') then Server.interface(Role.revert,true,player,by_player,2) end + if Sync then Sync.emit_embedded{ title='Player Clear', color=Color.to_hex(defines.textcolor.low), description='A player had their reports and warnings cleared.', ['Player:']='<>'..player.name, - ['By:']='<>'..by_player_name, + ['By:']='<>'..by_player.name, } end Admin.set_banned(player,false) end diff --git a/modules/ExpGamingAdmin/locale/de.cfg b/modules/ExpGamingAdmin/locale/de.cfg new file mode 100644 index 00000000..299b094f --- /dev/null +++ b/modules/ExpGamingAdmin/locale/de.cfg @@ -0,0 +1,15 @@ +[ExpGamingAdmin] +name=Admin-Befehle +tooltip=Die mächtigsten Befehle sind hier zuhause. +no-info-file=Die Informationsdatei wurde nicht gefunden. +message=Wähle einen Spieler und eine Aktion. Stell vor dem Ausführen sicher, dass der Richtige ist! +warning=Achtung, dieser Spieler hat einen höheren Rang als du selbst, weshalb du seinen Rang nicht ändern kannst. +short-reason=Achtung, dies ist ein sehr kurzer Grund. Bitte versuche, mehr Informationen anzugeben. (Warning: The reason is too short. UPDATE) +rank-high=Dieser Spieler hat einen hohen Rang. Bitte benutze nur Ingame-Befehle gegen diese Person, wenn du dir sicher bist! +invalid=Der Spieler oder die Aktion war ungültig. Bitte versuche es noch einmal! +take-action= Ergreife Maßnahme +tooltip-ban=Banne Spieler +tooltip-kick=Kicke Spieler +tooltip-jail=Sperre Spieler ins Gefängnis +tooltip-go-to=Gehe zum Spieler +tooltip-bring=Bringe den Spieler zu dir \ No newline at end of file diff --git a/modules/ExpGamingAdmin/locale/en.cfg b/modules/ExpGamingAdmin/locale/en.cfg new file mode 100644 index 00000000..f240bac1 --- /dev/null +++ b/modules/ExpGamingAdmin/locale/en.cfg @@ -0,0 +1,21 @@ +[ExpGamingAdmin] +name=Admin Commands +tooltip=Admin commands make their home here +no-info-file=No info file was found +message=Please select a player and an action to take. Make sure to choose the correct one! +warning=Warning: This player outranks you. Therefore, you cannot edit their rank. +short-reason=Warning: The reason is too short. +rank-high=Warning: This player outranks you. Therefore, you cannot edit their rank. +invalid=The player or the action is invalid. Please try again! +take-action=Take Action +tooltip-ban=Ban Player +tooltip-kick=Kick Player +tooltip-jail=Jail Player +tooltip-go-to=Go To Player +tooltip-bring=Bring Player +temp-ban=__1__ was temporary banned by __2__ and will remain in jail until next reset +report=Report Player +cant-report-ban=Invalid player as player is banned; Either unban or use /clear-all +low-print=__1__ has been reported by a user for: __2__ +high-print=__1__ has been reported by __2__ for: __3__ +cant-report=This player can't be reported. \ No newline at end of file diff --git a/modules/ExpGamingAdmin/locale/fr.cfg b/modules/ExpGamingAdmin/locale/fr.cfg new file mode 100644 index 00000000..f882fc1c --- /dev/null +++ b/modules/ExpGamingAdmin/locale/fr.cfg @@ -0,0 +1,15 @@ +[ExpGamingAdmin] +name=Commandes Admin +tooltip=Des commandes très puissantes résident ici. +no-info-file=Aucun fichier info trouvé +message=Veuillez sélectionner un joueur et une action, faites en sorte que ce soit la bonne ! +warning=Attention, ce joueur est de rang supérieur au vôtre, vous ne pouvez le modifier. +short-reason=Attention, la raison indiquée est trop courte. Soyez concis mais aussi précis. (Warning: The reason is too short. UPDATE) +rank-high=Ce joueur est de rang supérieur, veuillez utiliser une commande dont vous maîtriser l'utilisation ! +invalid=Le Joueur ou l'action est invalide, ré-essayez ! +take-action=Agir +tooltip-ban=Bannir un Joueur +tooltip-kick=Exclure un Joueur +tooltip-jail=Emprisonner un Joueur +tooltip-go-to=Aller à la position d'un Joueur +tooltip-bring=Amener le Joueur à soi diff --git a/modules/ExpGamingAdmin/locale/nl.cfg b/modules/ExpGamingAdmin/locale/nl.cfg new file mode 100644 index 00000000..ff47947a --- /dev/null +++ b/modules/ExpGamingAdmin/locale/nl.cfg @@ -0,0 +1,15 @@ +[ExpGamingAdmin] +name=Admin Commands +tooltip=Admin Commands kan je hier vinden. +no-info-file=Infobestand niet gevonden. +message=Selecteer een speler en de bijbehorende actie. Wees er zeker van dat je de correcte actie kiest. +warning=Fout: Je kan de rank van deze speler niet aanpassen omdat het jouw rank overtreft. +short-reason=Fout: De reden is te kort. (Warning: The reason is too short. UPDATE) +rank-high=Fout: Deze speler overtreft jouw rank. +invalid=Fout: De speler kan niet gevonden worden en/of de actie is onjuist. Probeer opnieuw! +take-action=Actie ondernemen +tooltip-ban=Ban speler +tooltip-kick=Kick speler +tooltip-jail=Jail speler +tooltip-go-to=Ga naar speler +tooltip-bring=Breng speler diff --git a/modules/ExpGamingAdmin/locale/sv-SE.cfg b/modules/ExpGamingAdmin/locale/sv-SE.cfg new file mode 100644 index 00000000..679188c2 --- /dev/null +++ b/modules/ExpGamingAdmin/locale/sv-SE.cfg @@ -0,0 +1,19 @@ +[ExpGamingAdmin] +name=Adminkommandon +tooltip=Adminkommando gör dit hem här +no-info-file=Ingen informationsfil kunde hittas +message=Var snäll och välj en spelare och en åtgärd att utfärda, se till att du väljer den rätta! +warning=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang. +short-reason=Warning: Skälet är för kort. +rank-high=Warning: Den här spelaren har högre rang än dig. Därför kan du inte redigera dess rang. +invalid=Spelaren eller åtgärden är ogiltig. Var vänlig och försök igen! +take-action=Utför åtgärd. +tooltip-ban=Bannlys Spelare +tooltip-kick=Sparka Spelare +tooltip-jail=Fängsla Spelare +tooltip-go-to=Gå till Spelare +tooltip-bring=Hämta spelare +report=Rapportera Spelare +low-print=__1__ har blivit rapporterad av __2__ för: __3__ +high-print=__1__ har blivit rapporterad av __2__ för: __3__ +cant-report=Den här spelaren kan inte bli rapporterad. diff --git a/modules/ExpGamingAdmin/softmod.json b/modules/ExpGamingAdmin/softmod.json index 1169cb21..efeae92e 100644 --- a/modules/ExpGamingAdmin/softmod.json +++ b/modules/ExpGamingAdmin/softmod.json @@ -1,275 +1,37 @@ { - "name": "ExpGamingAdmin", - "version": "4.0.0", - "type": "Collection", - "description": "A set of useful admin commands and functions that can be used by other modules.", - "location": "", - "keywords": [ - "Admin", - "ExpGaming", - "Set", - "Commands", - "Functions", - "Scripts", - "Useful" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "submodules": { - "AdminLib": { - "name": "AdminLib", - "version": "4.0.0", - "type": "Submodule", - "description": "The base functions required to make the others work.", - "location": "", - "keywords": [ - "lib", - "ExpGaming", - "Admin" - ], - "dependencies": { - "FactorioStdLib": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Ban": { - "name": "Ban", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a custom ban function to the admin command set.", - "location": "", - "keywords": [ - "Ban", - "Admin", - "Set", - "ExpGaming" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "?^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "ClearInventory": { - "name": "ClearInventory", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a function to clear a players inventoy and move the items to spawn.", - "location": "", - "keywords": [ - "Spawn", - "Items", - "Admin", - "Move", - "Clear", - "Inventory" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Gui": { - "name": "Gui", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a gui that can be used to access all the admin commands.", - "location": "", - "keywords": [ - "Admin", - "ExpGaming", - "Commands", - "Gui" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingPlayer": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Jail": { - "name": "Jail", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a jail function to the admin set, require ExpGamingCore.Role to work.", - "location": "", - "keywords": [ - "Jail", - "Roles", - "Admin", - "ExpGaming" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "?^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Kick": { - "name": "Kick", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a kick function to the admin function set.", - "location": "", - "keywords": [ - "Admin", - "ExpGaming", - "Kick", - "Commands" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "?^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Reports": { - "name": "Reports", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a report system into the game that can also push notifactions to discord.", - "location": "", - "keywords": [ - "Report", - "Player", - "Admin", - "ExpGaming", - "Player List", - "Commands" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Teleport": { - "name": "Teleport", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds three function to admin: tp, bring and go to, these all move the player.", - "location": "", - "keywords": [ - "Tp", - "Bring", - "Go To", - "Admin", - "ExpGaming", - "Teleport", - "Commands" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingAdmin.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "TempBan": { - "name": "TempBan", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a temp ban function to the admin set, requires ExpGamingCore.Role to work.", - "location": "", - "keywords": [ - "Jail", - "Temp Ban", - "Admin", - "ExpGaming", - "Roles" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Warnings": { - "name": "Warnings", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a warning system into the admin set which can be used by admins and the script.", - "location": "", - "keywords": [ - "Warning", - "Admin", - "ExpGaming", - "Report", - "Kick", - "Punishments", - "Ban" - ], - "dependencies": { - "ExpGamingAdmin.AdminLib": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "ExpGamingAdmin.Reports": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - }, - "Commands": { - "name": "Commands", - "version": "4.0.0", - "type": "Submodule", - "description": "Admins many of the admin featues which the script can use as in game commands.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.admin_4.0.0.zip", - "keywords": [ - "ExpGaming", - "Admin", - "Tools", - "Commands", - "Temp ban", - "Jail", - "Clear Inventory", - "Report", - "Warnings" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingAdmin.TempBan": "?^4.0.0", - "ExpGamingAdmin.Jail": "?^4.0.0", - "ExpGamingAdmin.Warnings": "?^4.0.0", - "ExpGamingAdmin.Reports": "^?4.0.0", - "ExpGamingAdmin.ClearInventory": "?^4.0.0" - }, - "collection": "ExpGamingAdmin_4.0.0" - } - }, - "dependencies": {} -} \ No newline at end of file + "name": "ExpGamingAdmin", + "version": "4.0.0", + "description": "A set of useful admin commands and functions that can be used by other modules.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Admin", + "ExpGaming", + "Set", + "Commands", + "Functions", + "Scripts", + "Useful" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "submodules": { + "ExpGamingAdmin": "4.0.0", + "ExpGamingAdmin.Ban": "4.0.0", + "ExpGamingAdmin.ClearInventory": "4.0.0", + "ExpGamingAdmin.Gui": "4.0.0", + "ExpGamingAdmin.Jail": "4.0.0", + "ExpGamingAdmin.Kick": "4.0.0", + "ExpGamingAdmin.Reports": "4.0.0", + "ExpGamingAdmin.Teleport": "4.0.0", + "ExpGamingAdmin.TempBan": "4.0.0", + "ExpGamingAdmin.Warnings": "4.0.0", + "ExpGamingAdmin.Commands": "4.0.0" + }, + "dependencies": { + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingCore.Server": "?^4.0.0", + "FactorioStdLib.Game": "^0.8.0" + } +} diff --git a/modules/ExpGamingBot/autoChat/control.lua b/modules/ExpGamingBot/autoChat/control.lua index ac0b65cb..b56bc760 100644 --- a/modules/ExpGamingBot/autoChat/control.lua +++ b/modules/ExpGamingBot/autoChat/control.lua @@ -1,15 +1,15 @@ ---- Sends messages in chat in resposce to other messages +--- Sends messages in chat in response to other messages -- @module ExpGamingBot.autoChat -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') -local Server = require('ExpGamingCore.Server@^4.0.0') +local Game = require('FactorioStdLib.Game') +local Server = require('ExpGamingCore.Server') local Role -- ExpGamingCore.Role@^4.0.0 --- Local Varibles +-- Local Variables -- lots of these are jokes, but some have uses -- white spaces removed and made into lower @@ -34,12 +34,12 @@ local messages = { } -- white spaces removed and made into lower -- these are global chat commands that can be used --- comands start with ! (all messages are also commands) +-- commands start with ! (all messages are also commands) local command_syntax = '!' local commands = { - ['online']=function(player) return {'ExpGamingBot-autoChat.players-online',#game.connected_players} end, - ['playtime']=function(player) return {'ExpGamingBot-autoChat.map-time',tick_to_display_format(game.tick)} end, - ['players']=function(player) return {'ExpGamingBot-autoChat.players',#game.players} end, + ['online']=function() return {'ExpGamingBot-autoChat.players-online',#game.connected_players} end, + ['playtime']=function() return {'ExpGamingBot-autoChat.map-time',tick_to_display_format(game.tick)} end, + ['players']=function() return {'ExpGamingBot-autoChat.players',#game.players} end, ['dev']={'ExpGamingBot-autoChat.not-real-dev'}, ['blame']=function(player) local names = {'Cooldude2606','arty714','badgamernl',player.name} return {'ExpGamingBot-autoChat.blame',names[math.random(#names)]} end, ['readme']={'ExpGamingBot-autoChat.read-readme'}, @@ -49,15 +49,17 @@ local commands = { ['lenny']={'ExpGamingBot-autoChat.lenny'}, ['feedback']={'ExpGamingBot-autoChat.feedback'}, ['wiki']={'ExpGamingBot-autoChat.wiki'}, - ['hodor']=function(player) local options = {'?','.','!','!!!'} return {'ExpGamingBot-autoChat.hodor',options[math.random(#options)]} end, - ['evolution']=function(player) return {'ExpGamingBot-autoChat.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)} end, + ['hodor']=function() local options = {'?','.','!','!!!'} return {'ExpGamingBot-autoChat.hodor',options[math.random(#options)]} end, + ['evolution']=function() return {'ExpGamingBot-autoChat.current-evolution',string.format('%.2f',game.forces['enemy'].evolution_factor)} end, --Jokes about food and drink ['whattoeat']={'ExpGamingBot-autoChat.food'}, + ['makepopcorn']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data=player.name }:on_event('timeout',function(self) if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-popcorn-2',self.data}} end end):open() return {'ExpGamingBot-autoChat.get-popcorn-1'} end, + ['orderpizza']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true }:on_event('timeout',function(self) @@ -66,6 +68,7 @@ local commands = { end self.data[2]=self.data[2]+1 end):open() return {'ExpGamingBot-autoChat.order-pizza-1'} end, + ['passsomesnaps']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true }:on_event('timeout',function(self) @@ -74,6 +77,7 @@ local commands = { end self.data[2]=self.data[2]+1 end):open() return {'ExpGamingBot-autoChat.get-snaps-1'} end, + ['makecocktail']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true }:on_event('timeout',function(self) @@ -82,11 +86,13 @@ local commands = { end self.data[2]=self.data[2]+1 end):open() return {'ExpGamingBot-autoChat.get-cocktail-1'} end, + ['makecoffee']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data=player.name }:on_event('timeout',function(self) if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.make-coffee-2',self.data}} end end):open() return {'ExpGamingBot-autoChat.make-coffee-1'} end, + ['orderpizza']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data={player.name,0}, reopen=true }:on_event('timeout',function(self) @@ -95,21 +101,25 @@ local commands = { end self.data[2]=self.data[2] + 1 end):open() return {'ExpGamingBot-autoChat.order-pizza-1'} end, + ['maketea']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data=player.name }:on_event('timeout',function(self) if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.make-tea-2',self.data}} end end):open() return {'ExpGamingBot-autoChat.make-tea-1'} end, + ['popcorn']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data=player.name }:on_event('timeout',function(self) if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-popcorn-2',self.data}} end end):open() return {'ExpGamingBot-autoChat.get-popcorn-1'} end, + ['meadplease']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data=player.name }:on_event('timeout',function(self) if self.data then game.print{'ExpGamingBot-autoChat.message',{'ExpGamingBot-autoChat.get-mead-2',self.data}} end end):open() return {'ExpGamingBot-autoChat.get-mead-1'} end, + ['passabeer']=function(player) Server.new_thread{ timeout=math.floor(180*(math.random()+0.5)),data=player.name }:on_event('timeout',function(self) @@ -121,7 +131,7 @@ local commands = { local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end end } @@ -153,4 +163,4 @@ script.on_event(defines.events.on_console_chat,function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingBot/autoChat/softmod.json b/modules/ExpGamingBot/autoChat/softmod.json index 22f4c342..7c790178 100644 --- a/modules/ExpGamingBot/autoChat/softmod.json +++ b/modules/ExpGamingBot/autoChat/softmod.json @@ -1,19 +1,19 @@ { - "name": "autoChat", - "version": "4.0.0", - "type": "Submodule", - "description": "Sends messages in chat based on what has been said by other players", - "location": "", - "keywords": [ - "Chat", - "Bot", - "Jokes", - "Fun" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingBot_4.0.0" -} \ No newline at end of file + "name": "ExpGamingBot.autoChat", + "version": "4.0.0", + "description": "Sends messages in chat based on what has been said by other players", + "location": "FSM_ARCHIVE", + "keywords": [ + "Chat", + "Bot", + "Jokes", + "Fun" + ], + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Server": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0" + }, + "collection": "ExpGamingBot@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingBot/autoMessage/control.lua b/modules/ExpGamingBot/autoMessage/control.lua index 00906d71..b21a0f7c 100644 --- a/modules/ExpGamingBot/autoMessage/control.lua +++ b/modules/ExpGamingBot/autoMessage/control.lua @@ -2,7 +2,7 @@ -- @module ExpGamingBot.autoMessage -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require local Server = require('ExpGamingCore.Server') @@ -10,14 +10,14 @@ local Game = require('FactorioStdLib.Game') local Role -- ExpGamingCore.Role@4.0.0 local Sync -- ExpGamingCore.Sync@4.0.0 --- Local Varibles +-- Local Variables -- Module Define local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end end, on_post=function() --code @@ -25,7 +25,7 @@ local ThisModule = { } -- Event Handlers Define -script.on_init(function(event) +script.on_init(function() Server.new_thread{ name='auto-message', timeout=54000, -- 3240000 = 15 hours dont make the mistake i did, 54000 is 15 minutes @@ -54,13 +54,12 @@ script.on_init(function(event) local data = self.data if not data.high_role or not data.low_role or not data.low then self.reopen = false return end - -- idk but this stoped working for no appent reason so i added more checks for nil values if Role and Role.get_highest(player).index <= Role.get(data.low_role).index or player.admin then return end for _,message in pairs(data.low) do player_return({'ExpGamingBot-autoMessage.message',message},nil,player) end end):on_event('error',function(self,err) - if Sync then Sync.emit_embeded{ + if Sync then Sync.emit_embedded{ title='Auto Message Error', color=Color.to_hex(defines.textcolor.bg), description='Auto Message Error - Closed Thread', @@ -72,4 +71,4 @@ script.on_init(function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingBot/autoMessage/softmod.json b/modules/ExpGamingBot/autoMessage/softmod.json index 2f0d9545..769ab362 100644 --- a/modules/ExpGamingBot/autoMessage/softmod.json +++ b/modules/ExpGamingBot/autoMessage/softmod.json @@ -1,20 +1,20 @@ { - "name": "autoMessage", - "version": "4.0.0", - "type": "Submodule", - "description": "Prints a message every 15 minutes to chat.", - "location": "", - "keywords": [ - "Bot", - "Chat", - "Auto Message", - "Message" - ], - "dependencies": { - "ExpGamingCore.Server": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingBot_4.0.0" -} \ No newline at end of file + "name": "ExpGamingBot.autoMessage", + "version": "4.0.0", + "description": "Prints a message every 15 minutes to chat.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Bot", + "Chat", + "Auto Message", + "Message" + ], + "dependencies": { + "ExpGamingCore.Server": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Sync": "?^4.0.0" + }, + "collection": "ExpGamingBot@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingBot/discordAlerts/control.lua b/modules/ExpGamingBot/discordAlerts/control.lua index 1cbeab2a..a7069d21 100644 --- a/modules/ExpGamingBot/discordAlerts/control.lua +++ b/modules/ExpGamingBot/discordAlerts/control.lua @@ -2,12 +2,12 @@ -- @module ExpGamingBot.discordAlerts@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Sync = require('ExpGamingCore.Sync@^4.0.0') -local Color = require('FactorioStdLib.Color@^0.8.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Sync = require('ExpGamingCore.Sync') +local Color = require('FactorioStdLib.Color') +local Game = require('FactorioStdLib.Game') -- Module Define local module_verbose = false @@ -23,7 +23,7 @@ script.on_event(defines.events.on_console_command,function(event) data.by = event.player_index and game.players[event.player_index].name or '' if data.by == '' then return end if command == 'config' or command == 'banlist' then - Sync.emit_embeded{ + Sync.emit_embedded{ title='Edit To '..data.title, color=Color.to_hex(defines.textcolor.bg), description='A player edited the '..command..'.', @@ -48,7 +48,7 @@ script.on_event(defines.events.on_console_command,function(event) if not Game.get_player(data.username) then return end if string.sub(command,-1) == 'e' then data.command = command..'d' else data.command = command..'ed' end data.reason = data.reason and data.reason ~= '' and data.reason or 'No Reason Required' - Sync.emit_embeded{ + Sync.emit_embedded{ title='Player '..data.title, color=data.colour, description='There was a player '..data.command..'.', @@ -60,4 +60,4 @@ script.on_event(defines.events.on_console_command,function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/ExpGamingBot/discordAlerts/softmod.json b/modules/ExpGamingBot/discordAlerts/softmod.json index 6d6e18c7..1bcd1602 100644 --- a/modules/ExpGamingBot/discordAlerts/softmod.json +++ b/modules/ExpGamingBot/discordAlerts/softmod.json @@ -1,20 +1,20 @@ { - "name": "discordAlerts", - "version": "4.0.0", - "type": "Submodule", - "description": "Sends alerts to discord once there is a bot set up to read the alerts.", - "location": "", - "keywords": [ - "Bot", - "Discord", - "Alerts", - "Messages", - "Acctions" - ], - "dependencies": { - "ExpGamingCore.Sync": "^4.0.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingBot_4.0.0" -} \ No newline at end of file + "name": "ExpGamingBot.discordAlerts", + "version": "4.0.0", + "description": "Sends alerts to discord once there is a bot set up to read the alerts.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Bot", + "Discord", + "Alerts", + "Messages", + "Acctions" + ], + "dependencies": { + "ExpGamingCore.Sync": "^4.0.0", + "FactorioStdLib.Color": "^0.8.0", + "FactorioStdLib.Game": "^0.8.0" + }, + "collection": "ExpGamingBot@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingBot/softmod.json b/modules/ExpGamingBot/softmod.json index a2c47877..a7328e25 100644 --- a/modules/ExpGamingBot/softmod.json +++ b/modules/ExpGamingBot/softmod.json @@ -1,78 +1,22 @@ { - "name": "ExpGamingBot", - "version": "4.0.0", - "type": "Collection", - "description": "Different parts of a useful bot to help run a server. Discord Bot Not Included.", - "location": "", - "keywords": [ - "Discord", - "Bot", - "Messages", - "Chat", - "Auto" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "submodules": { - "autoChat": { - "name": "autoChat", - "version": "4.0.0", - "type": "Submodule", - "description": "Sends messages in chat based on what has been said by other players", - "location": "", - "keywords": [ - "Chat", - "Bot", - "Jokes", - "Fun" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingBot_4.0.0" - }, - "autoMessage": { - "name": "autoMessage", - "version": "4.0.0", - "type": "Submodule", - "description": "Prints a message every 15 minutes to chat.", - "location": "", - "keywords": [ - "Bot", - "Chat", - "Auto Message", - "Message" - ], - "dependencies": { - "ExpGamingCore.Server": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0" - }, - "collection": "ExpGamingBot_4.0.0" - }, - "discordAlerts": { - "name": "discordAlerts", - "version": "4.0.0", - "type": "Submodule", - "description": "Sends alerts to discord once there is a bot set up to read the alerts.", - "location": "", - "keywords": [ - "Bot", - "Discord", - "Alerts", - "Messages", - "Acctions" - ], - "dependencies": { - "ExpGamingCore.Sync": "^4.0.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingBot_4.0.0" - } - }, - "dependencies": {} -} \ No newline at end of file + "name": "ExpGamingBot", + "version": "4.0.0", + "description": "Different parts of a useful bot to help run a server. Discord Bot Not Included.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Discord", + "Bot", + "Messages", + "Chat", + "Auto" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "submodules": { + "ExpGamingBot.autoChat": "4.0.0", + "ExpGamingBot.autoMessage": "4.0.0", + "ExpGamingBot.discordAlerts": "4.0.0" + }, + "dependencies": {} +} diff --git a/modules/ExpGamingCommands/bonus/control.lua b/modules/ExpGamingCommands/bonus/control.lua index 452005d9..e772de80 100644 --- a/modules/ExpGamingCommands/bonus/control.lua +++ b/modules/ExpGamingCommands/bonus/control.lua @@ -4,7 +4,7 @@ -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE local global = global{} -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') -- these are the settings which are changed with scale being as +100% local settings = { @@ -37,7 +37,7 @@ script.on_event(defines.events.on_player_respawned,function(event) end end) --- overided by ExpGamingCore.Role if present +-- overridden by ExpGamingCore.Role if present script.on_event(defines.events.on_pre_player_died,function(event) local player = Game.get_player(event) if player.admin then @@ -54,8 +54,8 @@ end) return { on_init= function(self) - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then - local Role = require('ExpGamingCore.Role@^4.0.0') + if loaded_modules['ExpGamingCore.Role'] then + local Role = require('ExpGamingCore.Role') -- instant respawn script.on_event(defines.events.on_pre_player_died,function(event) local player = Game.get_player(event) @@ -74,10 +74,10 @@ return { script.on_event(defines.events.role_change,function(event) local player = Game.get_player(event) if Role.allowed(player,'bonus') then - for _,setting in pairs(settings) do player[key] = setting*0.2 end + for key,setting in pairs(settings) do player[key] = setting*0.2 end global[player.index]=20 else - for _,setting in pairs(settings) do player[key] = 0 end + for key in pairs(settings) do player[key] = 0 end global[player.index]=nil end end) diff --git a/modules/ExpGamingCommands/bonus/softmod.json b/modules/ExpGamingCommands/bonus/softmod.json index 734b3f17..ddb09af9 100644 --- a/modules/ExpGamingCommands/bonus/softmod.json +++ b/modules/ExpGamingCommands/bonus/softmod.json @@ -1,22 +1,22 @@ { - "name": "bonus", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows a bonus to be applied to players and instant respawn.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.bonus_4.0.0.zip", - "keywords": [ - "Instant Respawn", - "Bonus", - "Cheat", - "Commands", - "ExpGaming", - "Respawn" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingLib": "^4.0.0", - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCommands.bonus", + "version": "4.0.0", + "description": "Allows a bonus to be applied to players and instant respawn.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Instant Respawn", + "Bonus", + "Cheat", + "Commands", + "ExpGaming", + "Respawn" + ], + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingLib": "^4.0.0", + "ExpGamingCore.Command": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0" + }, + "collection": "ExpGamingCommands@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCommands/cheatMode/control.lua b/modules/ExpGamingCommands/cheatMode/control.lua index f64037fe..19d05276 100644 --- a/modules/ExpGamingCommands/cheatMode/control.lua +++ b/modules/ExpGamingCommands/cheatMode/control.lua @@ -3,7 +3,7 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE ---- Toogles cheat mode for a player +--- Toggles cheat mode for a player -- @command cheat-mode -- @param[opt] player the player to toggle if nil then the player using the command commands.add_command('cheat-mode', 'Toggles cheat mode for a player', { diff --git a/modules/ExpGamingCommands/cheatMode/softmod.json b/modules/ExpGamingCommands/cheatMode/softmod.json index fb94b029..cc2843f6 100644 --- a/modules/ExpGamingCommands/cheatMode/softmod.json +++ b/modules/ExpGamingCommands/cheatMode/softmod.json @@ -1,19 +1,19 @@ { - "name": "cheatMode", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a command which allow you to toggle cheatmode", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.cheatMode_4.0.0.zip", - "keywords": [ - "Cheat", - "Commands", - "Admin", - "ExpGaming", - "Cheat Mode", - "Hacks" - ], - "dependencies": { - "ExpGamingCore.Command": "^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCommands.cheatMode", + "version": "4.0.0", + "description": "Adds a command which allow you to toggle cheatmode", + "location": "FSM_ARCHIVE", + "keywords": [ + "Cheat", + "Commands", + "Admin", + "ExpGaming", + "Cheat Mode", + "Hacks" + ], + "dependencies": { + "ExpGamingCore.Command": "^4.0.0" + }, + "collection": "ExpGamingCommands@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCommands/home/control.lua b/modules/ExpGamingCommands/home/control.lua index dd79b921..d5c667fb 100644 --- a/modules/ExpGamingCommands/home/control.lua +++ b/modules/ExpGamingCommands/home/control.lua @@ -3,7 +3,7 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') local global = global{} --- Sets the home for a player @@ -25,7 +25,7 @@ commands.add_command('home', 'Allows you to set, remove and goto your homes', { player_return{'ExpGamingCommands-home.set',name,pos[1],pos[2]} elseif command == 'remove' then if not homes[name] then player_return{'ExpGamingCommands-home.invalid',name} end - homes[name] = nil + homes[name] = nil homes._n=homes._n-1 player_return{'ExpGamingCommands-home.remove',name} elseif command == 'goto' then @@ -42,6 +42,6 @@ commands.add_command('home', 'Allows you to set, remove and goto your homes', { else player_return{'ExpGamingCommands-home.homes',homes._n,homes._m} local index = 1 - for name,pos in pairs(homes) do if name ~= '_n' and name ~= '_r' and name ~= '_m' then player_return{'ExpGamingCommands-home.home',index,name,pos[1],pos[2]} index=index+1 end end + for home_name,pos in pairs(homes) do if home_name ~= '_n' and home_name ~= '_r' and home_name ~= '_m' then player_return{'ExpGamingCommands-home.home',index,home_name,pos[1],pos[2]} index=index+1 end end end end) diff --git a/modules/ExpGamingCommands/home/softmod.json b/modules/ExpGamingCommands/home/softmod.json index 9db381c2..72d2c368 100644 --- a/modules/ExpGamingCommands/home/softmod.json +++ b/modules/ExpGamingCommands/home/softmod.json @@ -1,20 +1,20 @@ { - "name": "home", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows players to set homes and then return to them later.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.home_4.0.0.zip", - "keywords": [ - "Teleport", - "ExpGaming", - "Home", - "Return", - "Set Home", - "Commands" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Command": "^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCommands.home", + "version": "4.0.0", + "description": "Allows players to set homes and then return to them later.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Teleport", + "ExpGaming", + "Home", + "Return", + "Set Home", + "Commands" + ], + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Command": "^4.0.0" + }, + "collection": "ExpGamingCommands@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCommands/kill/control.lua b/modules/ExpGamingCommands/kill/control.lua index 37a6df71..b04ef3d8 100644 --- a/modules/ExpGamingCommands/kill/control.lua +++ b/modules/ExpGamingCommands/kill/control.lua @@ -3,7 +3,7 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^4.0.0') +local Game = require('FactorioStdLib.Game') --- Kills a player of a lower rank -- @command kill diff --git a/modules/ExpGamingCommands/kill/softmod.json b/modules/ExpGamingCommands/kill/softmod.json index 68d3d03c..989c03ee 100644 --- a/modules/ExpGamingCommands/kill/softmod.json +++ b/modules/ExpGamingCommands/kill/softmod.json @@ -1,21 +1,21 @@ { - "name": "kill", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a command which can be used to kill a player or yourself.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingAdmin.Commands_4.0.0.zip", - "keywords": [ - "Command", - "ExpGaming", - "Kill", - "Death", - "Admin", - "Tool" - ], - "dependencies": { - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingCommands_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCommands.kill", + "version": "4.0.0", + "description": "Adds a command which can be used to kill a player or yourself.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Command", + "ExpGaming", + "Kill", + "Death", + "Admin", + "Tool" + ], + "dependencies": { + "ExpGamingCore.Command": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0" + }, + "collection": "ExpGamingCommands@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCommands/repair/control.lua b/modules/ExpGamingCommands/repair/control.lua index fb3835fa..be84b7f0 100644 --- a/modules/ExpGamingCommands/repair/control.lua +++ b/modules/ExpGamingCommands/repair/control.lua @@ -4,8 +4,8 @@ -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^0.8.0') -local Role = require('ExpGamingCore.Role@^4.0.0') +local Game = require('FactorioStdLib.Game') +local Role = require('ExpGamingCore.Role') -- Set an item to true to disallow it from being repaired local disallow = { @@ -24,11 +24,11 @@ local repairDisallow local module_verbose = false local ThisModule = { on_init = function(self) - if loaded_modules['ExpGamingAdmin.TempBan@^4.0.0'] then verbose('ExpGamingAdmin.TempBan is installed; Loading tempban src') repairDisallow = require(module_path..'/src/tempban') end + if loaded_modules['ExpGamingAdmin.TempBan'] then verbose('ExpGamingAdmin.TempBan is installed; Loading tempban src') repairDisallow = require(module_path..'/src/tempban') end end } ---- Used so that the value can be overriden if tempban is present +--- Used so that the value can be overridden if tempban is present -- @local -- @function repairDisallow -- @param player the player who called the command @@ -41,7 +41,7 @@ end --- Used to repair and heal items in an area, different ranks get different size areas -- @command repair -- @param range the range that items are repaired in -commands.add_command('repair', 'Repairs all destoryed and damaged entites in an area.', { +commands.add_command('repair', 'Repairs all destroyed and damaged entities in an area.', { ['range']={true,'number-int'} }, function(event,args) local range = args.range diff --git a/modules/ExpGamingCommands/repair/softmod.json b/modules/ExpGamingCommands/repair/softmod.json index 0574acd0..db6cbfab 100644 --- a/modules/ExpGamingCommands/repair/softmod.json +++ b/modules/ExpGamingCommands/repair/softmod.json @@ -1,22 +1,22 @@ { - "name": "repair", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows items to be healed and repaired with a command", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.repair_4.0.0.zip", - "keywords": [ - "ExpGaming", - "Command", - "Heal", - "Repair", - "Ghosts", - "Revive" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "^4.0.0", - "ExpGamingAdmin.TempBan": "?^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCommands.repair", + "version": "4.0.0", + "description": "Allows items to be healed and repaired with a command", + "location": "FSM_ARCHIVE", + "keywords": [ + "ExpGaming", + "Command", + "Heal", + "Repair", + "Ghosts", + "Revive" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Role": "^4.0.0", + "ExpGamingAdmin.TempBan": "?^4.0.0" + }, + "collection": "ExpGamingCommands@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCommands/repair/src/tempban.lua b/modules/ExpGamingCommands/repair/src/tempban.lua index 2212c26f..31c029c2 100644 --- a/modules/ExpGamingCommands/repair/src/tempban.lua +++ b/modules/ExpGamingCommands/repair/src/tempban.lua @@ -1,5 +1,5 @@ -- not_luadoc=true -local temp_ban = require('ExpGamingAdmin.TempBan') +local temp_ban = require('ExpGamingAdmin').temp_ban return function(player,entity) player_return('You have repaired: '..entity.name..' this item is not allowed.',defines.textcolor.crit,player) temp_ban(player,'','Attempt To Repair A Banned Item') diff --git a/modules/ExpGamingCommands/softmod.json b/modules/ExpGamingCommands/softmod.json index bace2538..6cfb5d37 100644 --- a/modules/ExpGamingCommands/softmod.json +++ b/modules/ExpGamingCommands/softmod.json @@ -1,165 +1,25 @@ { - "name": "ExpGamingCommands", - "version": "4.0.0", - "type": "Collection", - "description": "A Collection of all of the custom commands used on ExpGaming servers.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands_4.0.0.zip", - "keywords": [ - "Commands", - "ExpGaming", - "Admin", - "Tools" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "submodules": { - "bonus": { - "name": "bonus", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows a bonus to be applied to players and instant respawn.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.bonus_4.0.0.zip", - "keywords": [ - "Instant Respawn", - "Bonus", - "Cheat", - "Commands", - "ExpGaming", - "Respawn" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingLib": "^4.0.0", - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" - }, - "cheatMode": { - "name": "cheatMode", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a command which allow you to toggle cheatmode", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.cheatMode_4.0.0.zip", - "keywords": [ - "Cheat", - "Commands", - "Admin", - "ExpGaming", - "Cheat Mode", - "Hacks" - ], - "dependencies": { - "ExpGamingCore.Command": "^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" - }, - "home": { - "name": "home", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows players to set homes and then return to them later.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.home_4.0.0.zip", - "keywords": [ - "Teleport", - "ExpGaming", - "Home", - "Return", - "Set Home", - "Commands" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Command": "^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" - }, - "kill": { - "name": "kill", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a command which can be used to kill a player or yourself.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingAdmin.Commands_4.0.0.zip", - "keywords": [ - "Command", - "ExpGaming", - "Kill", - "Death", - "Admin", - "Tool" - ], - "dependencies": { - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingCommands_4.0.0" - }, - "repair": { - "name": "repair", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows items to be healed and repaired with a command", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.repair_4.0.0.zip", - "keywords": [ - "ExpGaming", - "Command", - "Heal", - "Repair", - "Ghosts", - "Revive" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "^4.0.0", - "ExpGamingAdmin.TempBan": "?^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" - }, - "tags": { - "name": "tags", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows tags to be used by users.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.tags_4.0.0.zip", - "keywords": [ - "Tags", - "Custom Tags", - "Commands", - "ExpGaming" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Command": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingCommands_4.0.0" - }, - "teleport": { - "name": "teleport", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a few commands used to teleport players.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.teleport_4.0.0.zip", - "keywords": [ - "Teleport", - "Tp", - "Bring", - "GoTo", - "ExpGaming", - "Command", - "Admin", - "Tools" - ], - "dependencies": { - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingAdmin.Teleport": "^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" - } - }, - "dependencies": {} -} \ No newline at end of file + "name": "ExpGamingCommands", + "version": "4.0.0", + "description": "A Collection of all of the custom commands used on ExpGaming servers.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Commands", + "ExpGaming", + "Admin", + "Tools" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "submodules": { + "ExpGamingCommands.bonus": "4.0.0", + "ExpGamingCommands.cheatMode": "4.0.0", + "ExpGamingCommands.home": "4.0.0", + "ExpGamingCommands.kill": "4.0.0", + "ExpGamingCommands.repair": "4.0.0", + "ExpGamingCommands.tags": "4.0.0", + "ExpGamingCommands.teleport": "4.0.0" + }, + "dependencies": {} +} diff --git a/modules/ExpGamingCommands/tags/control.lua b/modules/ExpGamingCommands/tags/control.lua index bc021e4a..f320144b 100644 --- a/modules/ExpGamingCommands/tags/control.lua +++ b/modules/ExpGamingCommands/tags/control.lua @@ -3,14 +3,14 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') local Role -- ExpGamingCore.Role@^4.0.0 -- Module Define local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end end } diff --git a/modules/ExpGamingCommands/tags/softmod.json b/modules/ExpGamingCommands/tags/softmod.json index 536d87a8..ae4843ee 100644 --- a/modules/ExpGamingCommands/tags/softmod.json +++ b/modules/ExpGamingCommands/tags/softmod.json @@ -1,20 +1,20 @@ { - "name": "tags", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows tags to be used by users.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.tags_4.0.0.zip", - "keywords": [ - "Tags", - "Custom Tags", - "Commands", - "ExpGaming" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Command": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingCommands_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCommands.tags", + "version": "4.0.0", + "description": "Allows tags to be used by users.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Tags", + "Custom Tags", + "Commands", + "ExpGaming" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Command": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0" + }, + "collection": "ExpGamingCommands@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCommands/teleport/control.lua b/modules/ExpGamingCommands/teleport/control.lua index b2abdf47..d66f7e1b 100644 --- a/modules/ExpGamingCommands/teleport/control.lua +++ b/modules/ExpGamingCommands/teleport/control.lua @@ -3,7 +3,7 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') +local Admin = require('ExpGamingAdmin') --- Teleports the user to the player given -- @command go-to diff --git a/modules/ExpGamingCommands/teleport/softmod.json b/modules/ExpGamingCommands/teleport/softmod.json index 65aeb936..4420b19c 100644 --- a/modules/ExpGamingCommands/teleport/softmod.json +++ b/modules/ExpGamingCommands/teleport/softmod.json @@ -1,22 +1,23 @@ { - "name": "teleport", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a few commands used to teleport players.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCommands.teleport_4.0.0.zip", - "keywords": [ - "Teleport", - "Tp", - "Bring", - "GoTo", - "ExpGaming", - "Command", - "Admin", - "Tools" - ], - "dependencies": { - "ExpGamingCore.Command": "^4.0.0", - "ExpGamingAdmin.Teleport": "^4.0.0" - }, - "collection": "ExpGamingCommands_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCommands.teleport", + "version": "4.0.0", + "description": "Adds a few commands used to teleport players.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Teleport", + "Tp", + "Bring", + "GoTo", + "ExpGaming", + "Command", + "Admin", + "Tools" + ], + "dependencies": { + "ExpGamingCore.Command": "^4.0.0", + "ExpGamingAdmin.Teleport": "^4.0.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingCommands@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCore/Command/control.lua b/modules/ExpGamingCore/Command/control.lua index 8a5d1902..70b23fed 100644 --- a/modules/ExpGamingCore/Command/control.lua +++ b/modules/ExpGamingCore/Command/control.lua @@ -4,8 +4,8 @@ -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -- @alias commands -local Game = require('FactorioStdLib.Game@^0.8.0') -local Color = require('FactorioStdLib.Color@^0.8.0') +local Game = require('FactorioStdLib.Game') +local Color = require('FactorioStdLib.Color') --- Used as an error constant for validation -- @field commands.error @@ -13,7 +13,7 @@ local Color = require('FactorioStdLib.Color@^0.8.0') -- @usage return commands.error('err message') commands.error = setmetatable({},{__call=function(...) return ... end}) commands._add_command = commands.add_command -local data = {} +local commandDataStore = {} local middleware = {} --- Used to add middle ware to the command handler, functions should return true or false @@ -27,10 +27,10 @@ function commands.add_middleware(callback) if not is_type(callback,'function') t -- @tparam ?string|table|event key the command that will be returned: string is the name, table is the command data, event is event from add_command -- @treturn table the command data setmetatable(commands,{ - __index=function(tbl,key) return is_type(key,'table') and (key.command and rawget(data,key.name) or key) or key == 'data' and data or rawget(data,key) end + __index=function(tbl,key) return is_type(key,'table') and (key.command and rawget(commandDataStore,key.name) or key) or key == 'data' and commandDataStore or rawget(commandDataStore,key) end }) ---- Collection of funcations that can be used to validate inputs +--- Collection of functions that can be used to validate inputs -- @table commands.validate -- @usage commands.validate[type](value,event,...) -- @tparam string type the type that the value should be @@ -40,11 +40,11 @@ setmetatable(commands,{ -- @return[2] error constant -- @return[2] the err message -- @field __comment replace _ with - the ldoc did not like me using - in the names --- @field string basicly does nothing but a type filed is required --- @field string_inf same as string but is infite in length, must be last arg --- @field string_len same as string but can define a max lengh +-- @field string basically does nothing but a type filed is required +-- @field string_inf same as string but is infinite in length, must be last arg +-- @field string_len same as string but can define a max length -- @field number converts the input into a number --- @field number_int conerts the input to a number and floors it +-- @field number_int converts the input to a number and floors it -- @field number_range allows a number in a range min < X <= max -- @field number_range allows a number in a range after it has been floored min < math.floor(X) <= max -- @field player converts the input into a valid player @@ -54,54 +54,54 @@ setmetatable(commands,{ -- @field player_role-online converts the input to a player if the player is a lower rank than the user and online -- @field player_role_alive converts the input to a player if the player is a lower rank than the user and online and alive commands.validate = { - ['boolean']=function(value,event) local value = value.lower() if value == 'true' or valule == 'yes' or value == 'y' or value == '1' then return true else return false end end, - ['string']=function(value,event) return tostring(value) end, - ['string-inf']=function(value,event) return tostring(value) end, - ['string-list']=function(value,event,list) + ['boolean']=function(value) value = value.lower() if value == 'true' or value == 'yes' or value == 'y' or value == '1' then return true else return false end end, + ['string']=function(value) return tostring(value) end, + ['string-inf']=function(value) return tostring(value) end, + ['string-list']=function(value,event,list) local rtn = tostring(value) and table.includes(list,tostring(value)) and tostring(value) or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-string-list',table.concat(list,', ')} end return rtn end, - ['string-len']=function(value,event,max) + ['string-len']=function(value,event,max) local rtn = tostring(value) and tostring(value):len() <= max and tostring(value) or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-string-len',max} end return rtn end, - ['number']=function(value,event) - local rtn = tonumber(value) or nil + ['number']=function(value) + local rtn = tonumber(value) or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-number'} end return rtn end, - ['number-int']=function(value,event) - local rtn = tonumber(value) and math.floor(tonumber(value)) or nil + ['number-int']=function(value) + local rtn = tonumber(value) and math.floor(tonumber(value)) or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-number'} end return rtn end, - ['number-range']=function(value,event,min,max) + ['number-range']=function(value,event,min,max) local rtn = tonumber(value) and tonumber(value) > min and tonumber(value) <= max and tonumber(value) or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-number-range',min,max} end return rtn end, - ['number-range-int']=function(value,event,min,max) + ['number-range-int']=function(value,event,min,max) local rtn = tonumber(value) and math.floor(tonumber(value)) > min and math.floor(tonumber(value)) <= max and math.floor(tonumber(value)) or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-number-range',min,max} end return rtn end, - ['player']=function(value,event) + ['player']=function(value) local rtn = Game.get_player(value) or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-player',value} end return rtn end, - ['player-online']=function(value,event) - local player,err = commands.validate['player'](value) + ['player-online']=function(value) + local player,err = commands.validate['player'](value) if err then return commands.error(err) end local rtn = player.connected and player or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-player-online'} end return rtn end, - ['player-alive']=function(value,event) - local player,err = commands.validate['player-online'](value) + ['player-alive']=function(value) + local player,err = commands.validate['player-online'](value) if err then return commands.error(err) end local rtn = player.character and player.character.health > 0 and player or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-player-alive'} end return rtn end, - ['player-rank']=function(value,event) - local player,err = commands.validate['player'](value) - if err then return commands.error(err) end + ['player-rank']=function(value,event) + local player,err = commands.validate['player'](value) + if err then return commands.error(err) end local rtn = player.admin and Game.get_player(event).admin and player or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-player-rank'} end return rtn end, - ['player-rank-online']=function(value,event) - local player,err = commands.validate['player-online'](value) - if err then return commands.error(err) end - local player,err = commands.validate['player-rank'](player) + ['player-rank-online']=function(value) + local player,err = commands.validate['player-online'](value) + if err then return commands.error(err) end + local player,err = commands.validate['player-rank'](player) if err then return commands.error(err) end return player end, - ['player-rank-alive']=function(value,event) - local player,err = commands.validate['player-alive'](value) - if err then return commands.error(err) end - local player,err = commands.validate['player-rank'](player) + ['player-rank-alive']=function(value) + local player,err = commands.validate['player-alive'](value) + if err then return commands.error(err) end + local player,err = commands.validate['player-rank'](player) if err then return commands.error(err) end return player end, } --- Adds a function to the validation list @@ -114,7 +114,7 @@ function commands.add_validation(name,callback) if not is_type(callback,'functio -- @tparam ?string|table|event command the command to get the inputs of -- @treturn string the formated string for the inputs function commands.format_inputs(command) - local command = commands[command] + command = commands[command] if not is_type(command,'table') then error('Command is not valid',2) end local rtn = '' for name,data in pairs(command.inputs) do @@ -136,13 +136,13 @@ function commands.validate_args(event) local rtn = {} local count = 0 local count_opt = 0 - for name,data in pairs(command.inputs) do count = count + 1 if data[1] == false then count_opt = count_opt + 1 end end - -- checks that there is some args given if there is ment to be + for _,data in pairs(command.inputs) do count = count + 1 if data[1] == false then count_opt = count_opt + 1 end end + -- checks that there is some args given if there is meant to be if not event.parameter then if count == count_opt then return rtn else return commands.error('invalid-inputs') end end - -- splits the args into words so that it can be used to asign values + -- splits the args into words so that it can be used to assign values local words = string.split(event.parameter,' ') local index = 0 for _,word in pairs(words) do @@ -158,13 +158,13 @@ function commands.validate_args(event) end end -- assigns the values from the words to the args - local index = 0 + index = 0 for name,data in pairs(command.inputs) do index = index+1 local arg = words[index] if not arg and data[1] then return commands.error('invalid-inputs') end if data[2] == 'string-inf' then rtn[name] = table.concat(words,' ',index) break end - local valid = is_type(data[2],'function') and data[2] or commands.validate[data[2]] or error('Invalid type for command: "'..command.name..'/'..name..'"') + local valid = is_type(data[2],'function') and data[2] or commands.validate[data[2]] or error('Invalid validation ("'..tostring(data[2])..'") for command: "'..command.name..'/'..name..'"') local temp_tbl = table.deepcopy(data) table.remove(temp_tbl,1) table.remove(temp_tbl,1) local value, err = valid(arg,event,unpack(temp_tbl)) if value == commands.error then return value, err end @@ -178,10 +178,10 @@ end -- @tparam ?index|name|player| player the player to test as -- @treturn table a table containg all the commands the player can use function commands.get_commands(player) + player = Game.get_player(player) local commands = {} - local player = Game.get_player(player) if not player then return error('Invalid player',2) end - for name,data in pairs(data) do + for name,data in pairs(commandDataStore) do if #middleware > 0 then for _,callback in pairs(middleware) do local success, err = pcall(callback,player,name,data) if not success then error(err) @@ -207,7 +207,7 @@ end local function run_custom_command(command) local data = commands.data[command.name] local player = Game.get_player(command) or SERVER - -- runs all middle ware if any, if there is no middle where then it relyis on .default_admin_only + -- runs all middle ware if any, if there is no middle where then it relies on .default_admin_only if #middleware > 0 then for _,callback in pairs(middleware) do local success, err = pcall(callback,player,command.name,command) if not success then error(err) @@ -243,7 +243,7 @@ end -- @usage --see examples in file -- @tparam string name the name of the command -- @tparam[opt='No Description'] string description the description of the command --- @tparam[opt=an infite string] table inputs a table of the inputs to be used, last index being true makes the last parameter open ended (longer than one word) +-- @tparam[opt=an infinite string] table inputs a table of the inputs to be used, last index being true makes the last parameter open ended (longer than one word) -- @tparam function callback the function to call on the event commands.add_command = function(name, description, inputs, callback) if commands[name] then error('That command is already registered',2) end @@ -254,11 +254,11 @@ commands.add_command = function(name, description, inputs, callback) end verbose('Created Command: '..name) -- test for string and then test for locale string - local description = is_type(description,'string') and description + description = is_type(description,'string') and description or is_type(description,'table') and is_type(description[1],'string') and string.find(description[1],'.+[.].+') and {description,''} or 'No Description' - local inputs = is_type(inputs,'table') and inputs or {['param']={false,'string-inf'}} - data[name] = { + inputs = is_type(inputs,'table') and inputs or {['param']={false,'string-inf'}} + commandDataStore[name] = { name=name, description=description, inputs=inputs, @@ -268,12 +268,12 @@ commands.add_command = function(name, description, inputs, callback) local help = is_type(description,'string') and commands.format_inputs(name)..'- '..description or is_type(description,'table') and is_type(description[1],'string') and string.find(description[1],'.+[.].+') and {description,commands.format_inputs(name)..'- '} or commands.format_inputs(name) - data[name].help = help + commandDataStore[name].help = help commands._add_command(name,help,function(...) local success, err = Manager.sandbox(run_custom_command,{},...) if not success then error(err) end end) - return data[name] + return commandDataStore[name] end return commands @@ -289,8 +289,8 @@ return commands commands.add_command('foo',{'foo.description'},{ ['player']={true,'player'}, -- a required arg that must be a valid player ['number']={true,'number-range',0,10}, -- a required arg that must be a number 0", - "keywords": [ - "Groups", - "ExpGaming", - "System", - "Management", - "Manage", - "Permissions" - ], - "dependencies": { - "FactorioStdLib": "^0.8.0", - "ExpGamingCore.Server": "?^4.0.0", - "ExpGamingLib": "^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCore.Group", + "version": "4.0.0", + "description": "Adds a system to manage and auto-create permission groups.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Groups", + "ExpGaming", + "System", + "Management", + "Manage", + "Permissions" + ], + "dependencies": { + "FactorioStdLib": "^0.8.0", + "ExpGamingCore.Server": "?^4.0.0", + "ExpGamingLib": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0" + }, + "collection": "ExpGamingCore@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCore/Gui/src/center.lua b/modules/ExpGamingCore/Gui/center/control.lua similarity index 64% rename from modules/ExpGamingCore/Gui/src/center.lua rename to modules/ExpGamingCore/Gui/center/control.lua index e51c35ea..eb3b8da0 100644 --- a/modules/ExpGamingCore/Gui/src/center.lua +++ b/modules/ExpGamingCore/Gui/center/control.lua @@ -1,16 +1,13 @@ --- Adds a uniform preset for guis in the center of the screen which allow for different tabs to be opened --- @module ExpGamingCore.Gui.Center +-- @module ExpGamingCore.Gui.center -- @alias center -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE ---- This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module --- @function _comment - local Game = require('FactorioStdLib.Game') local Color = require('FactorioStdLib.Color') -local mod_gui = require("mod-gui") -local Gui = Gui -- this is to force gui to remain in the ENV +local Gui = require('ExpGamingCore.Gui') +local mod_gui = require('mod-gui') local center = {} center._prototype = {} @@ -18,98 +15,103 @@ center._prototype = {} --- Adds a new obj to the center gui -- @usage Gui.center.add{name='foo',caption='Foo',tooltip='Testing',draw=function} -- @usage return_value(player) -- opens the center gui for that player --- @param obj contains the new object, needs name, fraw is opt and is function(root_frame) +-- @param obj contains the new object, needs name, frame is opt and is function(root_frame) -- @return the object made, used to add tabs, calling the returned value will open the center for the given player function center.add(obj) - if not is_type(obj,'table') then return end - if not is_type(obj.name,'string') then return end + if not is_type(obj,'table') then return end + if not is_type(obj.name,'string') then return end verbose('Created Center Gui: '..obj.name) - setmetatable(obj,{__index=center._prototype,__call=function(self,player) return center.open(player,self.name) end}) + setmetatable(obj,{__index=center._prototype,__call=function(self,player,...) return center.open(player,self.name,...) end}) obj.tabs = {} obj._tabs = {} Gui.data('center',obj.name,obj) - Gui.toolbar(obj.name,obj.caption,obj.tooltip,obj.open) + if Gui.toolbar then Gui.toolbar(obj.name,obj.caption,obj.tooltip,function(event) return obj:open(event.player_index) end) end return obj end --- Used to get the center frame of the player, used mainly in script --- @usage Gui.center.get_flow(player) -- returns gui emelemt --- @param player a player indifier to get the flow for +-- @usage Gui.center.get_flow(player) -- returns gui element +-- @param player a player identifier to get the flow for -- @treturn table the gui element flow function center.get_flow(player) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then error('Invalid player',2) end return player.gui.center.exp_center or player.gui.center.add{name='exp_center',type='flow'} end ---- Used to open a center frame for a player +--- Used to open a center frame for a player, extra params are sent to open event -- @usage Gui.center.open(player,'server-info') -- return true --- @param player a player indifier to get the flow for --- @tparam string center the name of the center frame to open --- @treturn boelon based on if it successed or not -function center.open(player,center) - local player = Game.get_player(player) +-- @param player a player identifier to get the flow for +-- @tparam string center_name the name of the center frame to open +-- @treturn boolean based on if it succeeded or not +function center.open(player,center_name,...) + player = Game.get_player(player) if not player then error('Invalid player',2) return false end Gui.center.clear(player) - if not Gui.data.center[center] then return false end - Gui.data.center[center].open{ - element={name=center}, - player_index=player.index - } + if not Gui.data.center[center_name] then return false end + local self = Gui.data.center[center_name] + -- this function is the draw function passed to the open event + self:open(player,function(...) Gui.center._draw(self,...) end,...) return true end +-- used as a piece of middle ware for the open event +function center._draw(self,frame,...) + game.players[frame.player_index].opened=frame + if is_type(self.draw,'function') then + local success, err = pcall(self.draw,self,frame,...) + if not success then error(err) end + else error('No Callback on center frame '..self.name) end +end + --- Used to open a center frame for a player -- @usage Gui.center.open_tab(player,'readme','rules') -- return true --- @param player a player indifier to get the flow for +-- @param player a player identifier to get the flow for -- @tparam string center the name of the center frame to open -- @tparam string tab the name of the tab to open --- @treturn boelon based on if it successed or not -function center.open_tab(player,center,tab) - local player = Game.get_player(player) +-- @treturn boolean based on if it succeeded or not +function center.open_tab(player,center_name,tab) + player = Game.get_player(player) if not player then error('Invalid player',2) end - if not Gui.center.open(player,center) then return false end - local name = center..'_'..tab + if not Gui.center.open(player,center_name) then return false end + local name = center_name..'_'..tab if not Gui.data.inputs_button[name] then return false end Gui.data.inputs_button[name].events[defines.events.on_gui_click]{ - element=Gui.center.get_flow(player)[center].tab_bar.tab_bar_scroll.tab_bar_scroll_flow[name], + element=Gui.center.get_flow(player)[center_name].tab_bar.tab_bar_scroll.tab_bar_scroll_flow[name], } return true end --- Used to clear the center frame of the player, used mainly in script -- @usage Gui.center.clear(player) --- @param player a player indifier to get the flow for +-- @param player a player identifier to get the flow for function center.clear(player) - local player = Game.get_player(player) + player = Game.get_player(player) center.get_flow(player).clear() end --- used on the button press when the toolbar button is press, can be overriden --- not recomented for direct use see Gui.center.open -function center._prototype.open(event) - local player = Game.get_player(event) - local _center = Gui.data.center[event.element.name] +-- opens this gui for this player, draw is the draw function when event is called from center.open +-- this is the default function it can be overridden when the gui is defined, simply call draw on the frame you create +-- extra values passed to draw will also be passed to the draw event +-- extra values from center.draw and passed to the open event +function center._prototype:open(player,draw,...) + player = Game.get_player(player) + draw = draw or function(...) center._draw(self,...) end local center_flow = center.get_flow(player) - if center_flow[_center.name] then Gui.center.clear(player) return end + if center_flow[self.name] then Gui.center.clear(player) return end local center_frame = center_flow.add{ - name=_center.name, + name=self.name, type='frame', - caption=_center.caption, + caption=self.caption, direction='vertical', style=mod_gui.frame_style } if is_type(center_frame.caption,'string') and player.gui.is_valid_sprite_path(center_frame.caption) then center_frame.caption = '' end - if is_type(_center.draw,'function') then - local success, err = pcall(_center.draw,_center,center_frame) - if not success then error(err) end - else error('No Callback on center frame '.._center.name) - end - player.opened=center_frame + draw(center_frame,...) end --- this is the default draw function if one is not provided, can be overriden --- not recomented for direct use see Gui.center.open +-- this is the default draw function if one is not provided, can be overridden +-- not recommended for direct use see Gui.center.open function center._prototype:draw(frame) Gui.bar(frame,510) local tab_bar = frame.add{ @@ -121,8 +123,8 @@ function center._prototype:draw(frame) tab_bar.style.width = 510 tab_bar.style.height = 65 local tab_bar_scroll = tab_bar.add{ - type='scroll-pane', - name='tab_bar_scroll', + type='scroll-pane', + name='tab_bar_scroll', horizontal_scroll_policy='auto-and-reserve-space', vertical_scroll_policy='never' } @@ -145,7 +147,7 @@ function center._prototype:draw(frame) tab.style.height = 305 local tab_scroll = tab.add{ type ='scroll-pane', - name='tab_scroll', + name='tab_scroll', horizontal_scroll_policy='never', vertical_scroll_policy='auto' } @@ -153,8 +155,8 @@ function center._prototype:draw(frame) tab_scroll.style.vertically_stretchable = true tab_scroll.style.width = 500 local tab_scroll_flow = tab_scroll.add{ - type='flow', - name='tab_scroll_flow', + type='flow', + name='tab_scroll_flow', direction='vertical' } tab_scroll_flow.style.width = 480 @@ -169,7 +171,7 @@ function center._prototype:draw(frame) frame.parent.add{type='frame',name='temp'}.destroy()--recenter the GUI end ---- If deafult draw is used then you can add tabs to the gui with this function +--- If default draw is used then you can add tabs to the gui with this function -- @usage _center:add_tab('foo','Foo','Just a tab',function) -- @tparam string name this is the name of the tab -- @tparam string caption this is the words that appear on the tab button @@ -206,10 +208,14 @@ function center._prototype:add_tab(name,caption,tooltip,callback) end -- used so that when gui close key is pressed this will close the gui -center._events = {[defines.events.on_gui_closed]=function(event) +script.on_event(defines.events.on_gui_closed,function(event) if event.element and event.element.valid then event.element.destroy() end -end} +end) -center.on_role_change = center.clear +script.on_event(defines.events.on_player_respawned,center.clear) + +function center.on_init() + if loaded_modules['ExpGamingCore.Role'] then script.on_event(defines.events.on_role_change,center.clear) end +end -- calling will attempt to add a new gui return setmetatable(center,{__call=function(self,...) return self.add(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingCore/Gui/center/softmod.json b/modules/ExpGamingCore/Gui/center/softmod.json new file mode 100644 index 00000000..7d1dda86 --- /dev/null +++ b/modules/ExpGamingCore/Gui/center/softmod.json @@ -0,0 +1,24 @@ +{ + "name": "ExpGamingCore.Gui.center", + "version": "4.0.0", + "description": "Adds a pre-made center gui format.", + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Center" + ], + "collection": "ExpGamingCore.Gui@4.0.0", + "dependencies": { + "mod-gui": "*", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "^0.8.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Gui.inputs": "^4.0.0", + "ExpGamingCore.Gui.toolbar": "?^4.0.0" + }, + "submodules": {} +} diff --git a/modules/ExpGamingCore/Gui/control.lua b/modules/ExpGamingCore/Gui/control.lua index 9c20d668..0877c322 100644 --- a/modules/ExpGamingCore/Gui/control.lua +++ b/modules/ExpGamingCore/Gui/control.lua @@ -16,7 +16,7 @@ local global = global() -- @tparam string location the location to get/set the data, center left etc... -- @tparam[opt] string key the name of the gui to set the value of -- @param[opt] value the data that will be set can be any value but table advised --- @treturn[1] table all the gui data that is locationed in that location +-- @treturn[1] table all the gui data that is located in that location Gui.data = setmetatable({},{ __call=function(tbl,location,key,value) if not location then return tbl end @@ -27,28 +27,11 @@ Gui.data = setmetatable({},{ end }) -local events = {} -local order_config = require(module_path..'/order_config') - -Gui.center = require(module_path..'/src/center',{Gui=Gui}) -table.merge(events,Gui.center._events) -Gui.center._events = nil - -Gui.inputs = require(module_path..'/src/inputs',{Gui=Gui}) -table.merge(events,Gui.inputs._events) -Gui.inputs._events = nil - -Gui.left = require(module_path..'/src/left',{Gui=Gui,order_config=order_config,self_global=global}) -Gui.popup = require(module_path..'/src/popup',{Gui=Gui}) -Gui.toolbar = require(module_path..'/src/toolbar',{Gui=Gui,order_config=order_config}) - -for event,callback in pairs(events) do script.on_event(event,callback) end - --- Add a white bar to any gui frame -- @usage Gui.bar(frame,100) -- @param frame the frame to draw the line to -- @param[opt=10] width the width of the bar --- @return the line that was made type is progressbar +-- @return the line that was made type is progress bar function Gui.bar(frame,width) local line = frame.add{ type='progressbar', @@ -61,11 +44,11 @@ function Gui.bar(frame,width) return line end ---- Adds a lable that is centered --- @usage Gui.centered_label(frane, 'Hello, world!') +--- Adds a label that is centered +-- @usage Gui.centered_label(frame, 'Hello, world!') -- @tparam LuaGuiElement frame the parent frame to add the label to --- @tparam string string the string that the lable will have -function Gui.centered_label(frane, string) +-- @tparam string string the string that the label will have +function Gui.centered_label(frame, string) local flow = frame.add {frame = 'flow'} local flow_style = flow.style flow_style.align = 'center' @@ -79,13 +62,13 @@ function Gui.centered_label(frane, string) return label end ---- Used to set the index of a drop down to a certian item +--- Used to set the index of a drop down to a certain item -- @usage Gui.set_dropdown_index(dropdown,player.name) -- will select the index with the players name as the value -- @param dropdown the dropdown that is to be effected -- @param _item this is the item to look for -- @return returns the dropdown if it was successful function Gui.set_dropdown_index(dropdown,_item) - if dropdown and dropdown.valid and dropdown.items and _item then else return end + if not dropdown or not dropdown.valid or not dropdown.items or not _item then return end local _index = 1 for index, item in pairs(dropdown.items) do if item == _item then _index = index break end @@ -105,7 +88,7 @@ end -- @field surface this will over ride the surface that the camera follows on, allowing for a 'ghost surface' while keeping same position -- @field respawn_open if set to true then the camera will auto re link to the player after a respawn ---- Adds a camera that updates every tick (or less depeading on how many are opening) it will move to follow an entity +--- Adds a camera that updates every tick (or less depending on how many are opening) it will move to follow an entity -- @usage Gui.cam_link{entity=game.player.character,frame=frame,width=50,hight=50,zoom=1} -- @usage Gui.cam_link{entity=game.player.character,cam=frame.camera,surface=game.surfaces['testing']} -- @tparam table data contains all other params given below @@ -120,7 +103,7 @@ function Gui.cam_link(data) data.cam.name='camera' data.cam.position= data.entity.position data.cam.surface_index= data.surface and data.surface.index or data.entity.surface.index - data.cam.zomm = data.zoom + data.cam.zoom = data.zoom data.cam = data.frame.add(data.cam) data.cam.style.width = data.width or 100 data.cam.style.height = data.height or 100 @@ -158,17 +141,13 @@ function Gui.cam_link(data) end script.on_event('on_tick', function(event) - if Gui.left and ((event.tick+10)/(3600*game.speed)) % 15 == 0 then - Gui.left.update() - end if loaded_modules['ExpGamingCore.Server'] then return end - if global.cams and is_type(global.cams,'table') and #global.cams > 0 then local update = 4 if global.cam_index >= #global.cams then global.cam_index = 1 end if update > #global.cams then update = #global.cams end for cam_offset = 0,update do - local _cam = global.cams[global.cam_index] + local _cam = global.cams[global.cam_index+cam_offset] if not _cam then break end if not _cam.cam.valid then table.remove(global.cams,global.cam_index) elseif not _cam.entity.valid then table.remove(global.cams,global.cam_index) @@ -180,10 +159,10 @@ script.on_event('on_tick', function(event) end) script.on_event('on_player_respawned',function(event) - if Gui.center then Gui.center.clear() end if loaded_modules['ExpGamingCore.Server'] then return end if global.players and is_type(global.players,'table') and #global.players > 0 and global.players[event.player_index] then local remove = {} + local player = Game.get_player(event) for index,cam in pairs(global.players[event.player_index]) do if cam.valid then table.insert(global.cams,{cam=cam,entity=player.character,surface=player.surface}) else table.insert(remove,index) end @@ -195,26 +174,15 @@ script.on_event('on_player_respawned',function(event) end) function Gui:on_init() - self.left:on_init(); self.left.on_init = nil - self.toolbar:on_init(); self.toolbar.on_init = nil - if loaded_modules['ExpGamingCore.Server@^4.0.0'] then Server = require('ExpGamingCore.Server@^4.0.0') verbose('ExpGamingCore.Server is installed; Loading server src') script.on_init(require(module_path..'/src/server',{Gui=self})) end - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then - verbose('ExpGamingCore.Role is installed; Loading ranking src') - script.on_event('on_role_change',function(event) - self.toolbar.on_role_change(event) - self.center.on_role_change(event) - end) + if loaded_modules['ExpGamingCore.Server'] then + Server = require('ExpGamingCore.Server') + verbose('ExpGamingCore.Server is installed; Loading server src') + script.on_init(require(module_path..'/src/server',{Gui=self})) end - script.on_event('on_player_joined_game',function(event) - self.toolbar.on_player_joined_game(event) - self.popup.on_player_joined_game(event) - self.left.on_player_joined_game(event) - end) end -function Gui:on_post() +function Gui.on_post() Gui.test = require(module_path..'/src/test',{Gui=Gui}) - Gui.popup.load() Gui.popup.load = nil end diff --git a/modules/ExpGamingCore/Gui/src/inputs.lua b/modules/ExpGamingCore/Gui/inputs/control.lua similarity index 82% rename from modules/ExpGamingCore/Gui/src/inputs.lua rename to modules/ExpGamingCore/Gui/inputs/control.lua index cbd7d404..54abfe48 100644 --- a/modules/ExpGamingCore/Gui/src/inputs.lua +++ b/modules/ExpGamingCore/Gui/inputs/control.lua @@ -9,14 +9,14 @@ local Game = require('FactorioStdLib.Game') local Color = require('FactorioStdLib.Color') -local mod_gui = require("mod-gui") -local Gui = Gui -- this is to force gui to remain in the ENV +local mod_gui = require('mod-gui') +local Gui = require('ExpGamingCore.Gui') local inputs = {} inputs._prototype = {} -- these are just so you can have short cuts to this inputs.events = { - error='error', + --error={}, -- this is added after event calls are added as it is not a script event state=defines.events.on_gui_checked_state_changed, click=defines.events.on_gui_click, elem=defines.events.on_gui_elem_changed, @@ -33,7 +33,7 @@ inputs.events = { function inputs._prototype:on_event(event,callback) if not is_type(callback,'function') then return self end if inputs.events[event] then event = inputs.events[event] end - if event == 'error' then self._error = callback return self end + if event == inputs.events.error then self._error = callback return self end self.events[event] = callback return self end @@ -78,8 +78,8 @@ function inputs._prototype:draw(root) local success, err = pcall(self.data._items,player,root) if success then data.items = err else error(err) end if is_type(self.data._index,'function') then - local success, err = pcall(self.data._index,player,root) - if success then data.selected_index = err else error(err) end + local _success, _err = pcall(self.data._index,player,root) + if _success then data.selected_index = _err else error(_err) end end return root.add(data) else @@ -87,25 +87,25 @@ function inputs._prototype:draw(root) end end ---- Add a new input, this is the same as doing frame.add{} but returns a diffrent object +--- Add a new input, this is the same as doing frame.add{} but returns a different object -- @usage Gui.inputs.add{type='button',name='test',caption='Test'} -- @usage return_value(frame) -- draws the button onto that frame -- @tparam table obj the new element to add if caption is a sprite path then sprite is used --- @treturn table the custom input object, calling the returned calue will draw the button +-- @treturn table the custom input object, calling the returned value will draw the button function inputs.add(obj) if not is_type(obj,'table') then return end if not is_type(obj.type,'string') then return end local type = obj.type - if type == 'button' or - type == 'sprite-button' or - type == 'choose-elem-button' or - type == 'checkbox' or - type == 'radiobutton' or - type == 'textfield' or - type == 'text-box' or - type == 'slider' or - type == 'drop-down' - then else return end + if type ~= 'button' + and type ~= 'sprite-button' + and type ~= 'choose-elem-button' + and type ~= 'checkbox' + and type ~= 'radiobutton' + and type ~= 'textfield' + and type ~= 'text-box' + and type ~= 'slider' + and type ~= 'drop-down' + then return end verbose('Created Input: '..obj.name..' ('..obj.type..')') if obj.type == 'button' or obj.type == 'sprite-button' then obj.style = mod_gui.button_style end obj.draw_data = table.deepcopy(obj) @@ -136,33 +136,26 @@ function inputs._event_handler(event) end end -inputs._events = { - [inputs.events.state]=inputs._event_handler, - [inputs.events.click]=inputs._event_handler, - [inputs.events.elem]=inputs._event_handler, - [inputs.events.state]=inputs._event_handler, - [inputs.events.text]=inputs._event_handler, - [inputs.events.slider]=inputs._event_handler, - [inputs.events.selection]=inputs._event_handler -} +script.on_event(inputs.events,inputs._event_handler) +inputs.events.error = {} --- the folwing functions are just to make inputs easier but if what you want is not include use inputs.add(obj) +-- the following functions are just to make inputs easier but if what you want is not include use inputs.add(obj) --- Used to define a button, can have many function -- @usage Gui.inputs.add_button('test','Test','Just for testing',{{condition,callback},...}) -- @tparam string name the name of this button -- @tparam string the display for this button, either text or sprite path -- @tparam string tooltip the tooltip to show on the button --- @param callbacks can either be a single function or a list of function pairs see exaplmes at bottom +-- @param callbacks can either be a single function or a list of function pairs see examples at bottom -- @treturn table the button object that was made, to allow a custom error event if wanted function inputs.add_button(name,display,tooltip,callbacks) - local button = inputs.add{ + local rtn_button = inputs.add{ type='button', name=name, caption=display, tooltip=tooltip } - button.data._callbacks = callbacks - button:on_event('click',function(event) + rtn_button.data._callbacks = callbacks + rtn_button:on_event('click',function(event) local elements = Gui.data['inputs_'..event.element.type] or {} local button = elements[event.element.name] if not button and event.element.type == 'sprite-button' then @@ -173,19 +166,19 @@ function inputs.add_button(name,display,tooltip,callbacks) local mouse = event.button local keys = {alt=event.alt,ctrl=event.control,shift=event.shift} local element = event.element - local callbacks = button.data._callbacks - if is_type(callbacks,'function') then callbacks = {{function(...) return true end,callbacks}} end - for _,data in pairs(callbacks) do + local btn_callbacks = button.data._callbacks + if is_type(btn_callbacks,'function') then btn_callbacks = {{function() return true end,btn_callbacks}} end + for _,data in pairs(btn_callbacks) do if is_type(data[1],'function') and is_type(data[2],'function') then local success, err = pcall(data[1],player,mouse,keys,event) if success and err == true then - local success, err = pcall(data[2],player,element,event) - if not success then error(err) end + local _success, _err = pcall(data[2],player,element,event) + if not _success then error(_err) end elseif not success then error(err) end else error('Invalid Callback Condition Format') end - end + end end) - return button + return rtn_button end --- Used to define a choose-elem-button callback only on elem_changed @@ -228,20 +221,19 @@ end function inputs.add_checkbox(name,radio,display,default,callback_true,callback_false) local type = 'checkbox'; if radio then type='radiobutton' end local state = false; if is_type(default,'boolean') then state = default end - local checkbox = inputs.add{ + local rtn_checkbox = inputs.add{ type=type, name=name, caption=display, state=state } - if is_type(default,'function') then checkbox.data._state = default end - checkbox.data._true = callback_true - checkbox.data._false = callback_false - checkbox:on_event('state',function(event) + if is_type(default,'function') then rtn_checkbox.data._state = default end + rtn_checkbox.data._true = callback_true + rtn_checkbox.data._false = callback_false + rtn_checkbox:on_event('state',function(event) local checkbox = Gui.data['inputs_'..event.element.type][event.element.name] local player = Game.get_player(event) - local state = event.element.state - if state then + if event.element.state then if is_type(checkbox.data._true,'function') then local success, err = pcall(checkbox.data._true,player,event.element) if not success then error(err) end @@ -253,10 +245,10 @@ function inputs.add_checkbox(name,radio,display,default,callback_true,callback_f else error('Invalid Callback') end end end) - return checkbox + return rtn_checkbox end ---- Used to reset the state of radio buttons, recomened to be called on_state_change to reset any radio buttons it is ment to work with. +--- Used to reset the state of radio buttons, recommended to be called on_state_change to reset any radio buttons it is meant to work with. -- @usage Gui.inputs.reset_radio{radio1,radio2,...} -- @param elements can be a list of elements or a single element function inputs.reset_radio(elements) @@ -294,23 +286,23 @@ end -- @treturn table the text object that was made, to allow a custom error event if wanted function inputs.add_text(name,box,text,callback) local type = 'textfield'; if box then type='text-box' end - local textbox = inputs.add{ + local rtn_textbox = inputs.add{ type=type, name=name, text=text } - textbox.data._callback = callback - textbox:on_event('text',function(event) + rtn_textbox.data._callback = callback + rtn_textbox:on_event('text',function(event) local textbox = Gui.data['inputs_'..event.element.type][event.element.name] local player = Game.get_player(event) local element = event.element - local callback = textbox.data._callback - if is_type(callback,'function') then - local success, err = pcall(callback,player,element.text,element) + local event_callback = textbox.data._callback + if is_type(event_callback,'function') then + local success, err = pcall(event_callback,player,element.text,element) if not success then error(err) end else error('Invalid Callback Condition Format') end end) - return textbox + return rtn_textbox end --- Used to define a slider callback only on value_changed @@ -355,31 +347,29 @@ end -- @tparam function callback the callback which is called when a new index is selected function(player,selected,items,element) -- @treturn table the drop-down object that was made, to allow a custom error event if wanted function inputs.add_drop_down(name,items,index,callback) - local drop_down = inputs.add{ + local rtn_dropdown = inputs.add{ type='drop-down', name=name, items=items, selected_index=index } - drop_down.data._items = items - drop_down.data._index = index - drop_down.data._callback = callback - drop_down:on_event('selection',function(event) - local drop_down = Gui.data['inputs_'..event.element.type][event.element.name] + rtn_dropdown.data._items = items + rtn_dropdown.data._index = index + rtn_dropdown.data._callback = callback + rtn_dropdown:on_event('selection',function(event) + local dropdown = Gui.data['inputs_'..event.element.type][event.element.name] local player = Game.get_player(event) local element = event.element - local items = element.items - local selected = items[element.selected_index] - local callback = drop_down.data._callback - if is_type(callback,'function') then - local success, err = pcall(callback,player,selected,items,element) + local drop_items = element.items + local selected = drop_items[element.selected_index] + local drop_callback = dropdown.data._callback + if is_type(drop_callback,'function') then + local success, err = pcall(drop_callback,player,selected,drop_items,element) if not success then error(err) end else error('Invalid Callback Condition Format') end end) - return drop_down + return rtn_dropdown end -- calling will attempt to add a new input return setmetatable(inputs,{__call=function(self,...) return self.add(...) end}) - --- to see examples look at GuiParts/test.lua diff --git a/modules/ExpGamingCore/Gui/inputs/softmod.json b/modules/ExpGamingCore/Gui/inputs/softmod.json new file mode 100644 index 00000000..ba17e5a2 --- /dev/null +++ b/modules/ExpGamingCore/Gui/inputs/softmod.json @@ -0,0 +1,23 @@ +{ + "name": "ExpGamingCore.Gui.inputs", + "version": "4.0.0", + "description": "Addds an event manager for gui inputs and easy input creation", + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Inputs", + "Buttons", + "Text Fields" + ], + "collection": "ExpGamingCore.Gui@4.0.0", + "dependencies": { + "mod-gui": "*", + "FactorioStdLib.Color": "^0.8.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Gui": "^4.0.0" + }, + "submodules": {} +} diff --git a/modules/ExpGamingCore/Gui/left/control.lua b/modules/ExpGamingCore/Gui/left/control.lua new file mode 100644 index 00000000..7de7a904 --- /dev/null +++ b/modules/ExpGamingCore/Gui/left/control.lua @@ -0,0 +1,245 @@ +--- Adds a organiser for left gui elements which will automatically update there information and have open requirements +-- @module ExpGamingCore.Gui.Left +-- @alias left +-- @author Cooldude2606 +-- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE + +--- This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module +-- @function _comment +local Game = require('FactorioStdLib.Game') +local Server = require('ExpGamingCore.Server') +local Color = require('FactorioStdLib.Color') +local mod_gui = require('mod-gui') +local Gui = require('ExpGamingCore.Gui') +local order_config = require(module_path..'/order_config') +local Role -- this is optional and is handled by it being present, it is loaded on init + +local left = {} +left._prototype = {} + +left.hide = Gui.inputs{ + name='gui-left-hide', + type='button', + caption='<' +}:on_event('click',function(event) + for _,child in pairs(event.element.parent.children) do + if child.name ~= 'popups' then child.style.visible = false end + end +end) + +local global = global() + +-- used for debugging +function left.override_open(state) + global.over_ride_left_can_open = state +end +--- Used to add a left gui frame +-- @usage Gui.left.add{name='foo',caption='Foo',tooltip='just testing',open_on_join=true,can_open=function,draw=function} +-- @usage return_value(player) -- toggles visibility for that player, if no player then updates for all players +-- @param obj this is what will be made, needs a name and a draw function(root_frame), open_on_join can be used to set the default state true/false, can_open is a test to block it from opening but is not needed +-- @return the object that is made, calling the returned value with out a param will update the gui, else will toggle visibility for that player +function left.add(obj) + if not is_type(obj,'table') then return end + if not is_type(obj.name,'string') then return end + verbose('Created Left Gui: '..obj.name) + setmetatable(obj,{__index=left._prototype,__call=function(self,player) if player then return self:toggle(player) else return left.update(self.name) end end}) + Gui.data('left',obj.name,obj) + if Gui.toolbar then Gui.toolbar(obj.name,obj.caption,obj.tooltip,function(event) obj:toggle(event) end) end + return obj +end + +--- This is used to update all the guis of connected players, good idea to use our thread system as it as nested for loops +-- @usage Gui.left.update() +-- @tparam[opt] string frame this is the name of a frame if you only want to update one +-- @param[opt] players the player to update for, if not given all players are updated, can be one player +function left.update(frame,players) + if not Server or not Server._thread then + players = is_type(players,'table') and #players > 0 and {unpack(players)} or is_type(players,'table') and {players} or Game.get_player(players) and {Game.get_player(players)} or game.connected_players + for _,player in pairs(players) do + local frames = Gui.data.left or {} + if frame then frames = {[frame]=frames[frame]} or {} end + for _,left_frame in pairs(frames) do + if left_frame then left_frame:first_open(player) end + end + end + else + local frames = Gui.data.left or {} + if frame then frames = {[frame]=frames[frame]} or {} end + players = is_type(players,'table') and #players > 0 and {unpack(players)} or is_type(players,'table') and {players} or Game.get_player(players) and {Game.get_player(players)} or game.connected_players + Server.new_thread{ + data={players=players,frames=frames} + }:on_event('tick',function(thread) + if #thread.data.players == 0 then thread:close() return end + local player = table.remove(thread.data.players,1) + Server.new_thread{ + data={player=player,frames=thread.data.frames} + }:on_event('resolve',function(thread) + for _,left_frame in pairs(thread.data.frames) do + if left_frame then left_frame:first_open(thread.data.player) end + end + end):queue() + end):open() + end +end + +--- Used to open the left gui of every player +-- @usage Gui.left.open('foo') +-- @tparam string left_name this is the gui that you want to open +-- @tparam[opt] LuaPlayer the player to open the gui for +function left.open(left_name,player) + local players = player and {player} or game.connected_players + local _left = Gui.data.left[left_name] + if not _left then return end + if not Server or not Server._thread then + for _,next_player in pairs(players) do _left:open(next_player) end + else + Server.new_thread{ + data={players=players} + }:on_event('tick',function(thread) + if #thread.data.players == 0 then thread:close() return end + local next_player = table.remove(thread.data.players,1) + _left:open(next_player) + end):open() + end +end + +--- Used to close the left gui of every player +-- @usage Gui.left.close('foo') +-- @tparam string left_name this is the gui that you want to close +-- @tparam[opt] LuaPlayer the player to close the gui for +function left.close(left_name,player) + local players = player and {player} or game.connected_players + local _left = Gui.data.left[left_name] + if not _left then return end + if not Server or not Server._thread or player then + for _,next_player in pairs(players) do _left:close(next_player) end + else + Server.new_thread{ + data={players=players} + }:on_event('tick',function(thread) + if #thread.data.players == 0 then thread:close() return end + local next_player = table.remove(thread.data.players,1) + _left:close(next_player) + end):open() + end +end + + +--- Used to force the gui open for the player +-- @usage left:open(player) +-- @tparam luaPlayer player the player to open the gui for +function left._prototype:open(player) + player = Game.get_player(player) + if not player then error('Invalid Player') end + local left_flow = mod_gui.get_frame_flow(player) + if not left_flow[self.name] then self:first_open(player) end + left_flow[self.name].style.visible = true + if left_flow['gui-left-hide'] then left_flow['gui-left-hide'].style.visible = true end +end + +--- Used to force the gui closed for the player +-- @usage left:open(player) +-- @tparam luaPlayer player the player to close the gui for +function left._prototype:close(player) + player = Game.get_player(player) + if not player then error('Invalid Player') end + local left_flow = mod_gui.get_frame_flow(player) + if not left_flow[self.name] then self:first_open(player) end + left_flow[self.name].style.visible = false + local count = 0 + for _,child in pairs(left_flow.children) do if child.style.visible then count = count+1 end if count > 1 then break end end + if count == 1 and left_flow['gui-left-hide'] then left_flow['gui-left-hide'].style.visible = false end +end + +--- When the gui is first made or is updated this function is called, used by the script +-- @usage left:first_open(player) -- returns the frame +-- @tparam LuaPlayer player the player to draw the gui for +-- @treturn LuaFrame the frame made/updated +function left._prototype:first_open(player) + player = Game.get_player(player) + local left_flow = mod_gui.get_frame_flow(player) + local frame + if left_flow[self.name] then + frame = left_flow[self.name] + frame.clear() + else + if not left_flow['gui-left-hide'] then left.hide(left_flow).style.maximal_width=15 end + frame = left_flow.add{type='frame',name=self.name,style=mod_gui.frame_style,caption=self.caption,direction='vertical'} + frame.style.visible = false + if is_type(self.open_on_join,'boolean') then frame.style.visible = self.open_on_join left_flow['gui-left-hide'].style.visible = true end + end + if is_type(self.draw,'function') then self:draw(frame) else frame.style.visible = false error('No Callback On '..self.name) end + return frame +end + +--- Toggles the visibility of the gui based on some conditions +-- @usage left:toggle(player) -- returns new state +-- @tparam LuaPlayer player the player to toggle the gui for, remember there are condition which need to be met +-- @treturn boolean the new state that the gui is in +function left._prototype:toggle(player) + player = Game.get_player(player) + local left_flow = mod_gui.get_frame_flow(player) + if not left_flow[self.name] then self:first_open(player) end + local left_frame = left_flow[self.name] + local open = false + if is_type(self.can_open,'function') then + local success, err = pcall(self.can_open,player) + if not success then error(err) + elseif err == true then open = true + elseif global.over_ride_left_can_open then + if is_type(Role,'table') then + if Role.allowed(player,self.name) then open = true + else open = {'ExpGamingCore_Gui.unauthorized'} end + else open = true end + else open = err end + else + if is_type(Role,'table') then + if Role.allowed(player,self.name) then open = true + else open = {'ExpGamingCore_Gui.unauthorized'} end + else open = true end + end + if open == true and left_frame.style.visible ~= true then + left_frame.style.visible = true + left_flow['gui-left-hide'].style.visible = true + else + left_frame.style.visible = false + local count = 0 + for _,child in pairs(left_flow.children) do if child.style.visible then count = count+1 end if count > 1 then break end end + if count == 1 and left_flow['gui-left-hide'] then left_flow['gui-left-hide'].style.visible = false end + end + if open == false then player_return({'ExpGamingCore_Gui.cant-open-no-reason'},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} + elseif open ~= true then player_return({'ExpGamingCore_Gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end + return left_frame.style.visible +end + +script.on_event(defines.events.on_player_joined_game,function(event) + -- draws the left guis when a player first joins, fake_event is just because i am lazy + local player = Game.get_player(event) + local frames = Gui.data.left or {} + local left_flow = mod_gui.get_frame_flow(player) + if not left_flow['gui-left-hide'] then left.hide(left_flow).style.maximal_width=15 end + local done = {} + for _,name in pairs(order_config) do + local left_frame = Gui.data.left[name] + if left_frame then + done[name] = true + left_frame:first_open(player) + end + end + for name,left_frame in pairs(frames) do + if not done[name] then left_frame:first_open(player) end + end +end) + +script.on_event(defines.events.on_tick,function(event) + if ((event.tick+10)/(3600*game.speed)) % 15 == 0 then + left.update() + end +end) + +function left.on_init() + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end +end + +-- calling will attempt to add a new gui +return setmetatable(left,{__call=function(self,...) return self.add(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingCore/Gui/order_config.lua b/modules/ExpGamingCore/Gui/left/order_config.lua similarity index 100% rename from modules/ExpGamingCore/Gui/order_config.lua rename to modules/ExpGamingCore/Gui/left/order_config.lua diff --git a/modules/ExpGamingCore/Gui/left/softmod.json b/modules/ExpGamingCore/Gui/left/softmod.json new file mode 100644 index 00000000..d02b320e --- /dev/null +++ b/modules/ExpGamingCore/Gui/left/softmod.json @@ -0,0 +1,26 @@ +{ + "name": "ExpGamingCore.Gui.left", + "version": "4.0.0", + "description": "Adds an easy way to create auto updating left guis with toggle buttons.", + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Left", + "AutoUpdate" + ], + "collection": "ExpGamingCore.Gui@4.0.0", + "dependencies": { + "mod-gui": "*", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Server": "^4.0.0", + "FactorioStdLib.Color": "^0.8.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Gui.inputs": "^4.0.0", + "ExpGamingCore.Gui.toolbar": "?^4.0.0", + "ExpGamingCore.Role": "?^4.0.0" + }, + "submodules": {} +} diff --git a/modules/ExpGamingCore/Gui/src/popup.lua b/modules/ExpGamingCore/Gui/popup/control.lua similarity index 88% rename from modules/ExpGamingCore/Gui/src/popup.lua rename to modules/ExpGamingCore/Gui/popup/control.lua index 9c1bb03b..7a49bae3 100644 --- a/modules/ExpGamingCore/Gui/src/popup.lua +++ b/modules/ExpGamingCore/Gui/popup/control.lua @@ -8,25 +8,13 @@ -- @function _comment local Game = require('FactorioStdLib.Game') -local mod_gui = require("mod-gui") -local Gui = Gui -- this is to force gui to remain in the ENV +local mod_gui = require('mod-gui') +local Gui = require('ExpGamingCore.Gui') +local Server -- loaded on_init local popup = {} popup._prototype = {} -function popup.load() - popup._prototype.close = Gui.inputs.add{ - type='button', - name='popup-close', - caption='utility/set_bar_slot', - tooltip='Close This Popup' - }:on_event('click',function(event) - local frame = event.element.parent - local parent = frame.parent - if frame and frame.valid then frame.destroy() if #parent.children == 0 then parent.style.visible = false end end - end) -end - --- Used to add a popup gui style -- @usage Gui.left.add{name='foo',caption='Foo',draw=function} -- @usage return_value(data,player) -- opens popup for one player use popup.open to open for more than one player @@ -45,7 +33,7 @@ end -- this is used by the script to find the popup flow function popup.flow(player) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then error('Invalid Player',2) end local flow = mod_gui.get_frame_flow(player).popups if not flow then flow = mod_gui.get_frame_flow(player).add{name='popups',type='flow',direction='vertical'} flow.style.visible=false end @@ -59,8 +47,8 @@ end -- @tparam[opt=game.connected_players] table players the players to open the popup for function popup.open(style,data,players) local _popup = Gui.data.popup[style] - local players = players or game.connected_players - local data = data or {} + players = players or game.connected_players + data = data or {} if not _popup then return end if not Server or not Server._thread then for _,player in pairs(players) do @@ -80,7 +68,7 @@ function popup.open(style,data,players) } _popup.close(_frame) if is_type(_popup.draw,'function') then - local success, err = pcall(_popup.draw,frame,data) + local success, err = pcall(_popup.draw,_popup,frame,data) if not success then error(err) end else error('No Draw On Popup '.._popup.name) end end @@ -106,7 +94,7 @@ function popup.open(style,data,players) } self.data.popup.close(_frame) if is_type(self.data.popup.draw,'function') then - local success, err = pcall(self.data.popup.draw,frame,self.data.data) + local success, err = pcall(self.data.popup.draw,self.data.popup,frame,self.data.data) if not success then error(err) end else error('No Draw On Popup '..self.data.popup.name) end end):open() @@ -114,11 +102,29 @@ function popup.open(style,data,players) end function popup._prototype:add_left(obj) + if not Gui.left then return end obj.name = obj.name or self.name self.left = Gui.left(obj) end -popup.on_player_joined_game = popup.flow +function popup.on_init() + if loaded_modules['ExpGamingCore.Server'] then Server = require('ExpGamingCore.Server') end +end + +function popup.on_post() + popup._prototype.close = Gui.inputs.add{ + type='button', + name='popup-close', + caption='utility/set_bar_slot', + tooltip='Close This Popup' + }:on_event('click',function(event) + local frame = event.element.parent + local parent = frame.parent + if frame and frame.valid then frame.destroy() if #parent.children == 0 then parent.style.visible = false end end + end) +end + +script.on_event(defines.events.on_player_joined_game,popup.flow) -- calling will attempt to add a new popup style return setmetatable(popup,{__call=function(self,...) return self.add(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingCore/Gui/popup/softmod.json b/modules/ExpGamingCore/Gui/popup/softmod.json new file mode 100644 index 00000000..f4b3f736 --- /dev/null +++ b/modules/ExpGamingCore/Gui/popup/softmod.json @@ -0,0 +1,24 @@ +{ + "name": "ExpGamingCore.Gui.popup", + "version": "4.0.0", + "description": "Adds popup guis to the gui system which builds upon the left gui system.", + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Popup", + "Left" + ], + "collection": "ExpGamingCore.Gui@4.0.0", + "dependencies": { + "mod-gui": "*", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Gui.inputs": "^4.0.0", + "ExpGamingCore.Server": "?^4.0.0", + "ExpGamingCore.Gui.left": "?^4.0.0" + }, + "submodules": {} +} diff --git a/modules/ExpGamingCore/Gui/softmod.json b/modules/ExpGamingCore/Gui/softmod.json index f264a4af..7363526b 100644 --- a/modules/ExpGamingCore/Gui/softmod.json +++ b/modules/ExpGamingCore/Gui/softmod.json @@ -1,24 +1,29 @@ { - "name": "Gui", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a objective version to custom guis.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Gui_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core", - "Gui", - "ExpGui" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Server": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCore.Gui", + "version": "4.0.0", + "description": "Adds a objective version to custom guis.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Library", + "Lib", + "ExpGaming", + "Core", + "Gui", + "ExpGui" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "FactorioStdLib.Table": "^0.8.0", + "FactorioStdLib.Color": "^0.8.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Server": "?^4.0.0" + }, + "collection": "ExpGamingCore@4.0.0", + "submodules": { + "ExpGamingCore.Gui.center": "4.0.0", + "ExpGamingCore.Gui.inputs": "4.0.0", + "ExpGamingCore.Gui.left": "4.0.0", + "ExpGamingCore.Gui.popup": "4.0.0", + "ExpGamingCore.Gui.toolbar": "4.0.0" + } +} diff --git a/modules/ExpGamingCore/Gui/src/left.lua b/modules/ExpGamingCore/Gui/src/left.lua deleted file mode 100644 index 942ddf6b..00000000 --- a/modules/ExpGamingCore/Gui/src/left.lua +++ /dev/null @@ -1,240 +0,0 @@ ---- Adds a organiser for left gui ellements which will automaticaly update there information and have open requirements --- @module ExpGamingCore.Gui.Left --- @alias left --- @author Cooldude2606 --- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE - ---- This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module --- @function _comment - - local Game = require('FactorioStdLib.Game') - local Server = require('ExpGamingCore.Server') - local Color = require('FactorioStdLib.Color') - local Role -- this is optional and is hanndled by it being present, it is loaded on init - local mod_gui = require("mod-gui") - local Gui = Gui -- this is to force gui to remain in the ENV - local order_config = order_config - - local left = {} - left._prototype = {} - - left.hide = Gui.inputs{ - name='gui-left-hide', - type='button', - caption='<' - }:on_event('click',function(event) - for _,child in pairs(event.element.parent.children) do - if child.name ~= 'popups' then child.style.visible = false end - end - end) - - local global = self_global - - -- used for debugging - function left.override_open(state) - global.over_ride_left_can_open = state - end - --- Used to add a left gui frame - -- @usage Gui.left.add{name='foo',caption='Foo',tooltip='just testing',open_on_join=true,can_open=function,draw=function} - -- @usage return_value(player) -- toggles visiblity for that player, if no player then updates for all players - -- @param obj this is what will be made, needs a name and a draw function(root_frame), open_on_join can be used to set the deaful state true/false, can_open is a test to block it from opening but is not needed - -- @return the object that is made, calling the returned value with out a param will update the gui, else will toggle visiblity for that player - function left.add(obj) - if not is_type(obj,'table') then return end - if not is_type(obj.name,'string') then return end - verbose('Created Left Gui: '..obj.name) - setmetatable(obj,{__index=left._prototype,__call=function(self,player) if player then return self:toggle(player) else return left.update(self.name) end end}) - Gui.data('left',obj.name,obj) - Gui.toolbar(obj.name,obj.caption,obj.tooltip,function(event) obj:toggle(event) end) - return obj - end - - --- This is used to update all the guis of connected players, good idea to use our thread system as it as nested for loops - -- @usage Gui.left.update() - -- @tparam[opt] string frame this is the name of a frame if you only want to update one - -- @param[opt] players the player to update for, if not given all players are updated, can be one player - function left.update(frame,players) - if not Server or not Server._thread then - local players = is_type(players,'table') and #players > 0 and {unpack(players)} or is_type(players,'table') and {players} or Game.get_player(players) and {Game.get_player(players)} or game.connected_players - for _,player in pairs(players) do - local frames = Gui.data.left or {} - if frame then frames = {[frame]=frames[frame]} or {} end - for name,left in pairs(frames) do - if _left then left:first_open(player) end - end - end - else - local frames = Gui.data.left or {} - if frame then frames = {[frame]=frames[frame]} or {} end - local players = is_type(players,'table') and #players > 0 and {unpack(players)} or is_type(players,'table') and {players} or Game.get_player(players) and {Game.get_player(players)} or game.connected_players - Server.new_thread{ - data={players=players,frames=frames} - }:on_event('tick',function(thread) - if #thread.data.players == 0 then thread:close() return end - local player = table.remove(thread.data.players,1) - Server.new_thread{ - data={player=player,frames=thread.data.frames} - }:on_event('resolve',function(thread) - for name,left in pairs(thread.data.frames) do - if left then left:first_open(thread.data.player) end - end - end):queue() - end):open() - end - end - - --- Used to open the left gui of every player - -- @usage Gui.left.open('foo') - -- @tparam string left_name this is the gui that you want to open - -- @tparam[opt] LuaPlayer the player to open the gui for - function left.open(left_name,player) - local players = player and {player} or game.connected_players - local _left = Gui.data.left[left_name] - if not _left then return end - if not Server or not Server._thread then - for _,player in pairs(players) do _left:open(player) end - else - Server.new_thread{ - data={players=players} - }:on_event('tick',function(thread) - if #thread.data.players == 0 then thread:close() return end - local player = table.remove(thread.data.players,1) - _left:open(player) - end):open() - end - end - - --- Used to close the left gui of every player - -- @usage Gui.left.close('foo') - -- @tparam string left_name this is the gui that you want to close - -- @tparam[opt] LuaPlayer the player to close the gui for - function left.close(left_name,player) - local players = player and {player} or game.connected_players - local _left = Gui.data.left[left_name] - if not _left then return end - if not Server or not Server._thread or player then - for _,player in pairs(players) do _left:close(player) end - else - Server.new_thread{ - data={players=players} - }:on_event('tick',function(thread) - if #thread.data.players == 0 then thread:close() return end - local player = table.remove(thread.data.players,1) - _left:close(player) - end):open() - end - end - - - --- Used to force the gui open for the player - -- @usage left:open(player) - -- @tparam luaPlayer player the player to open the gui for - function left._prototype:open(player) - local player = Game.get_player(player) - if not player then error('Invalid Player') end - local left_flow = mod_gui.get_frame_flow(player) - if not left_flow[self.name] then self:first_open(player) end - left_flow[self.name].style.visible = true - if left_flow['gui-left-hide'] then left_flow['gui-left-hide'].style.visible = true end - end - - --- Used to force the gui closed for the player - -- @usage left:open(player) - -- @tparam luaPlayer player the player to close the gui for - function left._prototype:close(player) - local player = Game.get_player(player) - if not player then error('Invalid Player') end - local left_flow = mod_gui.get_frame_flow(player) - if not left_flow[self.name] then self:first_open(player) end - left_flow[self.name].style.visible = false - local count = 0 - for _,child in pairs(left_flow.children) do if child.style.visible then count = count+1 end if count > 1 then break end end - if count == 1 and left_flow['gui-left-hide'] then left_flow['gui-left-hide'].style.visible = false end - end - - --- When the gui is first made or is updated this function is called, used by the script - -- @usage left:first_open(player) -- returns the frame - -- @tparam LuaPlayer player the player to draw the gui for - -- @treturn LuaFrame the frame made/updated - function left._prototype:first_open(player) - local player = Game.get_player(player) - local left_flow = mod_gui.get_frame_flow(player) - local frame = nil - if left_flow[self.name] then - frame = left_flow[self.name] - frame.clear() - else - if not left_flow['gui-left-hide'] then left.hide(left_flow).style.maximal_width=15 end - frame = left_flow.add{type='frame',name=self.name,style=mod_gui.frame_style,caption=self.caption,direction='vertical'} - frame.style.visible = false - if is_type(self.open_on_join,'boolean') then frame.style.visible = self.open_on_join left_flow['gui-left-hide'].style.visible = true end - end - if is_type(self.draw,'function') then self.draw(frame) else frame.style.visible = false error('No Callback On '..self.name) end - return frame - end - - --- Toggles the visiblity of the gui based on some conditions - -- @usage left:toggle(player) -- returns new state - -- @tparam LuaPlayer player the player to toggle the gui for, remember there are condition which need to be met - -- @treturn boolean the new state that the gui is in - function left._prototype:toggle(player) - local player = Game.get_player(player) - local left_flow = mod_gui.get_frame_flow(player) - if not left_flow[self.name] then self:first_open(player) end - local left = left_flow[self.name] - local open = false - if is_type(self.can_open,'function') then - local success, err = pcall(self.can_open,player) - if not success then error(err) - elseif err == true then open = true - elseif global.over_ride_left_can_open then - if is_type(Role,'table') then - if Role.allowed(player,self.name) then open = true - else open = {'ExpGamingCore_Gui.unauthorized'} end - else open = true end - else open = err end - else - if is_type(Role,'table') then - if Role.allowed(player,self.name) then open = true - else open = {'ExpGamingCore_Gui.unauthorized'} end - else open = true end - end - if open == true and left.style.visible ~= true then - left.style.visible = true - left_flow['gui-left-hide'].style.visible = true - else - left.style.visible = false - local count = 0 - for _,child in pairs(left_flow.children) do if child.style.visible then count = count+1 end if count > 1 then break end end - if count == 1 and left_flow['gui-left-hide'] then left_flow['gui-left-hide'].style.visible = false end - end - if open == false then player_return({'ExpGamingCore_Gui.cant-open-no-reason'},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} - elseif open ~= true then player_return({'ExpGamingCore_Gui.cant-open',open},defines.textcolor.crit,player) player.play_sound{path='utility/cannot_build'} end - return left.style.visible - end - - left.on_player_joined_game = function(event) - -- draws the left guis when a player first joins, fake_event is just because i am lazy - local player = Game.get_player(event) - local frames = Gui.data.left or {} - local left_flow = mod_gui.get_frame_flow(player) - if not left_flow['gui-left-hide'] then left.hide(left_flow).style.maximal_width=15 end - local done = {} - for _,name in pairs(order_config) do - local left = Gui.data.left[name] - if left then - done[name] = true - left:first_open(player) - end - end - for name,left in pairs(frames) do - if not done[name] then left:first_open(player) end - end - end - - function left:on_init() - if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end - end - - -- calling will attempt to add a new gui - return setmetatable(left,{__call=function(self,...) return self.add(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingCore/Gui/src/server.lua b/modules/ExpGamingCore/Gui/src/server.lua index ca360803..1b613e11 100644 --- a/modules/ExpGamingCore/Gui/src/server.lua +++ b/modules/ExpGamingCore/Gui/src/server.lua @@ -1,13 +1,13 @@ --- This file will be loaded when ExpGamingCore.Server is present -- @function _comment -local Game = require('FactorioStdLib.Game@^0.8.0') -local Server = require('ExpGamingCore.Server@^4.0.0') +local Game = require('FactorioStdLib.Game') +local Server = require('ExpGamingCore.Server') Server.add_module_to_interface('ExpGui','ExpGamingCore.Gui') --- Adds a server thread that allows the camera follows to be toggled off and on -return function(event) +return function() Server.new_thread{ name='camera-follow', data={cams={},cam_index=1,players={}} diff --git a/modules/ExpGamingCore/Gui/src/test.lua b/modules/ExpGamingCore/Gui/src/test.lua index bb841e24..9ba60632 100644 --- a/modules/ExpGamingCore/Gui/src/test.lua +++ b/modules/ExpGamingCore/Gui/src/test.lua @@ -6,7 +6,7 @@ --- This is a submodule of ExpGamingCore.Gui but for ldoc reasons it is under its own module -- @function _comment -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') local Gui = Gui -- this is to force gui to remain in the ENV local mod_gui = require("mod-gui") @@ -53,30 +53,30 @@ local input_test = Gui.inputs.add_button('test-inputs','Try RMB','alt,ctrl,shift function(player,mouse,keys) return mouse == defines.mouse_button_type.right and keys.shift end, function(player,element) player_return('Right: Shift',nil,player) end } -}):on_event('error',function(err) game.print('this is error handliling') end) +}):on_event('error',function(err) game.print('this is error handling') end) local elem_test = Gui.inputs.add_elem_button('test-elem','item','Testing Elems',function(player,element,elem) player_return(elem.type..' '..elem.value,nil,player) end) -local check_test = Gui.inputs.add_checkbox('test-check',false,'Cheat Mode',function(player,parent) - return game.players[parent.player_index].cheat_mode -end,function(player,element) - player.cheat_mode = true +local check_test = Gui.inputs.add_checkbox('test-check',false,'Cheat Mode',function(player,parent) + return game.players[parent.player_index].cheat_mode +end,function(player,element) + player.cheat_mode = true end,function(player,element) player.cheat_mode = false end) -local radio_test = Gui.inputs.add_checkbox('test-radio',true,'Kill Self',function(player,parent) +local radio_test = Gui.inputs.add_checkbox('test-radio',true,'Kill Self',function(player,parent) return false -end,function(player,element) +end,function(player,element) if player.character then player.character.die() end Gui.inputs.reset_radio(element.parent['test-radio-reset']) end) -local radio_test_reset = Gui.inputs.add_checkbox('test-radio-reset',true,'Reset Kill Self',function(player,parent) +local radio_test_reset = Gui.inputs.add_checkbox('test-radio-reset',true,'Reset Kill Self',function(player,parent) return not parent['test-radio'].state -end,function(player,element) +end,function(player,element) Gui.inputs.reset_radio(element.parent['test-radio']) end) @@ -143,7 +143,7 @@ Gui.left{ name='test-left', caption='Gui Left', tooltip='just testing', - draw=function(frame) + draw=function(self,frame) for _,player in pairs(game.connected_players) do frame.add{type='label',caption=player.name} end @@ -166,14 +166,14 @@ end) Gui.popup{ name='test-popup', caption='Gui Popup', - draw=function(frame,data) + draw=function(self,frame,data) frame.add{type='label',caption='Opened by: '..data.player} frame.add{type='label',caption='Message: '..data.message} end }:add_left{ caption='Gui Left w/ Popup', tooltip='Send a message', - draw=function(frame) + draw=function(self,frame) text_popup:draw(frame) send_popup:draw(frame) end diff --git a/modules/ExpGamingCore/Gui/src/toolbar.lua b/modules/ExpGamingCore/Gui/toolbar/control.lua similarity index 89% rename from modules/ExpGamingCore/Gui/src/toolbar.lua rename to modules/ExpGamingCore/Gui/toolbar/control.lua index f2efa707..cae2f467 100644 --- a/modules/ExpGamingCore/Gui/src/toolbar.lua +++ b/modules/ExpGamingCore/Gui/toolbar/control.lua @@ -8,10 +8,10 @@ -- @function _comment local Game = require('FactorioStdLib.Game') -local Role -- this is optional and is hanndled by it being present, it is loaded on init -local mod_gui = require("mod-gui") -local Gui = Gui -- this is to force gui to remain in the ENV -local order_config = order_config +local mod_gui = require('mod-gui') +local Gui = require('ExpGamingCore.Gui') +local order_config = require(module_path..'/order_config') +local Role -- this is optional and is handled by it being present, it is loaded on init local toolbar = {} @@ -52,7 +52,7 @@ end -- @usage toolbar.draw(1) -- @param player the player to draw the tool bar of function toolbar.draw(player) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then return end local toolbar_frame = mod_gui.get_button_flow(player) toolbar_frame.clear() @@ -81,11 +81,10 @@ function toolbar.draw(player) end end -function toolbar:on_init() +function toolbar.on_init() if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end end -toolbar.on_role_change = toolbar.draw -toolbar.on_player_joined_game = toolbar.draw +script.on_event({defines.events.on_role_change,defines.events.on_player_joined_game},toolbar.draw) -- calling with only a player will draw the toolbar for that player, more params will attempt to add a button return setmetatable(toolbar,{__call=function(self,player,extra,...) if extra then return self.add(player,extra,...) else self.draw(player) end end}) \ No newline at end of file diff --git a/modules/ExpGamingCore/Gui/toolbar/order_config.lua b/modules/ExpGamingCore/Gui/toolbar/order_config.lua new file mode 100644 index 00000000..7f19658f --- /dev/null +++ b/modules/ExpGamingCore/Gui/toolbar/order_config.lua @@ -0,0 +1,13 @@ +return { + 'server-info', + 'readme', + 'science', + 'rockets', + 'player-list', + 'tasklist', + 'warp-list', + 'polls', + 'announcements', + 'admin-commands', + 'game-settings' +} \ No newline at end of file diff --git a/modules/ExpGamingCore/Gui/toolbar/softmod.json b/modules/ExpGamingCore/Gui/toolbar/softmod.json new file mode 100644 index 00000000..54884fbf --- /dev/null +++ b/modules/ExpGamingCore/Gui/toolbar/softmod.json @@ -0,0 +1,23 @@ +{ + "name": "ExpGamingCore.Gui.toolbar", + "version": "4.0.0", + "description": "Adds a toolbar at the top of the screen", + "author": "Cooldude2606", + "contact": "Discord: Cooldude26060#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Toolbar", + "Buttons" + ], + "collection": "ExpGamingCore.Gui@4.0.0", + "dependencies": { + "mod-gui": "*", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Gui.inputs": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0" + }, + "submodules": {} +} diff --git a/modules/ExpGamingCore/Role/config.lua b/modules/ExpGamingCore/Role/config.lua index e0840c24..d755336e 100644 --- a/modules/ExpGamingCore/Role/config.lua +++ b/modules/ExpGamingCore/Role/config.lua @@ -1,13 +1,17 @@ -Role.add_flag('is_default') -- this must be included in atleast one role -Role.add_flag('is_root',function(player,state) player.character.destructible = not state end) -- not required but setting true will allow everythin for that role -Role.add_flag('is_antiroot',function(player,state) player.character.destructible = not state end) -- not required but setting true will disallow everythin for that role -Role.add_flag('is_admin',function(player,state) player.admin = state end) -- highly recomented but not required +Role.add_flag('is_default') -- this must be included in at least one role +Role.add_flag('is_root',function(player,state) + if state then game.print('--- !!!ALERT!!! --- '..player.name..' has been given a role with ROOT ACCESS --- !!!ALERT!!! ---') end + if player.character then player.character.destructible = not state end +end) -- the SERVER role will have root but you may assign this to other roles +-- the two above and used internally and should NOT have their names changed and should NOT be removed but the state function MAY be changed +Role.add_flag('is_antiroot',function(player,state) if player.character then player.character.destructible = not state end end) -- not required but setting true will disallow everything for that role +Role.add_flag('is_admin',function(player,state) player.admin = state end) -- highly recommenced but not required Role.add_flag('is_spectator',function(player,state) player.spectator = state end) -Role.add_flag('is_jail',function(player,state) player.character.active = not state end) +Role.add_flag('is_jail',function(player,state) if player.character then player.character.active = not state end end) Role.add_flag('allow_afk_kick') Role.add_flag('is_donator') Role.add_flag('is_timed') -Role.add_flag('is_varified') +Role.add_flag('is_verified') Role.add_flag('not_reportable') -- Root @@ -32,6 +36,7 @@ Role{ is_admin=true, is_spectator=true, is_donator=true, + not_reportable=true, allow={} } Role{ @@ -43,6 +48,7 @@ Role{ is_admin=true, is_spectator=true, is_donator=true, + not_reportable=true, allow={ ['interface']=true, ['cheat-mode']=true @@ -58,6 +64,7 @@ Role{ colour={r=233,g=63,b=233}, is_admin=true, is_spectator=true, + is_verified=true, not_reportable=true, allow={ ['game-settings']=true, @@ -73,6 +80,7 @@ Role{ colour={r=0,g=170,b=0}, is_admin=true, is_spectator=true, + is_verified=true, not_reportable=true, allow={ ['set-home']=true, @@ -89,11 +97,11 @@ Role{ group='Admin', colour={r=0,g=196,b=137}, is_spectator=true, + is_verified=true, not_reportable=true, allow={ ['go-to']=true, ['bring']=true, - ['no-report']=true, ['set-home']=false, ['home']=false, ['return']=false, @@ -101,7 +109,7 @@ Role{ ['admin-commands']=true, ['warn']=true, ['temp-ban']=true, - ['clear-warings']=true, + ['clear-warnings']=true, ['clear-reports']=true, ['clear-all']=true, ['clear-inv']=true, @@ -165,7 +173,7 @@ Role{ group='HiMember', colour={r=140,g=120,b=200}, is_timed=true, - is_varified=true, + is_verified=true, allow_afk_kick=true, time=600, -- 10 hours allow={ @@ -182,13 +190,13 @@ Role{ tag='[Member]', group='Member', colour={r=24,g=172,b=188}, - is_varified=true, + is_verified=true, allow_afk_kick=true, allow={ ['edit-tasklist']=true, ['make-warp']=true, ['nuke']=true, - ['varified']=true + ['verified']=true } } Role{ @@ -212,7 +220,7 @@ Role{ name='Guest', short_hand='', tag='', - group='Guest', + group='User', colour={r=185,g=187,b=160}, allow_afk_kick=true, is_default=true, diff --git a/modules/ExpGamingCore/Role/control.lua b/modules/ExpGamingCore/Role/control.lua index f721c2b1..364bc995 100644 --- a/modules/ExpGamingCore/Role/control.lua +++ b/modules/ExpGamingCore/Role/control.lua @@ -2,17 +2,18 @@ -- @module ExpGamingCore.Role@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais Role +-- @alias Role -- Module Require -local Group = require('ExpGamingCore.Group@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Group = require('ExpGamingCore.Group') +local Game = require('FactorioStdLib.Game') --- Local Varibles +-- Local Variables local role_change_event_id = script.generate_event_name('on_role_change') local RoleGlobal -- Module Define +local _RoleSelfReference local module_verbose = false local Role = { _prototype={}, @@ -24,17 +25,20 @@ local Role = { roles=setmetatable({},{ __index=table.autokey, __newindex=function(tbl,key,value) - rawset(tbl,key,Role.define(value)) + rawset(tbl,key,_RoleSelfReference.define(value)) end }), on_init=function(self) - if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Role','ExpGamingCore.Role') end - if loaded_modules['ExpGamingCore.Command@^4.0.0'] then require(module_path..'/src/commands',{self=self}) end - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then require(module_path..'/src/sync',{self=self,RoleGlobal=RoleGlobal}) end + if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server').add_module_to_interface('Role','ExpGamingCore.Role') end + if loaded_modules['ExpGamingCore.Command'] then require(module_path..'/src/commands',{self=self}) end + if loaded_modules['ExpGamingCore.Sync'] then require(module_path..'/src/sync',{self=self,RoleGlobal=RoleGlobal}) end end, on_post=function(self) + -- creates a server role with root access + self.meta.server = self{name='SERVER',group='Root',is_root=true,allow={}} -- loads the roles in config require(module_path..'/config',{Role=self}) + self.order[0] = 'SERVER' -- joins role allows into a chain local previous for index,role_name in pairs(self.order) do @@ -54,10 +58,11 @@ local Role = { else error('Invalid roles, no roles to load.') end end } +_RoleSelfReference=Role -- Global Define local global = global{ - change_chache_length=15, + change_cache_length=15, changes={}, latest_change={}, preassign={}, @@ -76,12 +81,12 @@ function Role.set_preassign(tbl) if game then global.preassign = tbl else Role.p -- @usage Role{name='Root',short_hand='Root',tag='[Root]',group='Root',colour={r=255,b=255,g=255},is_root=true,allow={}} -- returns new role -- @tparam table obj contains the strings: name,short_hand,tag a table called allow a table called colour and a pointer to a permission group -- @treturn Role the role which has been made -function Role.define(obj) +function Role.define(obj) if not type_error(game,nil,'Cant define Role during runtime.') then return end if not type_error(obj.name,'string','Role creation is invalid: role.name is not a string') then return end if not is_type(obj.short_hand,'string') then obj.short_hand = obj.name:sub(1,3) end if not is_type(obj.tag,'string') then obj.tag = '['..obj.short_hand..']' end - if not type_error(obj.colour,'table','Role creation is invalid: role.colour is not a table') then return end + if not is_type(obj.colour,'table') then obj.colour = {r=255,b=255,g=255} end if not type_error(obj.allow,'table','Role creation is invalid: role.allow is not a table') then return end obj.group = Group.get(obj.group) if not type_error(obj.group,'table','Role creation is invalid: role.group is invalid') then return end @@ -98,42 +103,48 @@ end --- Used to get the role of a player or the role by name -- @usage Role.get('foo') -- returns group foo -- @usage Role.get(player) -- returns group of player --- @tparam ?LuaPlayer|pointerToPlayer|string mixed can either be the name of the role or a player indenifier +-- @tparam ?LuaPlayer|pointerToPlayer|string mixed can either be the name of the role or a player identifier -- @treturn table the group which was found or nil -function Role.get(mixed) +function Role.get(mixed,forceIsRole) local player = game and Game.get_player(mixed) - if player then + if player == SERVER then return {Role.meta.server} end + if not forceIsRole and player then local rtn = {} if not global.players[player.index] then return Role.meta.default and {Role.meta.default} or {} end for _,role in pairs(global.players[player.index]) do table.insert(rtn,Role.get(role)) end return rtn elseif is_type(mixed,'table') and mixed.group then return mixed - elseif is_type(mixed,'string') then return Role.roles[mixed] end + elseif is_type(mixed,'string') then return Role.roles[mixed] + elseif is_type(mixed,'number') then + for _,role in pairs(Role.roles) do + if role.index == mixed then return role end + end + end end --- Used to place a player into a role(s) -- @usage Role.assign(player,'Root') -- @usage Role.assign(player,{'Root','Foo'}) -- @tparam ?LuaPlayer|pointerToPlayer player the player to assign the role to --- @tparam ?string|role|table the role to add the player to, if its a table then it will act recursly though the table +-- @tparam ?string|role|table the role to add the player to, if its a table then it will act recursively though the table -- @tparam[opt=''] ?LuaPlayer|pointerToPlayer by_player the player who assigned the roles to the player --- @tparam[opt] table batch this is used internally to provent multiple event calls, conatins {role_index_in_batch,batch} +-- @tparam[opt] table batch this is used internally to prevent multiple event calls, contains {role_index_in_batch,batch} -- @treturn boolean was the player assigned the roles function Role.assign(player,role,by_player,batch) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then error('Invalid player #1 given to Role.assign.',2) return end verbose('Assigning Roles: '..serpent.line(role)..' to: '..player.name) - -- this loops over a table of role if given; will return if ipairs returns, else will asume it was ment to be a role and error - if is_type(role,'table') and not role.name then - local ctn = 0 + -- this loops over a table of role if given; will return if ipairs returns, else will assume it was meant to be a role and error + if is_type(role,'table') and not role.name then + local ctn = 0 for n,_role in ipairs(role) do ctn=ctn+1 Role.assign(player,_role,by_player,{n,role}) end - if ctn > 0 then if not batch then table.insert(global.changes[player.index],{'assign',role}) global.latest_change = {player.index,'assign',role} end return end + if ctn > 0 then if not batch then table.insert(global.changes[player.index],{'assign',role}) global.latest_change = {player.index,'assign',role} end return end end - local role = Role.get(role) + role = Role.get(role) if not role then error('Invalid role #2 given to Role.assign.',2) return end - -- this acts as a way to provent the global table getting too full + -- this acts as a way to prevent the global table getting too full if not global.changes[player.index] then global.changes[player.index]={} end - if #global.changes[player.index] > global.change_chache_length then table.remove(global.changes[player.index],1) end + if #global.changes[player.index] > global.change_cache_length then table.remove(global.changes[player.index],1) end if not batch then table.insert(global.changes[player.index],{'assign',role.name}) global.latest_change = {player.index,'assign',role.name} end return role:add_player(player,by_player,batch) end @@ -141,31 +152,31 @@ end --- Used to remove a player from a role(s) -- @usage Role.unassign(player,'Root') -- @tparam ?LuaPlayer|pointerToPlayer player the player to unassign the role to --- @tparam ?string|role|table role the role to remove the player from, if its a table then it will act recursly though the table +-- @tparam ?string|role|table role the role to remove the player from, if its a table then it will act recursively though the table -- @tparam[opt=''] ?LuaPlayer|pointerToPlayer by_player the player who unassigned the roles from the player --- @tparam[opt] table batch this is used internally to provent multiple event calls +-- @tparam[opt] table batch this is used internally to prevent multiple event calls -- @treturn boolean was the player unassigned the roles function Role.unassign(player,role,by_player,batch) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then error('Invalid player #1 given to Role.unassign.',2) return end verbose('Assigning Roles: '..serpent.line(role)..' to: '..player.name) - -- this loops over a table of role if given; will return if ipairs returns, else will asume it was ment to be a role and error + -- this loops over a table of role if given; will return if ipairs returns, else will assume it was meant to be a role and error if is_type(role,'table') and not role.name then local ctn = 0 for n,_role in ipairs(role) do ctn=ctn+1 Role.unassign(player,_role,by_player,{n,role}) end if ctn > 0 then if not batch then table.insert(global.changes[player.index],{'unassign',role}) global.latest_change = {player.index,'unassign',role} end return end end - local role = Role.get(role) + role = Role.get(role) if not role then error('Invalid role #2 given to Role.unassign.',2) return end if not global.changes[player.index] then global.changes[player.index]={} end - -- this acts as a way to provent the global table getting too full - if #global.changes[player.index] > global.change_chache_length then table.remove(global.changes[player.index],1) end + -- this acts as a way to prevent the global table getting too full + if #global.changes[player.index] > global.change_cache_length then table.remove(global.changes[player.index],1) end if not batch then table.insert(global.changes[player.index],{'unassign',role.name}) global.latest_change = {player.index,'unassign',role.name} end return role:remove_player(player,by_player,batch) end --- Returns the highest role given in a list, if a player is passed then it returns the highest role of the player --- @usage Role.get_highest{'Root','Admin','Mod'} -- retuns Root (given that root is highest) +-- @usage Role.get_highest{'Root','Admin','Mod'} -- returns Root (given that root is highest) -- @usage Role.get_highest(player) -- returns the players highest role -- @tparam ?table|LuaPlayer|pointerToPlayer options table of options or a player -- @treturn role the highest role given in the options @@ -183,26 +194,27 @@ function Role.get_highest(options) return highest end ---- Uses the change chache to revert changes to players roles +--- Uses the change cache to revert changes to players roles -- @usage Role.revert(player) -- reverts the last change to the players roles -- @tparam ?LuaPlayer|pointerToPlayer player the player to revert the changes of --- @tparam[opt] ?LuaPlayer|pointerToPlayer the player who proformed the role revert --- @tparam[opt=1] count the number of reverts to do, if 0 all changes chached are reverted --- @treturn number the number of changes that occured +-- @tparam[opt] ?LuaPlayer|pointerToPlayer the player who preformed the role revert +-- @tparam[opt=1] count the number of reverts to do, if 0 all changes cached are reverted +-- @treturn number the number of changes that occurred function Role.revert(player,by_player,count) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then error('Invalid player #1 given to Role.revert.',2) return end if count and not type_error(count,'number','Invalid argument #2 to Role.revert, count is not a number.') then return end local changes = global.changes[player.index] or {} if #changes == 0 then error('Player has no role changes logged, can not revert.') end - local count = count or 1 + count = count or 1 local ctn = 0 if count > #changes or count == 0 then count = #changes end for i = 1,count do local change = table.remove(changes) if not change then break end - if change[1] == 'assign' then Role.unassign(player,change[2],by_player,true) end - if change[1] == 'unassign' then Role.assign(player,change[2],by_player,true) end + local batch = is_type(change[2],'table') and change[2] or {change[2]} + if change[1] == 'assign' then Role.unassign(player,change[2],by_player,batch) end + if change[1] == 'unassign' then Role.assign(player,change[2],by_player,batch) end ctn=ctn+1 end return ctn @@ -210,7 +222,7 @@ end --- Adds a flag which can be set on roles; these flags act as a quick way to access general role changes -- @usage Role.add_flag('is_admin',function(player,state) player.admin = state end) -- the function is passed player and if the flag is true or false --- @tparam string flag the name of the falg that is being added +-- @tparam string flag the name of the flag that is being added -- @tparam[opt] function callback the function(player,state) which is called when a player loses or gains a flag, if nil no function is called function Role.add_flag(flag,callback) if not type_error(flag,'string','Invalid argument #1 to Role.add_flag, flag is not a string.') then return end @@ -219,7 +231,7 @@ function Role.add_flag(flag,callback) Role.flags[flag] = callback or true end ---- Checks if a player or role has the requested flag, if player all roles of player are checked (true has pirortiy) +--- Checks if a player or role has the requested flag, if player all roles of player are checked (true has priority) -- @usage Role.has_flag(role,'is_admin') -- returns true if this role has is_admin set -- @tparam role|LuaPlayer|pointerToPlayer mixed the player or role that will be tested -- @tparam string flag the flag to test for @@ -243,7 +255,7 @@ function Role.add_action(action) table.insert(Role.actions,action) end ---- Checks if a player or role is allowed the requested action, if player all roles of player are checked (true has pirortiy) +--- Checks if a player or role is allowed the requested action, if player all roles of player are checked (true has priority) -- @usage Role.allowed(role,'foo') -- returns true if this role is allowed 'foo' -- @tparam ?role|LuaPlayer|pointerToPlayer mixed the player or role that will be tested -- @tparam string action the action to test for @@ -259,32 +271,35 @@ function Role.allowed(mixed,action) end --- Prints to all roles and players of those roles which are greater than the given role (or if inv then all below) --- @usage Role.print('Admin','Hello, World!') -- returns the number of players who recived the message +-- @usage Role.print('Admin','Hello, World!') -- returns the number of players who received the message -- @tparam ?role|string role the role which acts as the turning point of the print (always included regardless of inv value) -- @param rtn the value that will be returned to the players -- @tparam[opt] table colour the colour that you want the message printed in -- @tparam[opt=false] boolean inv true to print to roles below, false to print to roles above --- @treturn number the number of players who recived the message +-- @treturn number the number of players who received the message function Role.print(role,rtn,colour,inv) - local role = Role.get(role) + role = Role.get(role,true) if not type_error(role,'table','Invalid argument #1 to Role.print, role is invalid.') then return end if colour and not type_error(colour,'table','Invalid argument #3 to Role.print, colour is not a table.') then return end if inv and not type_error(inv,'boolean','Invalid argument #4 to Role.print, inv is not a boolean.') then return end local message = inv and {'ExpGamingCore-Role.default-print',rtn} or {'ExpGamingCore-Role.print',role.name,rtn} - local print = inv or false + local change = inv and 1 or -1 local ctn = 0 - for index,_role in pairs(Role.roles) do - if print or _role == role then ctn=ctn+_role:print(message,colour) end - if _role == role then if print then break else print = true end end + local i = role.index + while true do + local _role = Role.get(i,true) + if not _role then break end + ctn=ctn+_role:print(message,colour) + i=i+change end return ctn end ---- Prints all registed roles and there important infomation (debug) +--- Prints all registered roles and there important information (debug) -- @tparam[opt] ?role|string the role to print the info of, if nil then all roles are printed in order of power -- @tparam[opt=game.player] ?LuaPlayer|pointerToPlayer the player to print the info to, default the player who ran command function Role.debug_output(role,player) - local player = Game.get_player(player) or game.player + player = Game.get_player(player) or game.player if not player then error('Invalid player #2 given to Role.debug_output.',2) return end local function _output(_role) local flags = {};for flag in pairs(Role.flags) do if _role:has_flag(flag) then table.insert(flags,flag) end end @@ -293,8 +308,8 @@ function Role.debug_output(role,player) player_return(rtn,_role.colour,player) end if role then - local role = Role.get(mixed) - if not type_error(roles,'table','Invalid argument #1 to Role.print, role is invalid.') then return end + role = Role.get(role) + if not type_error(role,'table','Invalid argument #1 to Role.print, role is invalid.') then return end _output(role) else for index,_role in pairs(Role.roles) do _output(_role) end end end @@ -341,18 +356,18 @@ end -- this is used to create a connected_players table Role._prototype.players_mt = { __call=function(tbl) return tbl.self:get_players(tbl.connected) end, - __pairs=function(tbl) - local players = tbl.self:get_players(tbl.connected) - local function next_pair(tbl,k) - k, v = next(players, k) + __pairs=function(tbl) + local players = tbl.self:get_players(tbl.connected) + local function next_pair(tbl,key) + local k, v = next(players, key) if v then return k,v end end return next_pair, players, nil end, __ipairs=function(tbl) - local players = tbl.self:get_players(tbl.connected) - local function next_pair(tbl,k) - k, v = next(players, k) + local players = tbl.self:get_players(tbl.connected) + local function next_pair(tbl,key) + local k, v = next(players, key) if v then return k,v end end return next_pair, players, nil @@ -361,10 +376,10 @@ Role._prototype.players_mt = { --- Prints a message to all players who have this role --- @usage role:print('Hello, World!') -- retuns number of players who recived the message +-- @usage role:print('Hello, World!') -- returns number of players who received the message -- @param rtn the message to print to the players -- @tparam[opt] table colour the colour to print the message in --- @treturn number the number of players who recived the message +-- @treturn number the number of players who received the message function Role._prototype:print(rtn,colour) if not self_test(self,'role','print') then return end if colour and not type_error(colour,'table','Invalid argument #2 to Role.print, colour is not a table.') then return end @@ -374,8 +389,8 @@ function Role._prototype:print(rtn,colour) end --- Returns a table that describes all the permissions and which this role is allowed --- @usage role:get_permissions() -- retuns table of permissions --- @treturn table a table of permisions, only includes ones which were defined with Role.add_action +-- @usage role:get_permissions() -- returns table of permissions +-- @treturn table a table of permissions, only includes ones which were defined with Role.add_action function Role._prototype:get_permissions() if not self_test(self,'role','get_permissions') then return end local rtn = {} @@ -387,12 +402,12 @@ end -- @usage role:add_player(player) -- @tparam ?LuaPlayer|PointerToPlayer player the player to add -- @tparam[opt] ?LuaPlayer|PointerToPlayer by_player the player who ran the command --- @tparam[opt] table batch this is used internally to provent multiple event calls +-- @tparam[opt] table batch this is used internally to prevent multiple event calls function Role._prototype:add_player(player,by_player,batch) if not self_test(self,'role','add_player') then return end - local player = Game.get_player(player) + player = Game.get_player(player) if not player then error('Invalid player #1 given to role:add_player.',2) return end - local by_player = Game.get_player(by_player) or SERVER + by_player = Game.get_player(by_player) or SERVER if not global.roles[self.name] then global.roles[self.name] = {} end if not global.players[player.index] then global.players[player.index] = {} end local highest = Role.get_highest(player) or Role.meta.default @@ -416,12 +431,12 @@ end -- @usage role:remove_player(player) -- @tparam ?LuaPlayer|PointerToPlayer player the player to remove -- @tparam[opt] ?LuaPlayer|PointerToPlayer by_player the player who ran the command --- @tparam[opt] table batch this is used internally to provent multiple event calls +-- @tparam[opt] table batch this is used internally to prevent multiple event calls function Role._prototype:remove_player(player,by_player,batch) if not self_test(self,'role','add_player') then return end - local player = Game.get_player(player) + player = Game.get_player(player) if not player then error('Invalid player #1 given to role:remove_player.',2) return end - local by_player = Game.get_player(by_player) or SERVER + by_player = Game.get_player(by_player) or SERVER if not global.roles[self.name] then global.roles[self.name] = {} end if not global.players[player.index] then global.players[player.index] = {} end local highest = Role.get_highest(player) or Role.meta.default @@ -445,13 +460,13 @@ end -- Event Handlers Define script.on_event(role_change_event_id,function(event) - -- varible init + -- variable init local player = Game.get_player(event) local by_player = Game.get_player(event.by_player_index) or SERVER - local role = Role.get(event.role_name) + local role = Role.get(event.role_name) local highest = Role.get_highest(player) if not highest then Role.meta.default:add_player(player) highest = Role.meta.default end - -- gets the falgs the player currently has + -- gets the flags the player currently has for flag,callback in pairs(Role.flags) do if is_type(callback,'function') then callback(player,Role.has_flag(player,flag)) end end -- assign new tag and group of highest role Group.assign(player,highest.group) @@ -463,7 +478,7 @@ script.on_event(role_change_event_id,function(event) -- send a message to other players if event.batch_index == 1 then local names = {} - for _,name in pairs(event.batch) do local role = Role.get(name) if role then table.insert(names,role.name) end end + for _,name in pairs(event.batch) do local next_role = Role.get(name) if next_role then table.insert(names,next_role.name) end end if event.effect == 'assign' then if not role.is_jail then player.play_sound{path='utility/achievement_unlocked'} end game.print{'ExpGamingCore-Role.default-print',{'ExpGamingCore-Role.assign',player.name,table.concat(names,', '),by_player.name}} @@ -511,4 +526,4 @@ end) -- Module Return -- calling will attempt to define a new role -return setmetatable(Role,{__call=function(tbl,...) tbl.define(...) end}) \ No newline at end of file +return setmetatable(Role,{__call=function(tbl,...) return tbl.define(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingCore/Role/softmod.json b/modules/ExpGamingCore/Role/softmod.json index 05670027..3af9da54 100644 --- a/modules/ExpGamingCore/Role/softmod.json +++ b/modules/ExpGamingCore/Role/softmod.json @@ -1,23 +1,24 @@ { - "name": "Role", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds roles where a player can have more than one role", - "location": "", - "keywords": [ - "Role", - "Ranks", - "Permissions", - "Alowed", - "Admin" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Group": "^4.0.0", - "ExpGamingCore.Server": "?^4.0.0", - "ExpGamingCore.Command": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCore.Role", + "version": "4.0.0", + "description": "Adds roles where a player can have more than one role", + "location": "FSM_ARCHIVE", + "keywords": [ + "Role", + "Ranks", + "Permissions", + "Alowed", + "Admin" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "FactorioStdLib.Table": "^0.8.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Group": "^4.0.0", + "ExpGamingCore.Server": "?^4.0.0", + "ExpGamingCore.Command": "?^4.0.0", + "ExpGamingCore.Sync": "?^4.0.0" + }, + "collection": "ExpGamingCore@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCore/Role/src/commands.lua b/modules/ExpGamingCore/Role/src/commands.lua index 158b32b8..612a781a 100644 --- a/modules/ExpGamingCore/Role/src/commands.lua +++ b/modules/ExpGamingCore/Role/src/commands.lua @@ -3,7 +3,7 @@ local Role = self commands.add_validation('player-rank',function(value,event) local player,err = commands.validate['player'](value) if err then return commands.error(err) end - local rtn = Role.get_highest(player).index > Role.get_highest(event).index and player or nil + local rtn = Role.get_highest(player).index > Role.get_highest(event).index and player or player.index == event.player_index and player or nil if not rtn then return commands.error{'ExpGamingCore_Command.error-player-rank'} end return rtn end) diff --git a/modules/ExpGamingCore/Role/src/sync.lua b/modules/ExpGamingCore/Role/src/sync.lua index 88c79058..36f0fdbe 100644 --- a/modules/ExpGamingCore/Role/src/sync.lua +++ b/modules/ExpGamingCore/Role/src/sync.lua @@ -1,8 +1,8 @@ local Role = self local RoleGlobal = RoleGlobal -local Sync = require('ExpGamingCore.Sync@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') -local Color = require('FactorioStdLib.Color@^0.8.0') +local Sync = require('ExpGamingCore.Sync') +local Game = require('FactorioStdLib.Game') +local Color = require('FactorioStdLib.Color') -- just to hard reset the role sync function Sync.set_roles(...) @@ -10,30 +10,40 @@ function Sync.set_roles(...) end -- used to assign the role if the player is online, or add to the the preassign -function Sync.assign_role(player_name,role_name,by_player_name) +function Sync.assign_role(player_name,roles,by_player_name) if not game then return end local preassign = RoleGlobal.preassign local player_roles = preassign[player_name] - if not player_roles then preassign[player_name] = {role_name} return end - if not table.includes(player_roles,role_name) then table.insert(player_roles,role_name) end - if Game.get_player(player_name) then Role.assign(player_name,role_name,by_player_name) end + if Game.get_player(player_name) then Role.assign(player_name,roles,by_player_name) + else + if not is_type(roles,'table') then roles = {roles} end + if not player_roles then preassign[player_name] = roles return end + for _,role_name in pairs(roles) do + if not table.includes(player_roles,role_name) then table.insert(player_roles,role_name) end + end + end end -- used to unassign the role if the player is online, or removes the preassign -function Sync.unassign_role(player_name,role_name,by_player_name) +function Sync.unassign_role(player_name,roles,by_player_name) if not game then return end local preassign = RoleGlobal.preassign local player_roles = preassign[player_name] - if not player_roles then preassign[player_name] = {} return end - local index = table.index(player_roles,role_name) - table.remove(player_roles,index) - if Game.get_player(player_name) then Role.unassign(player_name,role_name,by_player_name) end + if Game.get_player(player_name) then Role.unassign(player_name,roles,by_player_name) + else + if not is_type(roles,'table') then roles = {roles} end + if not player_roles then preassign[player_name] = nil return end + for _,role_name in pairs(roles) do + local index = table.index(player_roles,role_name) + if index then table.remove(player_roles,index) end + end + end end Sync.add_update('roles',function() if not game then return {'Offline'} end local _rtn = {} - for name,role in pairs(Role.roles) do + for _,role in pairs(Role.roles) do local players = role:get_players() local _players = {} for k,player in pairs(players) do _players[k] = player.name end @@ -47,20 +57,20 @@ end) -- Adds a caption to the info gui that shows the rank given to the player if Sync.add_to_gui then - Sync.add_to_gui(function(player,frame) + Sync.add_to_gui(function(player) local names = {} for _,role in pairs(Role.get(player)) do table.insert(names,role.name) end return 'You have been assigned the roles: '..table.concat(names,', ') end) end --- adds a discord emit for rank chaning +-- adds a discord emit for rank changing script.on_event('on_role_change',function(event) local role = Role.get(event.role_name) local player = Game.get_player(event) local by_player = Game.get_player(event.by_player_index) or SERVER if role.is_jail and RoleGlobal.last_change[1] ~= player.index then - Sync.emit_embeded{ + Sync.emit_embedded{ title='Player Jail', color=Color.to_hex(defines.textcolor.med), description='There was a player jailed.', diff --git a/modules/ExpGamingCore/Server/control.lua b/modules/ExpGamingCore/Server/control.lua index 7ed86cd4..82f0ec68 100644 --- a/modules/ExpGamingCore/Server/control.lua +++ b/modules/ExpGamingCore/Server/control.lua @@ -17,7 +17,7 @@ local module_verbose = false --true|false -- @field tick an index for threads which will run every tick (contains uuids) -- @field timeout an index for threads which will timeout (contains uuids) -- @field events an index of threads based on event ids (contains uuids) --- @field paused an index of pasued threads (contains uuids) +-- @field paused an index of paused threads (contains uuids) -- @field named a name index for thread uuids -- @field print_to contains players that event details will be printed to -- @field uuid contains the random number generator for the uuid system @@ -39,7 +39,7 @@ local global = global{ -- @treturn string the new uuid Server.uuid = add_metatable({},function() -- when it is called as a function - local uuid = 0 + local uuid if game then global.uuid=global.uuid+1 uuid=global.uuid+pre_load_uuid @@ -68,8 +68,8 @@ Server.threads = setmetatable({},{ __newindex=function(tbl,key,value) rawset(global.all,key,value) end, __pairs=function(tbl) local tbl = global.all - local function next_pair(tbl,k) - k, v = next(tbl, k) + local function next_pair(tbl,key) + local k, v = next(tbl, key) if type(v) ~= nil and k ~= '_n' then return k,v else return next(tbl, k) end end @@ -79,15 +79,15 @@ Server.threads = setmetatable({},{ --- Generates a new thread object -- @usage Server.new_thread{name='foo',data={}} --- @tparam table obj the atributes to give to the thread +-- @tparam table obj the attributes to give to the thread -- @treturn Server._thread the new thread created function Server.new_thread(obj) return Server._thread:create(obj) end ---- Used to get a thread via uuid or name (if one is assied) +--- Used to get a thread via uuid or name (if one is assigned) -- @usage Server.get_thread('decon') -- return thread -- @param mixed either a uuid or the name given to a thread -- @treturn[1] Server._thread the thread by that name or uuid --- @treturn[2] boolean if false is returned then no thread existes +-- @treturn[2] boolean if false is returned then no thread exists function Server.get_thread(mixed) local threads = global if threads.named[mixed] then return threads.all[threads.named[mixed]] @@ -99,7 +99,7 @@ end --- Adds a thread into the resolve queue, can be used to lower lag -- @usage Server.queue_thread(thread) -- return true/false -- @tparam Server._thread thread_to_queue the thread to be added to the queue, must be open and have a on_resolve function --- @treturn boolean was it added successfuly +-- @treturn boolean was it added successfully function Server.queue_thread(thread_to_queue) if not thread_to_queue and not thread_to_queue.valid and not thread_to_queue:valid() then return false end if not thread_to_queue._resolve then return false end @@ -109,21 +109,21 @@ end --- Closes all active threads, can use force if it causes errors -- @usage Server.close_all_threads() -- asks all threads to close --- @usage Server.close_all_threads(true) -- forcefuly close all threads --- @tparam bolean with_force use force when closing +-- @usage Server.close_all_threads(true) -- forcefully close all threads +-- @tparam boolean with_force use force when closing function Server.close_all_threads(with_force) if not with_force then for uuid,thread in pairs(Server.threads) do thread:close() end - else global.Server(true) end -- idk why you cant just use global even when global is defined at the top to be over ridren + else global.Server(true) end -- idk why you cant just use global even when global is defined at the top to be overridden end ---- Runs all the theads which have opened with an on_tick event +--- Runs all the threads which have opened with an on_tick event -- @usage Server.run_tick_threads() function Server.run_tick_threads() table.each(global.tick,function(uuid) local next_thread = Server.get_thread(uuid) if next_thread and next_thread:valid() and next_thread._tick then - local success, err = pcall(next_thread._tick,next_thread) + local success, err = Manager.sandbox(next_thread._tick,next_thread._env,next_thread) if not success then next_thread:error(err) end end end) @@ -146,8 +146,8 @@ end -- @tparam ?name|index event the event that info will be returned fo -- @tparam[opt=toggle] boolean state will info be returned, nil to toggle current state function Server._thread_debuger(player,event,state) - local player = Game.get_player(player) - local event = tonumber(event) or Manager.event.names[event] + player = Game.get_player(player) + event = tonumber(event) or Manager.event.names[event] local print_to = global.print_to print_to[player.index] = print_to[player.index] or {} if state then print_to[player.index][event] = state @@ -155,12 +155,12 @@ function Server._thread_debuger(player,event,state) else print_to[player.index][event] = true end end ---- Calles all threads on a certain game event (used with script.on_event) +--- Calls all threads on a certain game event (used with script.on_event) -- @local Server._thread_handler -- @usage script.on_event(defines.events,Server._thread_handler) -- adds this handler -- @tparam table event the event that is called function Server._thread_handler(event) - -- returns to players who have set _thread_debuger to trye + -- returns to players who have set _thread_debuger to true table.each(global.print_to,function(print_to,player_index,event) if event.name == defines.events.on_tick then return true end if print_to[event.name] then @@ -189,7 +189,7 @@ end --- Adds a event handler to tell threads about events -- @usage Server.add_thread_handler(defines.event) -- @tparam number event the event to run the thread handler on` --- @treturn bolean if the handler was added +-- @treturn boolean if the handler was added function Server.add_thread_handler(event) if not is_type(event,'number') then return false end local threads = global @@ -204,9 +204,9 @@ end --- Acts as a bypass for running functions, can accept a string -- @usage Server.interface('local x = 1+1 print(x) return x') -- return 2 --- @usage Server.interface('local x = 1+1 print(x)',true) -- will creat a thread to run as root (this is the bypass) +-- @usage Server.interface('local x = 1+1 print(x)',true) -- will create a thread to run as root (this is the bypass) -- @tparam ?string|function callback function to be ran --- @tparam[opt] ?Server._thread|true use_thread run the command on a premade thread or let it make its own +-- @tparam[opt] ?Server._thread|true use_thread run the command on a pre-made thread or let it make its own -- @tparam[opt] table env run the env to run the command in must have _env key as true to be -- @param[opt] ... any args you want to pass to the function -- @treturn[1] boolean if no thread then it will return a true for the success @@ -219,15 +219,15 @@ function Server.interface(callback,use_thread,env,...) if use_thread == true then use_thread = Server.new_thread{data={callback,env,...}} end -- creates the resolve function for the thread use_thread:on_event('resolve',function(thread) - local callback = table.remove(thread.data,1) - callback = is_type(callback,'function') and callback or loadstring(callback) - local env = table.remove(thread.data,1) - if is_type(env,'table') and env._env == true then - local success, err = Manager.sandbox(callback,env,unpack(thread.data)) + local thread_callback = table.remove(thread.data,1) + thread_callback = is_type(thread_callback,'function') and thread_callback or loadstring(thread_callback) + local thread_env = table.remove(thread.data,1) + if is_type(thread_env,'table') and not is_type(thread_env.__self,'userdata') and thread_env._env == true then + local success, err = Manager.sandbox(thread_callback,thread_env,unpack(thread.data)) if not success then error(err) end return err else - local success, err = Manager.sandbox(callback,{},env,unpack(thread.data)) + local success, err = Manager.sandbox(thread_callback,{},env,unpack(thread.data)) if not success then error(err) end return err end @@ -242,7 +242,7 @@ function Server.interface(callback,use_thread,env,...) if err then return false, err end _callback = rtn end - if is_type(env,'table') and env._env == true then + if is_type(env,'table') and not is_type(env.__self,'userdata') and env._env == true then local success, err = Manager.sandbox(_callback,env,...) if not success then return success,err else return success, unpack(err) end @@ -254,13 +254,13 @@ function Server.interface(callback,use_thread,env,...) end end ---- The class for the server threads, allows abbilty to run async function +--- The class for the server threads, allows ability to run async function -- @type Thread -- @alias Server._thread -- @field name the name that is given to the thread, use for easy later indexing -- @field timeout the time in ticks that the thread will have before it times out --- @field reopen when true the thread will reopen itself untill set to false, combine with timeout to create a long on_nth_tick wait --- @field data any data that the thread will beable to access +-- @field reopen when true the thread will reopen itself until set to false, combine with timeout to create a long on_nth_tick wait +-- @field data any data that the thread will be able to access Server._thread = {} local _env_metatable = { @@ -271,38 +271,38 @@ local _env_metatable = { -- @usage new_thread = thread:create() -- @tparam[opt={}] table obj all values are opt {timeout=int,name=str,data=any} -- @treturn Server._thread the new thread object -function Server._thread:create(obj) - local obj = obj or {} +function Server._thread.create(obj) + obj = obj or {} setmetatable(obj,{__index=Server._thread}) obj.uuid = tostring(Server.uuid) - -- creates a varible containg all upvalus for the thread (stops desyncs) + -- creates a variable containing all upvalus for the thread (stops desyncs) obj._env = get_upvalues(2) obj._env._env = true - obj._env._ENV = nil -- provents infinte recusion - -- removes any modules from the _env to save space in global (less time to serizle) + obj._env._ENV = nil -- prevents infinite recursion + -- removes any modules from the _env to save space in global (less time to serialize) obj._env._modules = {} - for name,value in pairs(obj._env) do if is_type(value,'table') and value._module_name and loaded_modules[value._module_name] == value then obj._env._modules[name] = value._module_name obj._env[name] = nil end end + for name,value in pairs(obj._env) do if is_type(value,'table') and value._moduleName and loaded_modules[value._moduleName] == value then obj._env._modules[name] = value._moduleName obj._env[name] = nil end end setmetatable(obj._env,_env_metatable) local name = obj.name or 'Anon' verbose('Created new thread: '..name..' ('..obj.uuid..')') return obj end ---- Opens and queses a thread +--- Opens and queues a thread -- @usage Server._thread:queue() -- returns true/false --- @treturn boolean was the thread queued successfuly +-- @treturn boolean was the thread queued successfully -- @see Server.queue_thread function Server._thread:queue() self:open() return Server.queue_thread(self) end ---- Test if the thread has all requied parts +--- Test if the thread has all required parts -- @usage if thread:valid() then end -- basic test for valid --- @tparam[opt=false] bolean skip_location_check true to skip the location checking +-- @tparam[opt=false] boolean skip_location_check true to skip the location checking -- @treturn boolean is the thread valid function Server._thread:valid(skip_location_check) - local skip_location_check = skip_location_check or false + skip_location_check = skip_location_check or false if is_type(self.uuid,'string') and skip_location_check or is_type(self.opened,'number') and skip_location_check or is_type(global.all[self.uuid],'table') and @@ -314,34 +314,34 @@ function Server._thread:valid(skip_location_check) is_type(self._resolve) or is_type(self._resolve,'function') and is_type(self._success) or is_type(self._success,'function') and is_type(self._error) or is_type(self._error,'function') then - -- all above must be true to be vaild, must accept nil and function + -- all above must be true to be valid, must accept nil and function return true end return false end ---- Opens the thread; indexs this thread in the global index +--- Opens the thread; indexes this thread in the global index -- @usage thread:open() -- return true --- @treturn bolean if the thread was opened successfuly +-- @treturn boolean if the thread was opened successfully function Server._thread:open() - -- if the thread is valid and not already opended + -- if the thread is valid and not already opened if not self:valid(true) or self.opened then return false end local uuid = self.uuid -- sets the thread to open, this is the tick it was opened self.opened = game.tick - -- creats the global index + -- creates the global index global.all[uuid] = global.all[uuid] or self global.all._n = global.all._n+1 - -- indexs the thread in other places if it has more function + -- indexes the thread in other places if it has more function -- if it was paused before (ie did not run any events) then the index is removed from the paused index if global.paused[self.name] then global.paused[self.name] = nil end - -- if it has a timeout or on_tick handler then it is indexed in those indexs + -- if it has a timeout or on_tick handler then it is indexed in those indexes if is_type(self.timeout,'number') then table.insert(global.timeout,uuid) end if is_type(self._tick,'function') then table.insert(global.tick,uuid) end -- if the thread is given a name then a index from the name to uuid is made if is_type(self.name,'string') then global.named[self.name] = global.named[self.name] or self.uuid end -- if there are event handlers then it will loop over them and add them to the event index - if is_type(self._events,'table') then + if is_type(self._events,'table') then table.each(self._events,function(callback,event,global,uuid) -- cant be used V --Server.add_thread_handler(event) @@ -354,26 +354,26 @@ function Server._thread:open() return true end ---- Inverse of thread:open() - Removes all indexs to this thread, most cases this will cause it to become inassible +--- Inverse of thread:open() - Removes all indexes to this thread, most cases this will cause it to become inaccessible -- @usage thread:close() -- return true -- @treturn boolean if the thread had a on_close function function Server._thread:close() local uuid = self.uuid local _return = false -- if there is a call to the threads on close event, will later return true - if is_type(self._close,'function') then pcall(self._close,self) _return = true end + if is_type(self._close,'function') then Manager.sandbox(self._close,self._env,self) _return = true end -- will search every possible location for this thread and remove it - local value,key = table.find(global.queue,function(v,k,uuid) return v == uuid end,uuid) + local _,key = table.find(global.queue,function(v,k,uuid) return v == uuid end,uuid) if key then table.remove(global.queue,key) end -- queue - local value,key = table.find(global.timeout,function(v,k,uuid) return v == uuid end,uuid) + _,key = table.find(global.timeout,function(v,k,uuid) return v == uuid end,uuid) if key then table.remove(global.timeout,key) end -- timeouts - local value,key = table.find(global.tick,function(v,k,uuid) return v == uuid end,uuid) + _,key = table.find(global.tick,function(v,k,uuid) return v == uuid end,uuid) if key then table.remove(global.tick,key) end -- on_tick -- then will look for it in the event handlers and remove it if found if is_type(self._events,'table') then table.each(self._events,function(callback,event) if global.events[event] then - local value,key = table.find(global.events[event],function(v,k,uuid) return v == uuid end,uuid) + local _,key = table.find(global.events[event],function(v,k,uuid) return v == uuid end,uuid) if key then table.remove(global.events[event],key) end -- cant be used V --if #global.events[event] == 0 then Event.remove(event,Server.game_event) global.events[event] = nil end @@ -382,9 +382,9 @@ function Server._thread:close() end -- sets the thread to closed self.opened=nil - -- unless the thread has a name or is assied to be reopened + -- unless the thread has a name or is assigned to be reopened if self.reopen == true then self:open() else - -- if it has a name but not assied to reopen then it will become 'pasued' + -- if it has a name but not assigned to reopen then it will become 'paused' if is_type(self.name,'string') then global.paused[self.name]=self.uuid -- else it will just be wiped from the global index else global.all[uuid] = nil global.all._n = global.all._n-1 end @@ -397,19 +397,19 @@ end --- Trigger the on_resolve function and closes the thread - error and success called based on result of pcall (useful for async) -- @usage thread:resolve(x,y,z) -- return true -- @param[opt] ... any arguments you want to pass to the resolve function --- @treturn bolean true if the thread called on_success or on_error +-- @treturn boolean true if the thread called on_success or on_error function Server._thread:resolve(...) local _return = false - -- checks if the resolve haddler is still present - if is_type(self._resolve,'function') then + -- checks if the resolve handler is still present + if is_type(self._resolve,'function') then local success, err = Manager.sandbox(self._resolve,self._env,self,...) if success then - -- if it was successful then it will attemp to call the success handler + -- if it was successful then it will attempt to call the success handler if is_type(self._success,'function') then -- interface is used as a way to delay the success call till the next tick Server.interface(function(thread,err) - local success, err = Manager.sandbox(thread._success,thread._env,thread,err) - if not success then thread:error(err) end + local _success, _err = Manager.sandbox(thread._success,thread._env,thread,err) + if not _success then thread:error(_err) end end,true,self,err) -- later returns true if there was a call to the success handler _return = true @@ -422,9 +422,9 @@ function Server._thread:resolve(...) return _return end ---- Checks the timeout on a thread - if timed out then it calles on_timeout and closes +--- Checks the timeout on a thread - if timed out then it calls on_timeout and closes -- @usage thread:check_timeout() -- return true --- @treturn bolean if the thread timed out +-- @treturn boolean if the thread timed out function Server._thread:check_timeout() local _return = false -- makes sure the thread is still valid @@ -436,7 +436,7 @@ function Server._thread:check_timeout() Manager.sandbox(self._timeout,self._env,self) end _return = true - -- closes the thread to provent any further event calls + -- closes the thread to prevent any further event calls self:close() end return _return @@ -444,18 +444,21 @@ end --- Used to check and raise the error handler of the thread, if not present it raises an error -- @usage thread:error(err) -- return true --- @tparam string err the err to be rasied +-- @tparam string err the err to be raised -- @treturn boolean did the thread have an error handler function Server._thread:error(err) local _return = false if is_type(self._error,'function') then - pcall(self._error,self,err) + Manager.sandbox(self._error,self._env,self,err) _return = true - else error(err) end + else + self:close() -- no matter what happens next this thread will be closed + error('Thread Error (no handler): '..err) + end return _return end ---- Set function to run then an event is triggered, none of them are 'needed' but you are advised to have atleast one +--- Set function to run then an event is triggered, none of them are 'needed' but you are advised to have at least one -- @usage thread:on_event('close',function) -- if event is not one below then a game event is used -- @usage thread_only_events = ['close','timeout','tick','resolve','success','error'] -- @tparam ?string|index event the name of the event that the function should be called on @@ -463,7 +466,7 @@ end -- @treturn table returns self so that they can be chained together function Server._thread:on_event(event,callback) local events = {'close','timeout','tick','resolve','success','error'} - -- seaches the above list for the event + -- searches the above list for the event local value = table.find(events,function(v,k,find) return v == string.lower(find) end,event) if value and is_type(callback,'function') then -- if it is a thread_only_event then it will add it to its core values @@ -489,7 +492,7 @@ script.on_event(defines.events.on_tick,function(event) end) script.on_load(function(event) - -- sets up metatable again so that threads contiune to work + -- sets up metatable again so that threads continue to work for uuid,thread in pairs(Server.threads) do setmetatable(thread,{__index=Server._thread}) setmetatable(thread._env,_env_metatable) @@ -532,7 +535,7 @@ return Server end) thread:open() - all on_event functions can be chained from the thread creation rather than use varibles eg: + all on_event functions can be chained from the thread creation rather than use variables eg: Server.new_thread{ name='tree-decon', data={} diff --git a/modules/ExpGamingCore/Server/softmod.json b/modules/ExpGamingCore/Server/softmod.json index 1e9e4c34..7c0ef190 100644 --- a/modules/ExpGamingCore/Server/softmod.json +++ b/modules/ExpGamingCore/Server/softmod.json @@ -1,26 +1,26 @@ { - "name": "Server", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a thread system and event listening and a admin bypass (recommend to disable /c and use optional /interface)", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Server_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core", - "Server", - "Thread", - "Interface", - "Events" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.String": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Command": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCore.Server", + "version": "4.0.0", + "description": "Adds a thread system and event listening and a admin bypass (recommend to disable /c and use optional /interface)", + "location": "FSM_ARCHIVE", + "keywords": [ + "Library", + "Lib", + "ExpGaming", + "Core", + "Server", + "Thread", + "Interface", + "Events" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "FactorioStdLib.Table": "^0.8.0", + "FactorioStdLib.Color": "^0.8.0", + "FactorioStdLib.String": "^0.8.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Command": "?^4.0.0" + }, + "collection": "ExpGamingCore@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCore/Server/src/commands.lua b/modules/ExpGamingCore/Server/src/commands.lua index 4188454c..4a0abf28 100644 --- a/modules/ExpGamingCore/Server/src/commands.lua +++ b/modules/ExpGamingCore/Server/src/commands.lua @@ -7,14 +7,13 @@ --- This file will be loaded when ExpGamingCore.Command is present -- @function _comment -local Game = require('FactorioStdLib.Game') local Server = Server Server.interfaceCallbacks = {} function Server.add_to_interface(loadAs,callback) Server.interfaceCallbacks[loadAs] = callback end -function Server.add_module_to_interface(loadAs,moduleName,version) - local moduleName = _G.moduleName or version and moduleName..'@'..version or moduleName or nil +function Server.add_module_to_interface(loadAs,moduleName) + local moduleName = moduleName or tostring(_G.moduleName) or nil if not moduleName then error('No module name supplied for: '..loadAs,2) return end Server.add_to_interface(loadAs,function() return require(moduleName) end) end @@ -40,7 +39,7 @@ commands.add_command('interface','Runs the given input from the script', { env.tile = game.player.surface.get_tile(game.player.position) end -- adds custom callbacks to the interface - for name,callback in pairs(Server.interfaceCallbacks) do env[name] = callback() end + for name,custom_callback in pairs(Server.interfaceCallbacks) do env[name] = custom_callback() end -- runs the function local success, err = Server.interface(callback,false,env) -- if there is an error then it will remove the stacktrace and return the error diff --git a/modules/ExpGamingCore/Sync/control.lua b/modules/ExpGamingCore/Sync/control.lua index 77ef7618..bfd91b43 100644 --- a/modules/ExpGamingCore/Sync/control.lua +++ b/modules/ExpGamingCore/Sync/control.lua @@ -1,11 +1,11 @@ ---- Allows syncing with an outside server and info panle. +--- Allows syncing with an outside server and info panel. -- @module ExpGamingCore.Sync -- @alias Sync -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^0.8.0') -local Color = require('FactorioStdLib.Color@^0.8.0') +local Game = require('FactorioStdLib.Game') +local Color = require('FactorioStdLib.Color') local Sync = {} local Sync_updates = {} @@ -16,10 +16,10 @@ local module_verbose = false --true|false -- @field server_name the server name -- @field server_description a short description of the server -- @field reset_time the reset time of the server --- @field time the last knowen irl time +-- @field time the last known irl time -- @field time_set the last in game time that the time was set -- @field last_update the last time that this info was updated --- @field time_period how often this infomation is updated +-- @field time_period how often this information is updated -- @field players a list of different player related states -- @field ranks a list of player ranks -- @field rockets the number of rockets launched @@ -35,15 +35,15 @@ local global = global{ time_period={18000,'5.00M'}, game_speed=1.0, players={ - online={'Offline'}, + online={}, n_online=0, - all={'Offline'}, + all={}, n_all=0, admins_online=0, afk_players={}, - times={'Offline'} + times={} }, - ranks={'Offline'}, + roles={admin={online={},players={},n_online=0,n_players=0},user={online={},players={},n_online=0,n_players=0}}, rockets=0, mods={'Offline'} } @@ -58,9 +58,9 @@ local global = global{ -- @field afk_players the number of afk players -- @field times the play times of every player ---- Used to standidise the tick format for any sync info +--- Used to standardise the tick format for any sync info -- @usage Sync.tick_format(60) -- return {60,'1.00M'} --- @treturn {number,string} table containg both the raw number and clean version of a time +-- @treturn {number,string} table containing both the raw number and clean version of a time function Sync.tick_format(tick) if not is_type(tick,'number') then error('Tick was not given to Sync.tick_format',2) end return {tick,tick_to_display_format(tick)} @@ -70,7 +70,7 @@ end -- @usage Sync.print('Test','Cooldude2606') -- @tparam string player_message the message to be printed in chat -- @tparam string player_name the name of the player sending the message --- @tparam[opt] string player_tag the tag apllied to the player's name +-- @tparam[opt] string player_tag the tag applied to the player's name -- @tparam[opt] string player_colour the colour of the message, either hex or named colour -- @tparam[opt] string prefix add a prefix before the chat eg [IRC] function Sync.print(player_message,player_name,player_tag,player_colour,prefix) @@ -78,8 +78,8 @@ function Sync.print(player_message,player_name,player_tag,player_colour,prefix) local player = game.player or game.players[player_name] local tag = player_tag and player_tag ~= '' and ' '..player_tag or '' local colour = type(player_colour) == 'string' and player_colour or '#FFFFFF' - local prefix = prefix and prefix..' ' or '' - -- if it is an ingame player it will over ride the given params + prefix = prefix and prefix..' ' or '' + -- if it is an in game player it will over ride the given params if player then tag = ' '..player.tag colour = player.chat_color @@ -92,7 +92,7 @@ function Sync.print(player_message,player_name,player_tag,player_colour,prefix) game.print(prefix..player_name..tag..': '..player_message,colour) end ---- Outline of the paramaters accepted by Sync.emit_embeded +--- Outline of the parameters accepted by Sync.emit_embedded -- @table EmitEmbededParamaters -- @field title the tile of the embed -- @field color the color given in hex you can use Color.to_hex{r=0,g=0,b=0} @@ -102,11 +102,11 @@ end -- @field fieldtwo the filed to add to the embed (key is name) (value is text) (start value with <<inline>> to make inline) --- Logs an embed to the json.data we use a js script to add things we cant here --- @usage Sync.emit_embeded{title='BAN',color='0x0',description='A player was banned' ... } --- @tparam table args a table which contains everything that the embeded will use +-- @usage Sync.emit_embedded{title='BAN',color='0x0',description='A player was banned' ... } +-- @tparam table args a table which contains everything that the embedded will use -- @see EmitEmbededParamaters -function Sync.emit_embeded(args) - if not is_type(args,'table') then error('Args table not given to Sync.emit_embeded',2) end +function Sync.emit_embedded(args) + if not is_type(args,'table') then error('Args table not given to Sync.emit_embedded',2) end if not game then error('Game has not loaded',2) end local title = is_type(args.title,'string') and args.title or '' local color = is_type(args.color,'string') and args.color:find("0x") and args.color or '0x0' @@ -116,7 +116,7 @@ function Sync.emit_embeded(args) -- creates the first field given for every emit local done, fields = {title=true,color=true,description=true,server_detail=true}, {{ name='Server Details', - value='Server Name: {{ serverName }} Online Players: '..#game.connected_players..' '..mods_online..' Server Time: '..tick_to_display_format(game.tick)..' '..server_detail + value='Server Name: ${serverName} Online Players: '..#game.connected_players..' '..mods_online..' Server Time: '..tick_to_display_format(game.tick)..' '..server_detail }} -- for each value given in args it will create a new field for the embed for key, value in pairs(args) do @@ -130,14 +130,14 @@ function Sync.emit_embeded(args) table.insert(fields,f) end end - -- forms the data that will be emited to the file + -- forms the data that will be emitted to the file local log_data = { title=title, description=description, color=color, fields=fields } - game.write_file('embeded.json',table.json(log_data)..'\n',true,0) + game.write_file('embedded.json',table.json(log_data)..'\n',true,0) end --- The error handle setup by sync to emit a discord embed for any errors @@ -147,7 +147,7 @@ end error.addHandler('Discord Emit',function(err) if not game then return error(error()) end local color = Color and Color.to_hex(defines.textcolor.bg) or '0x0' - Sync.emit_embeded{title='SCRIPT ERROR',color=color,description='There was an error in the script @Developers ',Error=err} + Sync.emit_embedded{title='SCRIPT ERROR',color=color,description='There was an error in the script @Developers ',Error=err} end) --- Used to get the number of admins currently online @@ -169,7 +169,7 @@ end -- @treturn number the number of afk players function Sync.count_afk_times(time) if not game then return 0 end - local time = time or 7200 + time = time or 7200 local rtn = {} for _,player in pairs(game.connected_players) do if player.afk_time > time then rtn[player.name] = Sync.tick_format(player.afk_time) end @@ -234,6 +234,23 @@ Sync.info = setmetatable({},{ if not is_type(set,'table') then return false end for key,value in pairs(set) do global[key] = value end return true + end, + __pairs=function(tbl) + tbl = global + local function next_pair(tbl,key) + local k, v = next(tbl, key) + if type(v) ~= nil then return k,v end + end + return next_pair, tbl, nil + end, + __ipairs=function(tbl) + tbl = global + local function next_pair(tbl, i) + i = i + 1 + local v = tbl[i] + if v then return i, v end + end + return next_pair, tbl, 0 end }) @@ -255,7 +272,7 @@ function Sync.update() afk_players=Sync.count_afk_times(), times=Sync.count_player_times() } - info.ranks = Sync.count_roles() + info.roles = Sync.count_roles() info.rockets = game.forces['player'].get_item_launched('satellite') for key,callback in pairs(Sync_updates) do info[key] = callback() end return info @@ -288,7 +305,7 @@ end -- @usage Sync.time('Sun Apr 1 18:44:30 UTC 2018') -- @usage Sync.time -- string -- @tparam[opt=nil] string set the date time to be set --- @treturn boolean if the datetime set was successful +-- @treturn boolean if the date time set was successful Sync.time=add_metatable({},function(full,date) local info = Sync.info if not is_type(full,'string') then return false end @@ -309,8 +326,8 @@ script.on_event('on_pre_player_left_game',Sync.emit_update) script.on_event('on_rocket_launched',Sync.emit_update) function Sync:on_init() - if loaded_modules['ExpGamingCore.Gui@^4.0.0'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync,module_path=module_path}) end - if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Sync','ExpGamingCore.Sync') end + if loaded_modules['ExpGamingCore.Gui'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync,module_path=module_path}) end + if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server').add_module_to_interface('Sync','ExpGamingCore.Sync') end end function Sync:on_post() diff --git a/modules/ExpGamingCore/Sync/softmod.json b/modules/ExpGamingCore/Sync/softmod.json index 005a54ba..c86e56dd 100644 --- a/modules/ExpGamingCore/Sync/softmod.json +++ b/modules/ExpGamingCore/Sync/softmod.json @@ -1,26 +1,27 @@ { - "name": "Sync", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows syncing with an outside server and info panle.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Sync_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core", - "Info", - "Sync", - "External", - "Discord" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Table": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Gui": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" -} \ No newline at end of file + "name": "ExpGamingCore.Sync", + "version": "4.0.0", + "description": "Allows syncing with an outside server and info panle.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Library", + "Lib", + "ExpGaming", + "Core", + "Info", + "Sync", + "External", + "Discord" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "FactorioStdLib.Color": "^0.8.0", + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Table": "^0.8.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Gui": "?^4.0.0", + "ExpGamingCore.Server": "?^4.0.0" + }, + "collection": "ExpGamingCore@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingCore/Sync/src/gui.lua b/modules/ExpGamingCore/Sync/src/gui.lua index a7c8408d..f01ebf2a 100644 --- a/modules/ExpGamingCore/Sync/src/gui.lua +++ b/modules/ExpGamingCore/Sync/src/gui.lua @@ -1,4 +1,4 @@ ---- Allows syncing with an outside server and info panle. +--- Allows syncing with an outside server and info panel. -- @submodule ExpGamingCore.Sync -- @alias Sync -- @author Cooldude2606 @@ -7,17 +7,16 @@ --- This file will be loaded when ExpGamingCore.Gui is present -- @function _comment -local Game = require('FactorioStdLib.Game@^0.8.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Gui = require('ExpGamingCore.Gui') local Sync = Sync -- this is to force sync to remain in the ENV local Sync_gui_functions = {} local logo_sprite_path = 'file'..string.sub(module_path,2)..'/src/logo.png' ---- Adds a emeltent to the sever info gui +--- Adds a element to the sever info gui -- @usage Sync.add_to_gui('string') -- return true -- @param element see examples before for what can be used, it can also be a return from Gui.inputs.add --- @treturn bolean based on weather it was successful or not +-- @treturn boolean based on weather it was successful or not function Sync.add_to_gui(element,...) if game then return false end if is_type(element,'function') then @@ -29,10 +28,10 @@ function Sync.add_to_gui(element,...) return true end -Sync.add_to_gui('Welcome to the Explosive Gaming comunity! This is one of many servers which we host.') +Sync.add_to_gui('Welcome to the Explosive Gaming community! This is one of many servers which we host.') Sync.add_to_gui(function(player,frame) return 'This server\'s next reset: '..Sync.info.reset_time end) ---- Formats a lable to be a certain format +--- Formats a label to be a certain format -- @local label_format local function label_format(label,width) label.style.width = width @@ -49,7 +48,7 @@ Sync.info_gui = Gui.center{ draw=function(self,frame) frame.caption = '' local info = Sync.info - local frame = frame.add{type='flow',direction='vertical'} + frame = frame.add{type='flow',direction='vertical'} local h_flow = frame.add{type='flow'} h_flow.add{type='sprite',sprite=logo_sprite_path} local v_flow = h_flow.add{type='flow',direction='vertical'} @@ -68,7 +67,7 @@ Sync.info_gui = Gui.center{ Gui.bar(_flow,110) Gui.bar(frame,600) local _frame = frame - local frame = frame.add{ + frame = frame.add{ type='frame', direction='vertical', style='image_frame' diff --git a/modules/ExpGamingCore/softmod.json b/modules/ExpGamingCore/softmod.json index ddfefb01..4b2715eb 100644 --- a/modules/ExpGamingCore/softmod.json +++ b/modules/ExpGamingCore/softmod.json @@ -1,159 +1,24 @@ { - "name": "ExpGamingCore", - "version": "4.0.0", - "type": "Collection", - "description": "Explosive Gaming Core Files", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "submodules": { - "Gui": { - "name": "Gui", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a objective version to custom guis.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Gui_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core", - "Gui", - "ExpGui" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Server": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" - }, - "Server": { - "name": "Server", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a thread system and event listening and a admin bypass (recommend to disable /c and use optional /interface)", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Server_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core", - "Server", - "Thread", - "Interface", - "Events" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.String": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Command": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" - }, - "Sync": { - "name": "Sync", - "version": "4.0.0", - "type": "Submodule", - "description": "Allows syncing with an outside server and info panle.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Sync_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core", - "Info", - "Sync", - "External", - "Discord" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Table": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Gui": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" - }, - "Command": { - "name": "Command", - "version": "4.0.0", - "type": "Submodule", - "description": "A better command handler than the base game.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingCore.Command_4.0.0.zip", - "keywords": [ - "Library", - "Lib", - "ExpGaming", - "Core", - "Commands" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingCore_4.0.0" - }, - "Group": { - "name": "Group", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a system to manage and auto-create permission groups.", - "location": "", - "keywords": [ - "Groups", - "ExpGaming", - "System", - "Management", - "Manage", - "Permissions" - ], - "dependencies": { - "FactorioStdLib": "^0.8.0", - "ExpGamingLib": "^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" - }, - "Role": { - "name": "Role", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds roles where a player can have more than one role", - "location": "", - "keywords": [ - "Role", - "Ranks", - "Permissions", - "Alowed", - "Admin" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Group": "^4.0.0", - "ExpGamingCore.Server": "?^4.0.0", - "ExpGamingCore.Command": "?^4.0.0" - }, - "collection": "ExpGamingCore_4.0.0" - } - }, - "dependencies": {} -} \ No newline at end of file + "name": "ExpGamingCore", + "version": "4.0.0", + "description": "Explosive Gaming Core Files", + "location": "FSM_ARCHIVE", + "keywords": [ + "Library", + "Lib", + "ExpGaming", + "Core" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "submodules": { + "ExpGamingCore.Gui": "4.0.0", + "ExpGamingCore.Server": "4.0.0", + "ExpGamingCore.Sync": "4.0.0", + "ExpGamingCore.Command": "4.0.0", + "ExpGamingCore.Group": "4.0.0", + "ExpGamingCore.Role": "4.0.0" + }, + "dependencies": {} +} diff --git a/modules/ExpGamingInfo/Readme/control.lua b/modules/ExpGamingInfo/Readme/control.lua index 4943dbe3..55365037 100644 --- a/modules/ExpGamingInfo/Readme/control.lua +++ b/modules/ExpGamingInfo/Readme/control.lua @@ -2,17 +2,16 @@ -- @module ExpGamingInfo.Readme -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Gui = require('ExpGamingCore.Gui') -- Module Define local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then require(module_path..'/src/sync') end + if loaded_modules['ExpGamingCore.Sync'] then require(module_path..'/src/sync') end end } @@ -65,12 +64,12 @@ end):add_tab('commands',{'ExpGamingInfo-Readme.commands-name'},{'ExpGamingInfo-R type='label', caption='/'..command.name } - local discription = table.add{ + local description = table.add{ type='label', caption=command.description, } - discription.style.maximal_width = 400 - discription.style.single_line = false + description.style.maximal_width = 400 + description.style.single_line = false end end):add_tab('links',{'ExpGamingInfo-Readme.links-name'},{'ExpGamingInfo-Readme.links-tooltip'},function(frame) local links={ @@ -87,7 +86,7 @@ end):add_tab('links',{'ExpGamingInfo-Readme.links-name'},{'ExpGamingInfo-Readme. text_box.selectable = true end for i,link in pairs(links) do - frame.add{ + frame.add{ type="label", caption={'ExpGamingInfo-Readme.links-cap'..tostring(i)}, style='caption_label' diff --git a/modules/ExpGamingInfo/Readme/softmod.json b/modules/ExpGamingInfo/Readme/softmod.json index 8531a82b..d824408e 100644 --- a/modules/ExpGamingInfo/Readme/softmod.json +++ b/modules/ExpGamingInfo/Readme/softmod.json @@ -1,22 +1,23 @@ { - "name": "Readme", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a readme gui to the game that contains useful information", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Readme", - "New Player" - ], - "author": "", - "contact": "", - "license": "", - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - } -} \ No newline at end of file + "name": "ExpGamingInfo.Readme", + "version": "4.0.0", + "description": "Adds a readme gui to the game that contains useful information", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Readme", + "New Player" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0" + }, + "submodules": {}, + "collection": "ExpGamingInfo@4.0.0" +} diff --git a/modules/ExpGamingInfo/Readme/src/sync.lua b/modules/ExpGamingInfo/Readme/src/sync.lua index eb52d6a7..51c3c8da 100644 --- a/modules/ExpGamingInfo/Readme/src/sync.lua +++ b/modules/ExpGamingInfo/Readme/src/sync.lua @@ -1,5 +1,5 @@ -local Sync = require('ExpGamingCore.Sync@^4.0.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Sync = require('ExpGamingCore.Sync') +local Gui = require('ExpGamingCore.Gui') Sync.add_to_gui(Gui.inputs.add_button('readme-sync-guildlines','View Guildlines','View the guildlines in the readme',function(player,element) Gui.center.open_tab(player,'readme','guildlines') diff --git a/modules/ExpGamingInfo/Rockets/control.lua b/modules/ExpGamingInfo/Rockets/control.lua index deb2a72c..6edd2130 100644 --- a/modules/ExpGamingInfo/Rockets/control.lua +++ b/modules/ExpGamingInfo/Rockets/control.lua @@ -2,11 +2,11 @@ -- @module ExpGamingInfo.Rockets -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Gui = require('ExpGamingCore.Gui') +local Game = require('FactorioStdLib.Game') -- Module Define local module_verbose = false @@ -31,7 +31,7 @@ ThisModule.Gui = Gui.left{ name='rockets', caption='item/rocket-silo', tooltip={'ExpGamingInfo-Rockets.tooltip'}, - draw=function(frame) + draw=function(self,frame) frame.caption = {'ExpGamingInfo-Rockets.name'} local player = Game.get_player(frame.player_index) local satellites = player.force.get_item_launched('satellite') @@ -74,20 +74,20 @@ ThisModule.Gui = Gui.left{ type='flow', direction='vertical' } - for milestone,time in pairs(global.milestones) do - local milestone = tonumber(milestone:match('%d+')) - if time == 0 and satellites == milestone then + for milestone,next_time in pairs(global.milestones) do + milestone = tonumber(milestone:match('%d+')) + if next_time == 0 and satellites == milestone then global.milestones['m'..milestone] = global.last - time = global.last + next_time = global.last Gui.left.open('rockets') end local _time = {'ExpGamingInfo-Rockets.nan'} - if time > 0 then _time = tick_to_display_format(time) end + if next_time > 0 then _time = tick_to_display_format(next_time) end milestones.add{ type='label', caption={'ExpGamingInfo-Rockets.format',tostring(milestone),_time} } - if time == 0 then break end + if next_time == 0 then break end end end, can_open=function(player) diff --git a/modules/ExpGamingInfo/Rockets/softmod.json b/modules/ExpGamingInfo/Rockets/softmod.json index abdfcd81..10c6e3e8 100644 --- a/modules/ExpGamingInfo/Rockets/softmod.json +++ b/modules/ExpGamingInfo/Rockets/softmod.json @@ -1,21 +1,23 @@ { - "name": "Rockets", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a rocket count gui to the game that shows milestones and average rocket time", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Rockets" - ], - "author": "", - "contact": "", - "license": "", - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - } -} \ No newline at end of file + "name": "ExpGamingInfo.Rockets", + "version": "4.0.0", + "description": "Adds a rocket count gui to the game that shows milestones and average rocket time", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Rockets" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingCore.Sync^4.0.0": "?*" + }, + "submodules": {}, + "collection": "ExpGamingInfo@4.0.0" +} diff --git a/modules/ExpGamingInfo/Rockets/src/sync.lua b/modules/ExpGamingInfo/Rockets/src/sync.lua index e215f530..82482eac 100644 --- a/modules/ExpGamingInfo/Rockets/src/sync.lua +++ b/modules/ExpGamingInfo/Rockets/src/sync.lua @@ -1,5 +1,5 @@ -local Sync = require('ExpGamingCore.Sync@^4.0.0') -local global = global['ExpGamingInfo.Rockets@^4.0.0'] +local Sync = require('ExpGamingCore.Sync') +local global = global['ExpGamingInfo.Rockets'] Sync.add_update('rockets',function() local _return = {} @@ -13,8 +13,8 @@ Sync.add_update('rockets',function() _return.time = Sync.tick_format(time) _return.fastest = Sync.tick_format(global.fastest) _return.milestones = {} - for milestone,time in pairs(global.milestones) do - _return.milestones[milestone] = Sync.tick_format(time) + for milestone,next_time in pairs(global.milestones) do + _return.milestones[milestone] = Sync.tick_format(next_time) end return _return end) \ No newline at end of file diff --git a/modules/ExpGamingInfo/Science/control.lua b/modules/ExpGamingInfo/Science/control.lua index 0fa25bdc..74118960 100644 --- a/modules/ExpGamingInfo/Science/control.lua +++ b/modules/ExpGamingInfo/Science/control.lua @@ -1,14 +1,14 @@ ---- Adds a science count gui to the game that shows toatal made and per minute +--- Adds a science count gui to the game that shows total made and per minute -- @module ExpGamingInfo.Science -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Gui = require('ExpGamingCore.Gui') +local Game = require('FactorioStdLib.Game') --- Local Varibles +-- Local Variables local science_packs = { 'science-pack-1', 'science-pack-2', @@ -23,7 +23,7 @@ local science_packs = { local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Sync^4.0.0'] then require(module_path..'/src/sync') end + if loaded_modules['ExpGamingCore.Sync^4.0.0'] then require(module_path..'/src/sync',{science_packs=science_packs}) end end } @@ -42,13 +42,13 @@ ThisModule.Gui = Gui.left{ name='science', caption='item/lab', tooltip={'ExpGamingInfo-Science.tooltip'}, - draw=function(frame) + draw=function(self,frame) local player = Game.get_player(frame.player_index) if not global[player.force.name] then verbose('Added Science Global for: '..player.force.name) global[player.force.name] = table.deepcopy(global._base) end - force_data = global[player.force.name] + local force_data = global[player.force.name] frame.caption = {'ExpGamingInfo-Science.name'} frame.add{ type='label', @@ -101,5 +101,5 @@ ThisModule.Gui = Gui.left{ script.on_event(defines.events.on_research_finished,function(event) Gui.left.update('science') end) -- Module Return --- when called will toogle the gui for that player, if no player it will update the gui +-- when called will toggle the gui for that player, if no player it will update the gui return setmetatable(ThisModule,{_call=function(self,...) self.Gui(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingInfo/Science/softmod.json b/modules/ExpGamingInfo/Science/softmod.json index 6b30c987..8f9cf99a 100644 --- a/modules/ExpGamingInfo/Science/softmod.json +++ b/modules/ExpGamingInfo/Science/softmod.json @@ -1,22 +1,24 @@ { - "name": "Science", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a science count gui to the game that shows toatal made and per minute", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Science", - "Production" - ], - "author": "", - "contact": "", - "license": "", - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - } -} \ No newline at end of file + "name": "ExpGamingInfo.Science", + "version": "4.0.0", + "description": "Adds a science count gui to the game that shows toatal made and per minute", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Science", + "Production" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingCore.Sync^4.0.0": "?*" + }, + "submodules": {}, + "collection": "ExpGamingInfo@4.0.0" +} diff --git a/modules/ExpGamingInfo/Science/src/sync.lua b/modules/ExpGamingInfo/Science/src/sync.lua index 3c7649c1..6f624d4f 100644 --- a/modules/ExpGamingInfo/Science/src/sync.lua +++ b/modules/ExpGamingInfo/Science/src/sync.lua @@ -1,5 +1,6 @@ -local Sync = require('ExpGamingCore.Sync@^4.0.0') -local data = global['ExpGamingInfo.Science@^4.0.0'] +local Sync = require('ExpGamingCore.Sync') +local data = global['ExpGamingInfo.Science'] +local science_packs = science_packs Sync.add_update('science',function() local _return = {} diff --git a/modules/ExpGamingInfo/Tasklist/control.lua b/modules/ExpGamingInfo/Tasklist/control.lua index de0c0e6f..5754742d 100644 --- a/modules/ExpGamingInfo/Tasklist/control.lua +++ b/modules/ExpGamingInfo/Tasklist/control.lua @@ -2,12 +2,12 @@ -- @module ExpGamingInfo.Tasklist -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Role = require('ExpGamingCore.Role@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Gui = require('ExpGamingCore.Gui') +local Role = require('ExpGamingCore.Role') +local Game = require('FactorioStdLib.Game') -- Module Define local module_verbose = false @@ -102,26 +102,26 @@ local add = Gui.inputs{ end) local function _tasks(player) - local player = Game.get_player(player) + player = Game.get_player(player) local data = global._edit[player.index] if not data then return global.tasks end - local _edit = false + local editing = false for _,v in pairs(data._editing) do if v == true then - _edit = true + editing = true break end end - if data._edit and not _edit then + if data._edit and not editing then global.tasks = table.deepcopy(data._tasks) global._edit[player.index] = table.deepcopy(global._base) Gui.left.update('tasklist') return global.tasks - elseif not data._edit and _edit then + elseif not data._edit and editing then data._edit = true for key,_ in pairs(data._tasks) do if not data._editing[key] then data._editing[key] = false end end return data._tasks - elseif _edit then return data._tasks + elseif editing then return data._tasks else return global.tasks end end @@ -130,7 +130,7 @@ ThisModule.Gui = Gui.left{ name='tasklist', caption='utility/not_enough_repair_packs_icon', tooltip={'ExpGamingInfo-Tasklist.tooltip'}, - draw=function(frame) + draw=function(self,frame) frame.caption = '' local title = frame.add{ type='flow', diff --git a/modules/ExpGamingInfo/Tasklist/softmod.json b/modules/ExpGamingInfo/Tasklist/softmod.json index 4b64949c..dcb673a7 100644 --- a/modules/ExpGamingInfo/Tasklist/softmod.json +++ b/modules/ExpGamingInfo/Tasklist/softmod.json @@ -1,21 +1,22 @@ { - "name": "Tasklist", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a task list gui which acts like a bulletin board for the current tasks", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Tasks" - ], - "author": "", - "contact": "", - "license": "", - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - } -} \ No newline at end of file + "name": "ExpGamingInfo.Tasklist", + "version": "4.0.0", + "description": "Adds a task list gui which acts like a bulletin board for the current tasks", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Tasks" + ], + "author": "", + "contact": "", + "license": "", + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Role": "^4.0.0", + "FactorioStdLib.Game": "^0.8.0" + }, + "submodules": {}, + "collection": "ExpGamingInfo@4.0.0" +} diff --git a/modules/ExpGamingInfo/softmod.json b/modules/ExpGamingInfo/softmod.json index 829aa0bb..fda8359b 100644 --- a/modules/ExpGamingInfo/softmod.json +++ b/modules/ExpGamingInfo/softmod.json @@ -1,92 +1,21 @@ { - "name": "ExpGamingInfo", - "version": "4.0.0", - "type": "Collection", - "description": "Adds info guis to the game for different production areas", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Production" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606@5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "submodules": { - "Readme": { - "name": "Readme", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a readme gui to the game that contains useful information", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Readme", - "New Player" - ], - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - } - }, - "Rockets": { - "name": "Rockets", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a rocket count gui to the game that shows milestones and average rocket time", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Rockets" - ], - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - } - }, - "Science": { - "name": "Science", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a science count gui to the game that shows toatal made and per minute", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Science", - "Production" - ], - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Sync": "?^4.0.0" - } - }, - "Tasklist": { - "name": "Tasklist", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a task list gui which acts like a bulletin board for the current tasks", - "location": "", - "keywords": [ - "Gui", - "Info", - "ExpGaming", - "Tasks" - ], - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - } - } - } -} \ No newline at end of file + "name": "ExpGamingInfo", + "version": "4.0.0", + "description": "Adds info guis to the game for different production areas", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Info", + "ExpGaming", + "Production" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606@5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "submodules": { + "ExpGamingInfo.Readme": "4.0.0", + "ExpGamingInfo.Rockets": "4.0.0", + "ExpGamingInfo.Science": "4.0.0", + "ExpGamingInfo.Tasklist": "4.0.0" + } +} diff --git a/modules/ExpGamingLib/control.lua b/modules/ExpGamingLib/control.lua index 23a9fc8d..b68fb4a3 100644 --- a/modules/ExpGamingLib/control.lua +++ b/modules/ExpGamingLib/control.lua @@ -10,7 +10,7 @@ local Color = require('FactorioStdLib.Color') local module_verbose = false -- there is no verbose in this file so true will do nothing local ExpLib = {} ---- Loads a table into _G even when sandboxed; will not overwrite values or append to tables; will not work during runtime to avoid desyncs +--- Loads a table into _G even when sandboxes; will not overwrite values or append to tables; will not work during runtime to avoid desyncs -- @usage unpack_to_G{key1='foo',key2='bar'} -- @tparam table tbl table to be unpacked function ExpLib.unpack_to_G(tbl) @@ -25,7 +25,7 @@ end -- @treturn table the env table with _G keys removed -- @warning does not work from console function ExpLib.get_env(level) - local level = level and level+1 or 2 + level = level and level+1 or 2 local env = setmetatable({},{__index=_G}) while true do if not debug.getinfo(level) then break end @@ -46,7 +46,7 @@ end -- @warning does not work from console function ExpLib.get_upvalues(level) local func = level and ExpLib.is_type(level,'function') and level or nil - local level = level and ExpLib.is_type(level,'number') and level+1 or 2 + level = level and ExpLib.is_type(level,'number') and level+1 or 2 func = func or debug.getinfo(level).func local upvalues = setmetatable({},{__index=_G}) local i = 1 @@ -58,7 +58,7 @@ function ExpLib.get_upvalues(level) return upvalues end ---- Creats a table that will act like a string and a function +--- Creates a table that will act like a string and a function -- @usage add_metatable({},function) -- returns table -- @tparam table tbl the table that will have its metatable set -- @tparam[opt=tostring] function callback the function that will be used for the call @@ -66,8 +66,8 @@ end -- @treturn table the new table with its metatable set function ExpLib.add_metatable(tbl,callback,string) if not ExpLib.is_type(tbl,'table') then error('No table given to add_metatable',2) end - local callback = ExpLib.is_type(callback,'function') and callback or tostring - local string = ExpLib.is_type(string,'function') and string or ExpLib.is_type(string,'string') and function() return string end or table.tostring + callback = ExpLib.is_type(callback,'function') and callback or tostring + string = ExpLib.is_type(string,'function') and string or ExpLib.is_type(string,'string') and function() return string end or table.tostring return setmetatable(tbl,{ __tostring=string, __concat=function(val1,val2) return type(val1) == 'string' and val1..string(val2) or string(val1)..val2 end, @@ -75,17 +75,17 @@ function ExpLib.add_metatable(tbl,callback,string) }) end ---- Compear types faster for faster valadation of prams +--- 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 bolean is v of type test_type +-- @treturn boolean is v of type test_type function ExpLib.is_type(v,test_type) return test_type and v and type(v) == test_type or not test_type and not v or false end ---- Compear types faster for faster valadation of prams, including giving an error if incorrect +--- Compare types faster for faster validation of prams, including giving an error if incorrect -- @usage type_error('foo','string','Value is not a string') -- return true -- @usage type_error('foo','table','Value is not a string') -- return error -- @param value the value to be tested @@ -96,7 +96,7 @@ function ExpLib.type_error(value,type,error_message) return ExpLib.is_type(value,type) or error(error_message,3) end ---- A speailsied verion of type_error to test for self +--- A specialised version of type_error to test for self -- @usage self_test(self,'Object','get_name') -- @tparam table self the table that is the object -- @tparam string prototype_name the name of the class @@ -110,11 +110,11 @@ end -- @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 rtn 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, ingroned when printing to 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 ExpLib.player_return(rtn,colour,player) - local colour = ExpLib.is_type(colour,'table') and colour or defines.textcolor[colour] ~= defines.color.white and defines.textcolor[colour] or defines.color[colour] - local player = player or game.player + colour = ExpLib.is_type(colour,'table') and colour or defines.textcolor[colour] ~= defines.color.white and defines.textcolor[colour] or defines.color[colour] + player = player or game.player local function _return(callback,rtn) if ExpLib.is_type(rtn,'table') then -- test for: userdata, locale string, table with __tostring meta method, any other table @@ -128,8 +128,8 @@ function ExpLib.player_return(rtn,colour,player) else callback(tostring(rtn),colour) end end if player then - -- allows any vaild player identifier to be used - local player = Game.get_player(player) + -- allows any valid player identifier to be used + player = Game.get_player(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'} @@ -175,8 +175,8 @@ function ExpLib.tick_to_display_format(tick) end end ---- Used as a way to view the structure of a gui, used for debuging --- @usage Gui_tree(root) returns all children of gui recusivly +--- Used as a way to view the structure of a gui, used for debugging +-- @usage Gui_tree(root) returns all children of gui recursively -- @tparam LuaGuiElement root the root to start the tree from -- @treturn table the table that describes the gui function ExpLib.gui_tree(root) @@ -249,33 +249,30 @@ function table.tostring(tbl) return "{"..table.concat(result,",") .."}" end ---- Simmilar to table.tostring but converts a lua table to a json one --- @usage talbe.json{k1='foo',k2='bar'} -- return '{"k1":"foo","k2":"bar"}' +--- Similar to table.tostring but converts a lua table to a json one +-- @usage table.json{k1='foo',k2='bar'} -- return '{"k1":"foo","k2":"bar"}' -- @tparam table lua_table the table to convert -- @treturn string the table in a json format function table.json(lua_table) - local result, done, only_indexs = {}, {}, true + --if game and game.table_to_json then return game.table_to_json(lua_table) end + local result, done, only_indexes = {}, {}, true for key,value in ipairs(lua_table) do done[key] = true if type(value) == 'table' then table.insert(result,table.json(value,true)) - elseif type(value) == 'string' then table.insert(result,'"'..value..'"') - elseif type(value) == 'number' then table.insert(result,value) - elseif type(value) == 'boolean' then table.insert(result,tostring(value)) - else table.insert(result,'null') + elseif not value then table.insert(result,'null') + else table.insert(result,table.val_to_str(value)) end end for key,value in pairs(lua_table) do if not done[key] then - only_indexs = false - if type(value) == 'table' then table.insert(result,'"'..key..'":'..table.json(value,true)) - elseif type(value) == 'string' then table.insert(result,'"'..key..'":"'..value..'"') - elseif type(value) == 'number' then table.insert(result,'"'..key..'":'..value) - elseif type(value) == 'boolean' then table.insert(result,'"'..key..'":'..tostring(value)) - else table.insert(result,'"'..key..'":null') + only_indexes = false + if type(value) == 'table' then table.insert(result,table.val_to_str(key)..':'..table.json(value,true)) + elseif not value then table.insert(result,table.val_to_str(key)..':null') + else table.insert(result,table.val_to_str(key)..':'..table.val_to_str(value)) end end end - if only_indexs then return "["..table.concat(result,",").."]" + if only_indexes then return "["..table.concat(result,",").."]" else return "{"..table.concat(result,",").."}" end end diff --git a/modules/ExpGamingLib/softmod.json b/modules/ExpGamingLib/softmod.json index 45846fa5..160803be 100644 --- a/modules/ExpGamingLib/softmod.json +++ b/modules/ExpGamingLib/softmod.json @@ -1,19 +1,19 @@ { - "name": "ExpGamingLib", - "version": "4.0.0", - "type": "Module", - "description": "Adds some common functions used though out all ExpGaming modules", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingLib_4.0.0.zip", - "keywords": [ - "ExpGaming", - "Lib" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Table": "^0.8.0" - } -} \ No newline at end of file + "name": "ExpGamingLib", + "version": "4.0.0", + "description": "Adds some common functions used though out all ExpGaming modules", + "location": "FSM_ARCHIVE", + "keywords": [ + "ExpGaming", + "Lib" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "FactorioStdLib.Color": "^0.8.0", + "FactorioStdLib.Table": "^0.8.0" + }, + "submodules": {} +} diff --git a/modules/ExpGamingPlayer/afkKick/control.lua b/modules/ExpGamingPlayer/afkKick/control.lua index 0e302ccf..aa8f1c11 100644 --- a/modules/ExpGamingPlayer/afkKick/control.lua +++ b/modules/ExpGamingPlayer/afkKick/control.lua @@ -3,18 +3,18 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') local Role -- ExpGamingCore.Role@^4.0.0 local Sync -- ExpGamingCore.Sync@^4.0.0 local function get_allowed_afk_time(player) - local role - if Role then role = Role.get_highest(player) - else if player.admin then return else role = Role.meta.default end end - local count = #game.connected_players - local base = not role.allow_afk_kick and role.index or false - if not base then return false end - return (Role.meta.count/base)*count + player = Game.get_player(player) + local role = Role and Role.get_highest(player) or {index=1,allow_afk_kick=not player.admin} + local player_count = #game.connected_players + local role_count = Role and Role.meta.count or 1 + local role_index = role.allow_afk_kick and role.index or false + if not role_index then return false end + return (role_count/role_index)*player_count end script.on_event(defines.events.on_tick,function(event) @@ -30,8 +30,8 @@ end) return setmetatable({ get_allowed_afk_time=get_allowed_afk_time, on_init=function(self) - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end - if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end - if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require(module_path..'/src/server',Sync,self) end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end + if loaded_modules['ExpGamingCore.Sync'] then Sync = require('ExpGamingCore.Sync') end + if loaded_modules['ExpGamingCore.Server'] then require(module_path..'/src/server',{Sync=Sync,self=self}) end end -},{__call=function(self,...) self.get_allowed_afk_time(...) end}) \ No newline at end of file +},{__call=function(self,...) return self.get_allowed_afk_time(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingPlayer/afkKick/softmod.json b/modules/ExpGamingPlayer/afkKick/softmod.json index 7fb29fb7..bace003d 100644 --- a/modules/ExpGamingPlayer/afkKick/softmod.json +++ b/modules/ExpGamingPlayer/afkKick/softmod.json @@ -1,22 +1,22 @@ { - "name": "afkKick", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a varible amount of time before a user is kicked based on the current player count.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingPlayer.afkKick_4.0.0.zip", - "keywords": [ - "Kick", - "AFK", - "Players", - "Smart", - "Varible" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingCore.Server": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" -} \ No newline at end of file + "name": "ExpGamingPlayer.afkKick", + "version": "4.0.0", + "description": "Adds a varible amount of time before a user is kicked based on the current player count.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Kick", + "AFK", + "Players", + "Smart", + "Varible" + ], + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Sync": "?^4.0.0", + "ExpGamingCore.Server": "?^4.0.0" + }, + "collection": "ExpGamingPlayer@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingPlayer/afkKick/src/server.lua b/modules/ExpGamingPlayer/afkKick/src/server.lua index f8d4b3e1..ed6bcf00 100644 --- a/modules/ExpGamingPlayer/afkKick/src/server.lua +++ b/modules/ExpGamingPlayer/afkKick/src/server.lua @@ -1,6 +1,7 @@ local Sync = Sync local get_allowed_afk_time = self -local Server = require('ExpGamingCore.Server@^4.0.0') +local Server = require('ExpGamingCore.Server') +local Color = require('FactorioStdLib.Color') Event[defines.events.on_tick] = nil script.on_init(function(event) @@ -16,7 +17,7 @@ script.on_init(function(event) end end):on_event('error',function(self,err) if Sync then - Sync.emit_embeded{ + Sync.emit_embedded{ title='Auto Kick Error', color=Color.to_hex(defines.textcolor.bg), description='Auto Kick Error - Closed Thread', diff --git a/modules/ExpGamingPlayer/inventorySearch/control.lua b/modules/ExpGamingPlayer/inventorySearch/control.lua index 675b9549..12318f15 100644 --- a/modules/ExpGamingPlayer/inventorySearch/control.lua +++ b/modules/ExpGamingPlayer/inventorySearch/control.lua @@ -1,15 +1,14 @@ ---- Adds an inventory search that is proformed on a random player every 15 seconds +--- Adds an inventory search that is preformed on a random player every 15 seconds -- @module ExpGamingPlayer.inventorySearch@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Admin = require('ExpGamingAdmin') local Role -- ExpGamingCore.Role@^4.0.0 --- Local Varibles +-- Local Variables -- removed from none admin ranks, no further action local low_items = { 'loader', @@ -36,7 +35,7 @@ local high_items = { } -- inventories which are searched -local inventorys = { +local inventories = { defines.inventory.player_main, defines.inventory.player_quickbar, defines.inventory.player_trash @@ -48,7 +47,7 @@ local _root_tree = {low_items=low_items,med_items=med_items,high_items=high_item local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end end } @@ -63,7 +62,7 @@ end function ThisModule.search_player(player) for category,items in pairs(_root_tree) do if not Role or category ~= 'low_items' and not Role.allowed(player,'admin-items') then - for _,_inventory in pairs(inventorys) do + for _,_inventory in pairs(inventories) do local inventory = player.get_inventory(_inventory) if inventory then for _,item in pairs(items) do diff --git a/modules/ExpGamingPlayer/inventorySearch/softmod.json b/modules/ExpGamingPlayer/inventorySearch/softmod.json index bf8994a8..17f251c0 100644 --- a/modules/ExpGamingPlayer/inventorySearch/softmod.json +++ b/modules/ExpGamingPlayer/inventorySearch/softmod.json @@ -1,21 +1,22 @@ { - "name": "inventorySearch", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds an inventory search that is proformed on a random player every 15 seconds.", - "location": "", - "keywords": [ - "Search", - "ExpGaming", - "Player", - "Inventory" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "ExpGamingAdmin.TempBan": "^4.0.0", - "ExpGamingAdmin.Warnings": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingPlayer_4.0.0" -} \ No newline at end of file + "name": "ExpGamingPlayer.inventorySearch", + "version": "4.0.0", + "description": "Adds an inventory search that is proformed on a random player every 15 seconds.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Search", + "ExpGaming", + "Player", + "Inventory" + ], + "dependencies": { + "ExpGamingLib": "^4.0.0", + "ExpGamingAdmin.TempBan": "^4.0.0", + "ExpGamingAdmin.Warnings": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0", + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingAdmin": "^4.0.0" + }, + "collection": "ExpGamingPlayer@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingPlayer/playerInfo/control.lua b/modules/ExpGamingPlayer/playerInfo/control.lua index a5a4817e..cd68d962 100644 --- a/modules/ExpGamingPlayer/playerInfo/control.lua +++ b/modules/ExpGamingPlayer/playerInfo/control.lua @@ -3,13 +3,13 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^0.8.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Game = require('FactorioStdLib.Game') +local Gui = require('ExpGamingCore.Gui') local Role -- ExpGamingCore.Role@^4.0.0 local Group -- ExpGamingCore.Group@^4.0.0 local function get_player_info(player,frame,add_cam) - local player = Game.get_player(player) + player = Game.get_player(player) if not player then return {} end local _player = {} _player.index = player.index @@ -26,7 +26,7 @@ local function get_player_info(player,frame,add_cam) _player.roles = roles end if frame then - local frame = frame.add{type='frame',direction='vertical',style='image_frame'} + frame = frame.add{type='frame',direction='vertical',style='image_frame'} frame.style.width = 200 if Role then frame.style.height = 300 else frame.style.height = 260 end @@ -50,9 +50,9 @@ end return setmetatable({ get_player_info=get_player_info, on_init=function(self) - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end - if loaded_modules['ExpGamingCore.Group@^4.0.0'] then Group = require('ExpGamingCore.Group@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end + if loaded_modules['ExpGamingCore.Group'] then Group = require('ExpGamingCore.Group') end end },{ - __call=function(self,...) self.get_player_info(...) end + __call=function(self,...) return self.get_player_info(...) end }) \ No newline at end of file diff --git a/modules/ExpGamingPlayer/playerInfo/softmod.json b/modules/ExpGamingPlayer/playerInfo/softmod.json index 323e16de..2fda8414 100644 --- a/modules/ExpGamingPlayer/playerInfo/softmod.json +++ b/modules/ExpGamingPlayer/playerInfo/softmod.json @@ -1,20 +1,21 @@ { - "name": "playerInfo", - "version": "4.0.0", - "type": "Submodule", - "description": "Used to give so common info on a player as a lua table or a frame.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingPlayer.playerInfo_4.0.0.zip", - "keywords": [ - "Cam", - "Follow", - "Player", - "Info", - "Useful" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" -} \ No newline at end of file + "name": "ExpGamingPlayer.playerInfo", + "version": "4.0.0", + "description": "Used to give so common info on a player as a lua table or a frame.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Cam", + "Follow", + "Player", + "Info", + "Useful" + ], + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Group": "?^4.0.0" + }, + "collection": "ExpGamingPlayer@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingPlayer/playerList/control.lua b/modules/ExpGamingPlayer/playerList/control.lua index d7153c42..886e3139 100644 --- a/modules/ExpGamingPlayer/playerList/control.lua +++ b/modules/ExpGamingPlayer/playerList/control.lua @@ -3,12 +3,12 @@ -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -local Game = require('FactorioStdLib.Game@^0.8.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Admin -- ExpGamingAdmin.AdminLib@^4.0.0 +local Game = require('FactorioStdLib.Game') +local Gui = require('ExpGamingCore.Gui') +local Admin -- ExpGamingAdmin@^4.0.0 local AdminGui -- ExpGamingAdmin.Gui@^4.0.0 --- Local Varibles +-- Local Variables local playerInfo = function(player,frame) frame.add{ type='label', @@ -17,7 +17,7 @@ local playerInfo = function(player,frame) end local getPlayers = function() - local rtn = {{{r=233,g=63,b=233},'Admin',{}},{{r=255,g=159,b=27},'',{}}} + local rtn = {{{r=233,g=63,b=233},'Admin',{},true},{{r=255,g=159,b=27},'',{},false}} for _,player in pairs(game.connected_players) do if player.admin then table.insert(rtn[2][3],player) else table.insert(rtn[1][3],player) end @@ -30,9 +30,9 @@ local module_verbose = false local ThisModule = { on_init=function(self) if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then getPlayers = require(module_path..'/src/ranking',{self=self}) end - if loaded_modules['ExpGamingAdmin.AdminLib@^4.0.0'] then Admin = require('ExpGamingAdmin.AdminLib@^4.0.0') end - if loaded_modules['ExpGamingAdmin.Gui@^4.0.0'] then AdminGui = require('ExpGamingAdmin.Gui@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then getPlayers = require(module_path..'/src/ranking',{self=self}) end + if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end + if loaded_modules['ExpGamingAdmin.Gui'] then AdminGui = require('ExpGamingAdmin.Gui') end end } @@ -40,12 +40,12 @@ local ThisModule = { local global = global{ update=0, delay=10, - intervial=54000 + interval=54000 } function ThisModule.update(tick) local tick = is_type(tick,'table') and tick.tick or is_type(tick,'number') and tick or game.tick - if tick + global.delay > global.update - global.intervial then + if tick + global.delay > global.update - global.interval then global.update = tick + global.delay end end @@ -63,7 +63,7 @@ ThisModule.Gui = Gui.left{ name='player-list', caption='entity/player', tooltip={'ExpGamingPlayer-playerList.tooltip'}, - draw=function(frame) + draw=function(self,frame) frame.caption = '' local player_list = frame.add{ name='scroll', @@ -113,7 +113,7 @@ ThisModule.Gui = Gui.left{ script.on_event(defines.events.on_tick,function(event) if event.tick > global.update then ThisModule.Gui() - global.update = event.tick + global.intervial + global.update = event.tick + global.interval end end) @@ -125,6 +125,8 @@ script.on_event(defines.events.on_gui_click,function(event) -- must be a right click if event.button == defines.mouse_button_type.right then else return end local player_list = event.element.parent.parent.parent + -- must be a valid player which is clicked + if not Game.get_player(event.element.name) then return end -- hides the player list to show the info player_list.scroll.style.visible = false local flow = player_list.add{type='flow',direction='vertical'} diff --git a/modules/ExpGamingPlayer/playerList/softmod.json b/modules/ExpGamingPlayer/playerList/softmod.json index e2002be0..bda73c47 100644 --- a/modules/ExpGamingPlayer/playerList/softmod.json +++ b/modules/ExpGamingPlayer/playerList/softmod.json @@ -1,23 +1,24 @@ { - "name": "playerList", - "version": "4.0.0", - "type": "Submodule", - "description": "Used to display player names and online time on the top left.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingPlayer.playerList_4.0.0.zip", - "keywords": [ - "Player List", - "List", - "Gui", - "Names" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingAdmin.AdminLib": "?^4.0.0", - "ExpGamingAdmin.buttonFlow": "?^4.0.0", - "ExpGamingAdmin.reports": "?^4.0.0", - "ExpGamingPlayer.playerInfo": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" -} \ No newline at end of file + "name": "ExpGamingPlayer.playerList", + "version": "4.0.0", + "description": "Used to display player names and online time on the top left.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Player List", + "List", + "Gui", + "Names" + ], + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingAdmin": "?^4.0.0", + "ExpGamingAdmin.buttonFlow": "?^4.0.0", + "ExpGamingAdmin.reports": "?^4.0.0", + "ExpGamingPlayer.playerInfo": "?^4.0.0", + "ExpGamingAdmin.Gui": "?^4.0.0" + }, + "collection": "ExpGamingPlayer@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingPlayer/playerList/src/ranking.lua b/modules/ExpGamingPlayer/playerList/src/ranking.lua index e7f96896..66a94eae 100644 --- a/modules/ExpGamingPlayer/playerList/src/ranking.lua +++ b/modules/ExpGamingPlayer/playerList/src/ranking.lua @@ -1,12 +1,15 @@ -local Role = require('ExpGamingCore.Role@^4.0.0') +local Role = require('ExpGamingCore.Role') script.on_event(defines.events.on_role_change,self.update) return function() local rtn = {} + local default = {} for _,role_name in pairs(Role.order) do local role = Role.get(role_name) - table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable}) + if role.is_default then default = {role.colour,role.short_hand,role:get_players(true),role.not_reportable} + else table.insert(rtn,{role.colour,role.short_hand,role:get_players(true),role.not_reportable}) end end + table.insert(rtn,default) return rtn end \ No newline at end of file diff --git a/modules/ExpGamingPlayer/polls/control.lua b/modules/ExpGamingPlayer/polls/control.lua index 7c1341ba..1f187437 100644 --- a/modules/ExpGamingPlayer/polls/control.lua +++ b/modules/ExpGamingPlayer/polls/control.lua @@ -4,18 +4,18 @@ -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -- Module Require -local Server = require('ExpGamingCore.Server@^4.0.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Server = require('ExpGamingCore.Server') +local Gui = require('ExpGamingCore.Gui') local Role -- ExpGamingCore.Server@^4.0.0 --- Local Varibles +-- Local Variables local poll_time_out = 90 -- In seconds -- Module Define local module_verbose = false local ThisModule = { on_init=function() - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end end } @@ -27,7 +27,7 @@ local global = global{ -- Function Define local function _poll_data(question,answers) - local poll = { + local rtn_poll = { uuid=Server.uuid(), question=question, answers=answers or {'None'}, @@ -35,7 +35,7 @@ local function _poll_data(question,answers) voted={} } Server.new_thread{ - data={poll_uuid=poll.uuid}, + data={poll_uuid=rtn_poll.uuid}, timeout=poll_time_out*60 }:on_event('timeout',function(self) local uuid = tostring(self.data.poll_uuid) @@ -58,9 +58,9 @@ local function _poll_data(question,answers) game.print({'ExpGamingPlayer-polls.winner',highest[1]},defines.textcolor.info) verbose('Ended Poll: '..poll.question..' ('..uuid..') Highest: '..highest[1]) end):open() - global.active[tostring(poll.uuid)]=poll - verbose('Created Poll: '..question..' ('..poll.uuid..')') - return poll.uuid + global.active[tostring(rtn_poll.uuid)]=rtn_poll + verbose('Created Poll: '..question..' ('..rtn_poll.uuid..')') + return rtn_poll.uuid end local function draw_poll(frame) @@ -86,18 +86,18 @@ local function draw_poll(frame) end end -local function _opptions(player,root_frame) - local opptions = {'Please Select An Opption'} +local function _options(player,root_frame) + local options = {'Please Select An option'} local uuid = root_frame.name local poll = global.active[uuid] if not poll then return {'Invalid Poll'} end for _,answer in pairs(poll.answers) do - table.insert(opptions,answer) + table.insert(options,answer) end - return opptions + return options end -local opption_drop_down = Gui.inputs.add_drop_down('opption-drop-down-polls',_opptions,1,function(player,selected,items,element) +local option_drop_down = Gui.inputs.add_drop_down('option-drop-down-polls',_options,1,function(player,selected,items,element) local uuid = element.parent.name local poll = global.active[uuid] if not poll then return end @@ -146,17 +146,17 @@ local poll_question_input = Gui.inputs.add_text('poll-question-input',true,'Ques else options.question.caption = text end end) -local _self_referace_poll_option_input = nil +local _self_reference_poll_option_input = nil local poll_option_input = Gui.inputs.add_text('poll-option-input',true,'Enter Option',function(player,text,element) local options = element.parent.parent.parent.options if not options[element.parent.name] then options.add{type='label',name=element.parent.name,caption=text} else options[element.parent.name].caption = text end if options.last.caption == element.parent.name then options.last.caption = tonumber(options.last.caption)+1 - _self_referace_poll_option_input(element.parent.parent.add{type='flow',name=options.last.caption}).style.minimal_width = 200 + _self_reference_poll_option_input(element.parent.parent.add{type='flow',name=options.last.caption}).style.minimal_width = 200 end end) -_self_referace_poll_option_input = poll_option_input +_self_reference_poll_option_input = poll_option_input local function poll_assembler(frame) frame.clear() @@ -206,7 +206,7 @@ end) ThisModule.Gui = Gui.popup{ name='polls', caption={'ExpGamingPlayer-polls.name'}, - draw=function(frame,data) + draw=function(self,frame,data) frame.style.right_padding = 5 frame.style.bottom_padding = 5 local uuid = data.uuid @@ -220,12 +220,12 @@ ThisModule.Gui = Gui.popup{ flow.add{type='label',caption={'ExpGamingPlayer-polls.time-left',poll_time_out}} flow.add{type='label',caption='Question: '..poll.question} flow.add{type='label',name='answer',caption='Your Answer: None'} - opption_drop_down(flow) + option_drop_down(flow) end }:add_left{ caption='utility/item_editor_icon', tooltip={'ExpGamingPlayer-polls.tooltip'}, - draw=function(frame) + draw=function(self,frame) frame.caption={'ExpGamingPlayer-polls.name'} frame.add{ type='label', @@ -245,11 +245,11 @@ ThisModule.Gui = Gui.popup{ caption='Viewing Poll: 1', style='caption_label' } - local btn = next:draw(title) + btn = next:draw(title) btn.style.width = 20 btn.style.height = 20 if Role and Role.allowed(frame.player_index,'create-poll') or game.players[frame.player_index].admin then - local btn = create_poll:draw(title) + btn = create_poll:draw(title) btn.style.width = 20 btn.style.height = 20 end @@ -269,5 +269,5 @@ ThisModule.Gui = Gui.popup{ -- Event Handlers Define -- Module Return --- when called it will toogle the left gui for this player +-- when called it will toggle the left gui for this player return setmetatable(ThisModule,{__call=function(self,...) self.Gui(...) end}) \ No newline at end of file diff --git a/modules/ExpGamingPlayer/polls/softmod.json b/modules/ExpGamingPlayer/polls/softmod.json index 39bfdea7..d5c416b6 100644 --- a/modules/ExpGamingPlayer/polls/softmod.json +++ b/modules/ExpGamingPlayer/polls/softmod.json @@ -1,19 +1,19 @@ { - "name": "polls", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a poll gui into the game for quick polls (default 90 seconds)", - "location": "", - "keywords": [ - "Polls", - "Poll", - "Question", - "Gui" - ], - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" -} \ No newline at end of file + "name": "ExpGamingPlayer.polls", + "version": "4.0.0", + "description": "Adds a poll gui into the game for quick polls (default 90 seconds)", + "location": "FSM_ARCHIVE", + "keywords": [ + "Polls", + "Poll", + "Question", + "Gui" + ], + "dependencies": { + "ExpGamingCore.Gui": "^4.0.0", + "ExpGamingCore.Server": "^4.0.0", + "ExpGamingCore.Role": "?^4.0.0" + }, + "collection": "ExpGamingPlayer@4.0.0", + "submodules": {} +} diff --git a/modules/ExpGamingPlayer/softmod.json b/modules/ExpGamingPlayer/softmod.json index ef55164a..e31dddb6 100644 --- a/modules/ExpGamingPlayer/softmod.json +++ b/modules/ExpGamingPlayer/softmod.json @@ -1,124 +1,23 @@ { - "name": "ExpGamingPlayer", - "version": "4.0.0", - "type": "Collection", - "description": "Useful collection of modules for displaying player infomation.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingPlayer_4.0.0.zip", - "keywords": [ - "ExpGaming", - "Player", - "Information", - "AFK" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "submodules": { - "afkKick": { - "name": "afkKick", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a varible amount of time before a user is kicked based on the current player count.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingPlayer.afkKick_4.0.0.zip", - "keywords": [ - "Kick", - "AFK", - "Players", - "Smart", - "Varible" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Sync": "?^4.0.0", - "ExpGamingCore.Server": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" - }, - "playerInfo": { - "name": "playerInfo", - "version": "4.0.0", - "type": "Submodule", - "description": "Used to give so common info on a player as a lua table or a frame.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingPlayer.playerInfo_4.0.0.zip", - "keywords": [ - "Cam", - "Follow", - "Player", - "Info", - "Useful" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" - }, - "playerList": { - "name": "playerList", - "version": "4.0.0", - "type": "Submodule", - "description": "Used to display player names and online time on the top left.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/ExpGamingPlayer.playerList_4.0.0.zip", - "keywords": [ - "Player List", - "List", - "Gui", - "Names" - ], - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingAdmin.AdminLib": "?^4.0.0", - "ExpGamingAdmin.buttonFlow": "?^4.0.0", - "ExpGamingAdmin.reports": "?^4.0.0", - "ExpGamingPlayer.playerInfo": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" - }, - "inventorySearch": { - "name": "inventorySearch", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds an inventory search that is proformed on a random player every 15 seconds.", - "location": "", - "keywords": [ - "Search", - "ExpGaming", - "Player", - "Inventory" - ], - "dependencies": { - "ExpGamingLib": "^4.0.0", - "ExpGamingAdmin.TempBan": "^4.0.0", - "ExpGamingAdmin.Warnings": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0", - "FactorioStdLib.Game": "^0.8.0" - }, - "collection": "ExpGamingPlayer_4.0.0" - }, - "polls": { - "name": "polls", - "version": "4.0.0", - "type": "Submodule", - "description": "Adds a poll gui into the game for quick polls (default 90 seconds)", - "location": "", - "keywords": [ - "Polls", - "Poll", - "Question", - "Gui" - ], - "dependencies": { - "ExpGamingCore.Gui": "^4.0.0", - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Role": "?^4.0.0" - }, - "collection": "ExpGamingPlayer_4.0.0" - } - }, - "dependencies": {} -} \ No newline at end of file + "name": "ExpGamingPlayer", + "version": "4.0.0", + "description": "Useful collection of modules for displaying player infomation.", + "location": "FSM_ARCHIVE", + "keywords": [ + "ExpGaming", + "Player", + "Information", + "AFK" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "submodules": { + "ExpGamingPlayer.afkKick": "4.0.0", + "ExpGamingPlayer.playerInfo": "4.0.0", + "ExpGamingPlayer.playerList": "4.0.0", + "ExpGamingPlayer.inventorySearch": "4.0.0", + "ExpGamingPlayer.polls": "4.0.0" + }, + "dependencies": {} +} diff --git a/modules/FactorioStdLib/Color/softmod.json b/modules/FactorioStdLib/Color/softmod.json index 63974367..c95f14bc 100644 --- a/modules/FactorioStdLib/Color/softmod.json +++ b/modules/FactorioStdLib/Color/softmod.json @@ -1,16 +1,16 @@ { - "name": "Color", - "version": "0.8.0", - "type": "Submodule", - "description": "A defines module for retrieving colors by name.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.Color_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "Color", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" -} \ No newline at end of file + "name": "FactorioStdLib.Color", + "version": "0.8.0", + "description": "A defines module for retrieving colors by name.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Standard Library", + "Lib", + "StdLib", + "Color", + "Extends" + ], + "dependencies": {}, + "collection": "FactorioStdLib@0.8.0", + "submodules": {} +} diff --git a/modules/FactorioStdLib/Game/control.lua b/modules/FactorioStdLib/Game/control.lua index 219b88f7..b7608965 100644 --- a/modules/FactorioStdLib/Game/control.lua +++ b/modules/FactorioStdLib/Game/control.lua @@ -5,9 +5,9 @@ local Game = { --luacheck: allow defined top VALID_FILTER = function(v) return v and v.valid end, - _protect = function(module_name) + _protect = function(moduleName) return { - __newindex = function() error("Attempt to mutatate read-only "..module_name.." Module") end, + __newindex = function() error("Attempt to mutatate read-only "..moduleName.." Module") end, __metatable = true } end, diff --git a/modules/FactorioStdLib/Game/softmod.json b/modules/FactorioStdLib/Game/softmod.json index a175839a..76b50163 100644 --- a/modules/FactorioStdLib/Game/softmod.json +++ b/modules/FactorioStdLib/Game/softmod.json @@ -1,16 +1,16 @@ { - "name": "Game", - "version": "0.8.0", - "type": "Submodule", - "description": "The game module.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.Game_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "Game", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" -} \ No newline at end of file + "name": "FactorioStdLib.Game", + "version": "0.8.0", + "description": "The game module.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Standard Library", + "Lib", + "StdLib", + "Game", + "Extends" + ], + "dependencies": {}, + "collection": "FactorioStdLib@0.8.0", + "submodules": {} +} diff --git a/modules/FactorioStdLib/String/softmod.json b/modules/FactorioStdLib/String/softmod.json index 426934a4..3ef2d9a6 100644 --- a/modules/FactorioStdLib/String/softmod.json +++ b/modules/FactorioStdLib/String/softmod.json @@ -1,16 +1,16 @@ { - "name": "String", - "version": "0.8.0", - "type": "Submodule", - "description": "Extends Lua 5.2 string.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.String_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "String", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" -} \ No newline at end of file + "name": "FactorioStdLib.String", + "version": "0.8.0", + "description": "Extends Lua 5.2 string.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Standard Library", + "Lib", + "StdLib", + "String", + "Extends" + ], + "dependencies": {}, + "collection": "FactorioStdLib@0.8.0", + "submodules": {} +} diff --git a/modules/FactorioStdLib/Table/softmod.json b/modules/FactorioStdLib/Table/softmod.json index 8e86a708..e915763c 100644 --- a/modules/FactorioStdLib/Table/softmod.json +++ b/modules/FactorioStdLib/Table/softmod.json @@ -1,16 +1,16 @@ { - "name": "Table", - "version": "0.8.0", - "type": "Submodule", - "description": "Extends Lua 5.2 table.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.Table_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "Table", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" -} \ No newline at end of file + "name": "FactorioStdLib.Table", + "version": "0.8.0", + "description": "Extends Lua 5.2 table.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Standard Library", + "Lib", + "StdLib", + "Table", + "Extends" + ], + "dependencies": {}, + "collection": "FactorioStdLib@0.8.0", + "submodules": {} +} diff --git a/modules/FactorioStdLib/softmod.json b/modules/FactorioStdLib/softmod.json index f2471e5f..7cc751b9 100644 --- a/modules/FactorioStdLib/softmod.json +++ b/modules/FactorioStdLib/softmod.json @@ -1,82 +1,21 @@ { - "name": "FactorioStdLib", - "version": "0.8.0", - "type": "Collection", - "description": "Factorio Standard Library Projects", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib" - ], - "author": "Afforess", - "contact": "https://github.com/Afforess/Factorio-Stdlib/issues", - "license": "https://github.com/Afforess/Factorio-Stdlib/blob/master/LICENSE", - "submodules": { - "Color": { - "name": "Color", - "version": "0.8.0", - "type": "Submodule", - "description": "A defines module for retrieving colors by name.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.Color_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "Color", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" - }, - "Game": { - "name": "Game", - "version": "0.8.0", - "type": "Submodule", - "description": "The game module.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.Game_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "Game", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" - }, - "String": { - "name": "String", - "version": "0.8.0", - "type": "Submodule", - "description": "Extends Lua 5.2 string.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.String_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "String", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" - }, - "Table": { - "name": "Table", - "version": "0.8.0", - "type": "Submodule", - "description": "Extends Lua 5.2 table.", - "location": "https://github.com/explosivegaming/scenario/releases/download/v4.0-core/FactorioStdLib.Table_0.8.0.zip", - "keywords": [ - "Standard Library", - "Lib", - "StdLib", - "Table", - "Extends" - ], - "dependencies": {}, - "collection": "FactorioStdLib_0.8.0" - } - }, - "dependencies": {} -} \ No newline at end of file + "name": "FactorioStdLib", + "version": "0.8.0", + "description": "Factorio Standard Library Projects", + "location": "FSM_ARCHIVE", + "keywords": [ + "Standard Library", + "Lib", + "StdLib" + ], + "author": "Afforess", + "contact": "https://github.com/Afforess/Factorio-Stdlib/issues", + "license": "https://github.com/Afforess/Factorio-Stdlib/blob/master/LICENSE", + "submodules": { + "FactorioStdLib.Color": "0.8.0", + "FactorioStdLib.Game": "0.8.0", + "FactorioStdLib.String": "0.8.0", + "FactorioStdLib.Table": "0.8.0" + }, + "dependencies": {} +} diff --git a/modules/GameSettingsGui/control.lua b/modules/GameSettingsGui/control.lua index 61bbb758..2a447482 100644 --- a/modules/GameSettingsGui/control.lua +++ b/modules/GameSettingsGui/control.lua @@ -4,10 +4,10 @@ -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE -- Module Require -local Server = require('ExpGamingCore.Server@^4.0.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') +local Server = require('ExpGamingCore.Server') +local Gui = require('ExpGamingCore.Gui') --- Local Varibles +-- Local Variables --{type='slider',object='',key='',name='',min=x,max=y} --{type='function',object='',key='',name='',param={}} local basic_settings = { @@ -122,8 +122,7 @@ local are_you_sure = Gui.inputs.add_checkbox('game-settings-are-you-sure',true,n end) local function _draw_setting(frame,setting) - local frame = frame.add{type='flow'} - local frame = frame.add{ + frame = frame.add{type='flow'}.add{ type='flow', name=setting._group } diff --git a/modules/GameSettingsGui/softmod.json b/modules/GameSettingsGui/softmod.json index ac3a5deb..2e09943f 100644 --- a/modules/GameSettingsGui/softmod.json +++ b/modules/GameSettingsGui/softmod.json @@ -1,21 +1,21 @@ { - "name": "GameSettingsGui", - "version": "4.0.0", - "type": "Module", - "description": "A gui for controlling game settings with sliders as well as some global commands.", - "location": "", - "keywords": [ - "Gui", - "Game", - "Game Settings", - "Settings", - "Admin" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "ExpGamingCore.Server": "^4.0.0", - "ExpGamingCore.Gui": "^4.0.0" - } -} \ No newline at end of file + "name": "GameSettingsGui", + "version": "4.0.0", + "description": "A gui for controlling game settings with sliders as well as some global commands.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Gui", + "Game", + "Game Settings", + "Settings", + "Admin" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "ExpGamingCore.Server": "^4.0.0", + "ExpGamingCore.Gui": "^4.0.0" + }, + "submodules": {} +} diff --git a/modules/GuiAnnouncements/control.lua b/modules/GuiAnnouncements/control.lua index c2f73c86..d1a434d2 100644 --- a/modules/GuiAnnouncements/control.lua +++ b/modules/GuiAnnouncements/control.lua @@ -1,15 +1,15 @@ ---- Creates a gui for making and reciving announcements +--- Creates a gui for making and receiving announcements -- @module GuiAnnouncements@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule --- maybe make this not require Role and have it optinal +-- maybe make this not require Role and have it optional -- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Role = require('ExpGamingCore.Role@^4.0.0') +local Game = require('FactorioStdLib.Game') +local Gui = require('ExpGamingCore.Gui') +local Role = require('ExpGamingCore.Role') -- Module Define local module_verbose = false @@ -27,15 +27,15 @@ local function _roles(player) return roles end -local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-annoncements',_roles,1,function(player,selected,items,element) +local role_drop_down = Gui.inputs.add_drop_down('rank-drop-down-announcements',_roles,1,function(player,selected,items,element) element.parent.role.caption = selected - if selected == 'Select Role' then element.parent['send-annoncement'].style.visible = false - else element.parent['send-annoncement'].style.visible = true end + if selected == 'Select Role' then element.parent['send-announcement'].style.visible = false + else element.parent['send-announcement'].style.visible = true end end) local send_popup = Gui.inputs{ type='button', - name='send-annoncement', + name='send-announcement', caption='utility/export_slot' }:on_event('click',function(event) local player = Game.get_player(event) @@ -57,7 +57,7 @@ end) ThisModule.Gui = Gui.popup{ name='announcements', caption={'GuiAnnouncements.name'}, - draw=function(frame,data) + draw=function(self,frame,data) frame.style.right_padding = 5 frame.style.bottom_padding = 5 frame.add{type='label',caption=data.sent_by,style='caption_label'} @@ -72,9 +72,9 @@ ThisModule.Gui = Gui.popup{ }:add_left{ caption='item/programmable-speaker', tooltip={'GuiAnnouncements.tooltip'}, - draw=function(frame) + draw=function(self,frame) frame.caption = {'GuiAnnouncements.name'} - local frame = frame.add{ + frame = frame.add{ type='flow', direction='vertical' } diff --git a/modules/GuiAnnouncements/softmod.json b/modules/GuiAnnouncements/softmod.json index bd79684b..9867fd84 100644 --- a/modules/GuiAnnouncements/softmod.json +++ b/modules/GuiAnnouncements/softmod.json @@ -1,20 +1,20 @@ { - "name": "GuiAnnouncements", - "version": "4.0.0", - "type": "Module", - "description": "Creates a gui for making and reciving announcements", - "location": "", - "keywords": [ - "Announcements", - "Gui", - "Admin" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "^4.0.0", - "ExpGamingCore.Gui": "^4.0.0" - } -} \ No newline at end of file + "name": "GuiAnnouncements", + "version": "4.0.0", + "description": "Creates a gui for making and reciving announcements", + "location": "FSM_ARCHIVE", + "keywords": [ + "Announcements", + "Gui", + "Admin" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Role": "^4.0.0", + "ExpGamingCore.Gui": "^4.0.0" + }, + "submodules": {} +} diff --git a/modules/HealthIndicator/control.lua b/modules/HealthIndicator/control.lua deleted file mode 100644 index 7da0b504..00000000 --- a/modules/HealthIndicator/control.lua +++ /dev/null @@ -1,47 +0,0 @@ ---- In game text float to desplay health to other players. --- @module HealthIndicator@1.0.1 --- @author Ps7cho (converted by Cooldude2606) --- @license https://opensource.org/licenses/MIT --- @alais ThisModule - --- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') - --- Local Varibles -local green = 200 -- above this makes text green -local yellow = 100 -- above this makes text yellow - --- Module Define -local module_verbose = false -local ThisModule = {} - --- Global Define -local global = global() - --- Event Handlers Define -script.on_event(defines.events.on_entity_damaged, function(event) - if event.entity.name ~= 'player' then return end - local player = Game.get_player(event.entity.player) - if player.character then - if player.character.health == nil then return end - local index = player.index - local health = math.ceil(player.character.health) - if global[index] == nil then global[index] = health end - if global[index] ~= health then - if health < global[index] then - local text = health..' (-'..math.floor(event.final_damage_amount)..')' - if health > green then - player.surface.create_entity{name="flying-text", color={b = 0.2, r= 0.1, g = 1, a = 0.8}, text=text, position= {player.position.x, player.position.y-2}} - elseif health > yellow then - player.surface.create_entity{name="flying-text", color={r = 1, g = 1, b = 0}, text=text, position= {player.position.x, player.position.y-2}} - else - player.surface.create_entity{name="flying-text", color={b = 0.1, r= 1, g = 0, a = 0.8}, text=text, position= {player.position.x, player.position.y-2}} - end - end - global[index] = health - end - end -end) - --- Module Return -return ThisModule \ No newline at end of file diff --git a/modules/HealthIndicator/softmod.json b/modules/HealthIndicator/softmod.json deleted file mode 100644 index 3aca69f7..00000000 --- a/modules/HealthIndicator/softmod.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "HealthIndicator", - "version": "1.0.1", - "type": "Module", - "description": "In game text float to desplay health to other players.", - "location": "", - "keywords": [ - "Health", - "Overlay", - "Text", - "Damage" - ], - "author": " Ps7cho (converted by Cooldude2606)", - "contact": "Discord: Cooldude2606#5241", - "license": "https://opensource.org/licenses/MIT", - "dependencies": { - "FactorioStdLib.Game": "^0.8.0" - } -} \ No newline at end of file diff --git a/modules/PlayerAutoColor/control.lua b/modules/PlayerAutoColor/control.lua index 3fb811cc..b4776c9e 100644 --- a/modules/PlayerAutoColor/control.lua +++ b/modules/PlayerAutoColor/control.lua @@ -2,10 +2,10 @@ -- @module PlayerAutoColor@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Color = require('FactorioStdLib.Color@^0.8.0') +local Color = require('FactorioStdLib.Color') -- Module Define local module_verbose = false @@ -28,7 +28,7 @@ local global = global{ } -- Event Handlers Define -Event.register(defines.events.on_player_created, function(event) +script.on_event(defines.events.on_player_created, function(event) local player = game.players[event.player_index] local colours = table.keys(defines.color) player.color = defines.color.black @@ -44,4 +44,4 @@ Event.register(defines.events.on_player_created, function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/PlayerAutoColor/softmod.json b/modules/PlayerAutoColor/softmod.json index b97444ef..d028bba7 100644 --- a/modules/PlayerAutoColor/softmod.json +++ b/modules/PlayerAutoColor/softmod.json @@ -1,19 +1,19 @@ { - "name": "PlayerAutoColor", - "version": "4.0.0", - "type": "Module", - "description": "Assigns random colours to players (larger range than default) and allows predefined colours for users.", - "location": "", - "keywords": [ - "Colour", - "Color", - "Player", - "Vibrant" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "FactorioStdLib.Color": "^0.8.0" - } -} \ No newline at end of file + "name": "PlayerAutoColor", + "version": "4.0.0", + "description": "Assigns random colours to players (larger range than default) and allows predefined colours for users.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Colour", + "Color", + "Player", + "Vibrant" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "FactorioStdLib.Color": "^0.8.0" + }, + "submodules": {} +} diff --git a/modules/SpawnArea/control.lua b/modules/SpawnArea/control.lua index 944e4760..d32258fd 100644 --- a/modules/SpawnArea/control.lua +++ b/modules/SpawnArea/control.lua @@ -2,12 +2,12 @@ -- @module SpawnArea@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') --- Local Varibles +-- Local Variables local turret_enabled = true local turret_ammo = 'uranium-rounds-magazine' @@ -17,8 +17,8 @@ local entity_positions = require(module_path..'/src/spawn_entities') local global_offset = {x=0,y=-2} local decon_radius = 20 local decon_tile = 'concrete' -local partern_radius = 50 -local partern_tile = 'stone-path' +local pattern_radius = 50 +local pattern_tile = 'stone-path' -- Module Define local module_verbose = false @@ -45,10 +45,10 @@ end function ThisModule.auto_turret(surface,pos) if not turret_enabled then error('Auto Turrets are disabled.') end - -- adds a new turrent to the global list, returns index + -- adds a new turret to the global list, returns index local _return if surface then - local surface = Game.get_surface(surface) + surface = Game.get_surface(surface) if not surface then error('Surface is not valid.') end local posx = pos.x or pos[1] or error('Position is not valid.') local posy = pos.y or pos[2] or error('Position is not valid.') @@ -57,7 +57,7 @@ function ThisModule.auto_turret(surface,pos) -- spawns turrets and refills them if not game.forces['spawn'] then game.create_force('spawn').set_cease_fire('player',true) game.forces['player'].set_cease_fire('spawn',true) end for _,pos in pairs(global) do - local surface = game.surfaces[pos[1]] + surface = game.surfaces[pos[1]] local turret = surface.find_entity('gun-turret',{pos[2],pos[3]}) if not turret then turret = surface.create_entity{name='gun-turret',position={pos[2],pos[3]},force='spawn'} @@ -83,34 +83,34 @@ script.on_event(defines.events.on_player_created, function(event) local player = Game.get_player(event) local surface = player.surface local offset = {x=0,y=0} - local partern_base_tile = surface.get_tile(player.position).name - if partern_base_tile == 'deepwater' or partern_base_tile == 'water' then partern_base_tile = 'grass-1' end + local pattern_base_tile = surface.get_tile(player.position).name + if pattern_base_tile == 'deepwater' or pattern_base_tile == 'water' then pattern_base_tile = 'grass-1' end local base_tiles = {} local tiles = {} - -- generates a safe area of land and removes all entites - for x = -partern_radius, partern_radius do - for y = -partern_radius, partern_radius do + -- generates a safe area of land and removes all entities + for x = -pattern_radius, pattern_radius do + for y = -pattern_radius, pattern_radius do if x^2+y^2 < decon_radius^2 then table.insert(base_tiles,{name=decon_tile,position={x+offset.x,y+offset.y}}) local entities = surface.find_entities_filtered{area={{x+offset.x-1,y+offset.y-1},{x+offset.x,y+offset.y}}} for _,entity in pairs(entities) do if entity.name ~= 'player' then entity.destroy() end end - elseif x^2+y^2 < partern_radius^2 then - table.insert(base_tiles,{name=partern_base_tile,position={x+offset.x,y+offset.y}}) + elseif x^2+y^2 < pattern_radius^2 then + table.insert(base_tiles,{name=pattern_base_tile,position={x+offset.x,y+offset.y}}) end end end surface.set_tiles(base_tiles) - -- creates the partern in the spawn + -- creates the pattern in the spawn for _,position in pairs(tile_positions) do - table.insert(tiles,{name=partern_tile,position={position[1]+offset.x+global_offset.x,position[2]+offset.y+global_offset.y}}) + table.insert(tiles,{name=pattern_tile,position={position[1]+offset.x+global_offset.x,position[2]+offset.y+global_offset.y}}) end surface.set_tiles(tiles) - -- spawns all the entites in spawn + -- spawns all the entities in spawn for _,entity in pairs(entity_positions) do - local entity = surface.create_entity{name=entity[1],position={entity[2]+offset.x+global_offset.x,entity[3]+offset.y+global_offset.y},force='neutral'} + entity = surface.create_entity{name=entity[1],position={entity[2]+offset.x+global_offset.x,entity[3]+offset.y+global_offset.y},force='neutral'} entity.destructible = false; entity.health = 0; entity.minable = false; entity.rotatable = false end - -- generates spawn turrents and afk belts + -- generates spawn turrets and afk belts if turret_enabled then ThisModule.auto_turret() end ThisModule.afk_belt(surface,{offset.x-5,offset.y-5}) ThisModule.afk_belt(surface,{offset.x+5,offset.y-5}) @@ -123,4 +123,4 @@ script.on_event(defines.events.on_player_created, function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/SpawnArea/softmod.json b/modules/SpawnArea/softmod.json index 90b98b82..240e1af4 100644 --- a/modules/SpawnArea/softmod.json +++ b/modules/SpawnArea/softmod.json @@ -1,19 +1,19 @@ { - "name": "SpawnArea", - "version": "4.0.0", - "type": "Module", - "description": "Creates a safe spawn area with chests and auto refilling turrets.", - "location": "", - "keywords": [ - "Spawn", - "Safe", - "Turrets", - "Auto Refill" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "FactorioStdLib.Game": "^0.8.0" - } -} \ No newline at end of file + "name": "SpawnArea", + "version": "4.0.0", + "description": "Creates a safe spawn area with chests and auto refilling turrets.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Spawn", + "Safe", + "Turrets", + "Auto Refill" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "FactorioStdLib.Game": "^0.8.0" + }, + "submodules": {} +} diff --git a/modules/WarpPoints/control.lua b/modules/WarpPoints/control.lua index 2674d4b8..42874bd4 100644 --- a/modules/WarpPoints/control.lua +++ b/modules/WarpPoints/control.lua @@ -2,14 +2,14 @@ -- @module WarpPoints@4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Gui = require('ExpGamingCore.Gui@^4.0.0') -local Game = require('FactorioStdLib.Game@^0.8.0') +local Gui = require('ExpGamingCore.Gui') +local Game = require('FactorioStdLib.Game') local Role -- ExpGamingCore.Role@^4.0.0 --- Local Varibles +-- Local Variables local warp_tiles = require(module_path..'/src/warp_tiles') local warp_entities = require(module_path..'/src/warp_entities') @@ -27,8 +27,8 @@ local global local module_verbose = false local ThisModule = { on_init=function(self) - if loaded_modules['ExpGamingCore.Role@^4.0.0'] then Role = require('ExpGamingCore.Role@^4.0.0') end - if loaded_modules['ExpGamingCore.Command@^4.0.0'] then require(module_path..'/src/commands',{self=self,warps=global,warp_min_distance=warp_min_distance}) end + if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') end + if loaded_modules['ExpGamingCore.Command'] then require(module_path..'/src/commands',{self=self,warps=global,warp_min_distance=warp_min_distance}) end end } @@ -49,7 +49,6 @@ function ThisModule.remove_warp_point(name) local surface = game.surfaces[warp.surface] local offset = warp.position local tiles = {} - local tiles = {} -- clears the area where the warp was for x = -warp_radius, warp_radius do for y = -warp_radius, warp_radius do @@ -72,9 +71,9 @@ end -- @tparam surface surface the surface that the warp point is on -- @tparam force force the force that the warp point will belong to -- @tparam string name the name of the warp point to be made -function ThisModule.make_warp_point(position,surface,force,name) - local warp = global.warps[name] - if warp then return end; warp = nil +function ThisModule.make_warp_point(position,surface,force,warpName) + local warp = global.warps[warpName] + if warp then return end local offset = {x=math.floor(position.x),y=math.floor(position.y)} local old_tile = surface.get_tile(offset).name local base_tiles = {} @@ -88,22 +87,22 @@ function ThisModule.make_warp_point(position,surface,force,name) end end surface.set_tiles(base_tiles) - -- this adds the patern and entities - for _,position in pairs(warp_tiles) do - table.insert(tiles,{name=warp_tile,position={position[1]+offset.x+global_offset.x,position[2]+offset.y+global_offset.y}}) + -- this adds the pattern and entities + for _,pos in pairs(warp_tiles) do + table.insert(tiles,{name=warp_tile,position={pos[1]+offset.x+global_offset.x,pos[2]+offset.y+global_offset.y}}) end surface.set_tiles(tiles) for _,entity in pairs(warp_entities) do - local entity = surface.create_entity{name=entity[1],position={entity[2]+offset.x+global_offset.x,entity[3]+offset.y+global_offset.y},force='neutral'} + entity = surface.create_entity{name=entity[1],position={entity[2]+offset.x+global_offset.x,entity[3]+offset.y+global_offset.y},force='neutral'} entity.destructible = false; entity.health = 0; entity.minable = false; entity.rotatable = false end -- creates a tag on the map for the wap point local tag = force.add_chart_tag(surface,{ position={offset.x+0.5,offset.y+0.5}, - text='Warp: '..name, + text='Warp: '..warpName, icon={type='item',name=warp_item} }) - global.warps[name] = {tag=tag,surface=surface.index,position=tag.position,old_tile=old_tile} + global.warps[warpName] = {tag=tag,surface=surface.index,position=tag.position,old_tile=old_tile} local _temp = {Spawn=global.warps.Spawn} global.warps.Spawn = nil for name,data in pairs(table.keysort(global.warps)) do _temp[name] = data end @@ -145,7 +144,7 @@ ThisModule.Gui = Gui.left{ name='warp-list', caption='item/'..warp_item, tooltip={'WarpPoints.tooltip'}, - draw=function(frame) + draw=function(self,frame) local player = Game.get_player(frame.player_index) frame.caption={'WarpPoints.name'} local warp_list = frame.add{ @@ -190,7 +189,7 @@ ThisModule.Gui = Gui.left{ if cooldown > 0 then frame.style.visible = false return elseif not Role and player.admin or Role and Role.allowed(player,'always-warp') then return elseif player.surface.get_tile(player.position).name == warp_tile - and player.surface.name == 'nauvis' + and player.surface.name == 'nauvis' then return elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then return else frame.style.visible = false end @@ -199,7 +198,7 @@ ThisModule.Gui = Gui.left{ local cooldown = global.cooldowns[player.index] or 0 if not Role and player.admin or Role and Role.allowed(player,'always-warp') then return true elseif player.surface.get_tile(player.position).name == warp_tile - and player.surface.name == 'nauvis' + and player.surface.name == 'nauvis' then return true elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then return true elseif cooldown > 0 then return {'WarpPoints.cooldown',cooldown} @@ -213,7 +212,7 @@ script.on_event(defines.events.on_tick,function(event) if not (event.tick % 60 == 0) then return end for index,time in pairs(global.cooldowns) do if time > 0 then - global.cooldowns[index] = time-1 + global.cooldowns[index] = time-1 if global.cooldowns[index] == 0 then player_return({'WarpPoints.cooldown-zero'},defines.textcolor.low,index) end end end @@ -224,9 +223,9 @@ script.on_event(defines.events.on_player_changed_position, function(event) local cooldown = global.cooldowns[player.index] or 0 local tile = player.surface.get_tile(player.position).name if not Role and player.admin or Role and not Role.allowed(player,'always-warp') and cooldown == 0 then - if tile == warp_tile and player.surface.name == 'nauvis' then + if tile == warp_tile and player.surface.name == 'nauvis' then ThisModule.Gui:open(player) - elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then + elseif player.position.x^2+player.position.y^2 < (warp_radius*spawn_warp_scale)^2 then ThisModule.Gui:open(player) else ThisModule.Gui:close(player) end end @@ -246,4 +245,4 @@ script.on_event(defines.events.on_player_created, function(event) end) -- Module Return -return ThisModule \ No newline at end of file +return ThisModule \ No newline at end of file diff --git a/modules/WarpPoints/softmod.json b/modules/WarpPoints/softmod.json index bb6449e4..82df5531 100644 --- a/modules/WarpPoints/softmod.json +++ b/modules/WarpPoints/softmod.json @@ -1,22 +1,22 @@ { - "name": "WarpPoints", - "version": "4.0.0", - "type": "Module", - "description": "Creates a warp point system which makes moving around large maps easier.", - "location": "", - "keywords": [ - "Warps", - "System", - "Teleport", - "PAX" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "FactorioStdLib.Game": "^0.8.0", - "ExpGamingCore.Role": "?^4.0.0", - "ExpGamingCore.Command": "?^4.0.0", - "ExpGamingCore.Gui": "^4.0.0" - } -} \ No newline at end of file + "name": "WarpPoints", + "version": "4.0.0", + "description": "Creates a warp point system which makes moving around large maps easier.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Warps", + "System", + "Teleport", + "PAX" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "FactorioStdLib.Game": "^0.8.0", + "ExpGamingCore.Role": "?^4.0.0", + "ExpGamingCore.Command": "?^4.0.0", + "ExpGamingCore.Gui": "^4.0.0" + }, + "submodules": {} +} diff --git a/modules/WarpPoints/src/commands.lua b/modules/WarpPoints/src/commands.lua index 89e4cb2b..9fe0e436 100644 --- a/modules/WarpPoints/src/commands.lua +++ b/modules/WarpPoints/src/commands.lua @@ -8,6 +8,7 @@ commands.add_command('make-warp', 'Make a warp point at your location', { if not game.player then return end local position = game.player.position local name = args.name + if name:len() > 40 then player_return({'ExpGamingCore_Command.error-string-len',40},defines.textcolor.med) return commands.error end if game.player.gui.top[name] then player_return({'WarpPoints.name-used'},defines.textcolor.med) return commands.error end if warps.warps[name] then player_return({'WarpPoints.name-used'},defines.textcolor.med) return commands.error end for name,warp in pairs(warps.warps) do diff --git a/modules/WornPaths/control.lua b/modules/WornPaths/control.lua index d8842d42..1ccf1830 100644 --- a/modules/WornPaths/control.lua +++ b/modules/WornPaths/control.lua @@ -1,19 +1,19 @@ ---- Makes paths which wear down and paths where entites are placed. +--- Makes paths which wear down and paths where entities are placed. -- @module WornPaths@^4.0.0 -- @author Cooldude2606 -- @license https://github.com/explosivegaming/scenario/blob/master/LICENSE --- @alais ThisModule +-- @alias ThisModule -- Module Require -local Game = require('FactorioStdLib.Game@^0.8.0') +local Game = require('FactorioStdLib.Game') --- Local Varibles -local entites = require(module_path..'/src/entites') +-- Local Variables +local entities = require(module_path..'/src/entites') local paths = require(module_path..'/src/paths') -for tile,value in pairs(paths) do value[1]=-1/value[1] end +for _,value in pairs(paths) do value[1]=-1/value[1] end local placed_paths = require(module_path..'/src/placed') -local adjacency_boost = 2 -- makes paths more lickly to be next to each other; must be greater than 0 +local adjacency_boost = 2 -- makes paths more likely to be next to each other; must be greater than 0 adjacency_boost = 10/adjacency_boost -- dont change this line -- Module Define @@ -28,7 +28,7 @@ local function global_key(surface,pos) return 'S'..surface.name..'X'..math.floor(pos.x)..'Y'..math.floor(pos.y) end ---- Downgrads a tile in this position +--- Downgrades a tile in this position -- @usage ThisModule.down_grade(surface,{x=10,y=10}) -- @tparam surface surface the surface the tile is on -- @tparam table pos the position of the tile to change @@ -36,7 +36,7 @@ function ThisModule.down_grade(surface,pos) local tile = surface.get_tile(pos).name local new_tile = paths[tile][2] if new_tile == 'world-gen' then - new_tile = global[global_key(surface,pos)] or 'grass-1' + new_tile = global[global_key(surface,pos)] or 'grass-1' end surface.set_tiles{{name=new_tile,position=pos}} end @@ -46,15 +46,15 @@ script.on_event({defines.events.on_player_built_tile,defines.events.on_robot_bui local surface = event.surface_index and game.surfaces[event.surface_index] or event.robot and event.robot.surface local old_tiles = event.tiles for _,old_tile in pairs(old_tiles) do - if placed_paths[old_tile.old_tile.name] or old_tile.old_tile.name == 'water' or old_tile.old_tile.name == 'deepwater' then else - global[global_key(surface,old_tile.position)]=old_tile.old_tile.name -- not a mistake, this makes it have dimising returns + if not placed_paths[old_tile.old_tile.name] and old_tile.old_tile.name ~= 'water' and old_tile.old_tile.name ~= 'deepwater' then + global[global_key(surface,old_tile.position)]=old_tile.old_tile.name -- not a mistake, this makes it have demising returns end end end) script.on_event(defines.events.on_player_changed_position, function(event) local player = Game.get_player(event) - if player and player.valid and game.tick > 10 then else return end + if not player or not player.valid or game.tick < 10 then return end if player.afk_time > 300 then return end local surface = player.surface local pos = player.position @@ -76,7 +76,7 @@ end) script.on_event({defines.events.on_built_entity,on_robot_built_entity}, function(event) local entity = event.created_entity local surface = entity.surface - if entites[entity.name] then + if entities[entity.name] then local box = entity.prototype.collision_box for x = box.left_top.x,box.right_bottom.x do for y = box.left_top.y,box.right_bottom.y do local pos = {x=entity.position.x+x,y=entity.position.y+y} @@ -87,17 +87,17 @@ script.on_event({defines.events.on_built_entity,on_robot_built_entity}, function end) -- Module Return -- when called it will downgrade a tile -return setmetatable(ThisModule,{__call=function(self,...) self.down_grade(...) end}) +return setmetatable(ThisModule,{__call=function(self,...) self.down_grade(...) end}) --[[ -/interface -local tile_name = surface.get_tile(position).name +/interface +local tile_name = surface.get_tile(position).name if not paths[tile_name] then return end local count = -9 -- this value is important for x = -1,1 do for y = -1,1 do local _pos = {position.x+x,position.y+y} - if placed_paths[tile_name] and not placed_paths[surface.get_tile(_pos).name] - or surface.get_tile(_pos).name == paths[tile_name][2] + if placed_paths[tile_name] and not placed_paths[surface.get_tile(_pos).name] + or surface.get_tile(_pos).name == paths[tile_name][2] then count=count+1 end end end return paths[tile_name][1]/(count-adjacency_boost) diff --git a/modules/WornPaths/softmod.json b/modules/WornPaths/softmod.json index 480376e2..1b1a489a 100644 --- a/modules/WornPaths/softmod.json +++ b/modules/WornPaths/softmod.json @@ -1,19 +1,19 @@ { - "name": "WornPaths", - "version": "4.0.0", - "type": "Module", - "description": "Makes paths which wear down and paths where entites are placed.", - "location": "", - "keywords": [ - "Paths", - "Worn", - "Decay", - "Degrade" - ], - "author": "Cooldude2606", - "contact": "Discord: Cooldude2606#5241", - "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", - "dependencies": { - "FactorioStdLib.Game": "^0.8.0" - } -} \ No newline at end of file + "name": "WornPaths", + "version": "4.0.0", + "description": "Makes paths which wear down and paths where entites are placed.", + "location": "FSM_ARCHIVE", + "keywords": [ + "Paths", + "Worn", + "Decay", + "Degrade" + ], + "author": "Cooldude2606", + "contact": "Discord: Cooldude2606#5241", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "dependencies": { + "FactorioStdLib.Game": "^0.8.0" + }, + "submodules": {} +} diff --git a/modules/index.lua b/modules/index.lua index c92d71cf..d48bd875 100644 --- a/modules/index.lua +++ b/modules/index.lua @@ -1,81 +1,67 @@ -- not_luadoc=true --- Used to index the files to be loaded return { - ['FactorioStdLib.String@^0.8.0']='./modules/FactorioStdLib/String', - ['FactorioStdLib.String@0.8.0']='./modules/FactorioStdLib/String', - ['FactorioStdLib.Table@^0.8.0']='./modules/FactorioStdLib/Table', - ['FactorioStdLib.Table@0.8.0']='./modules/FactorioStdLib/Table', - ['FactorioStdLib.Game@^0.8.0']='./modules/FactorioStdLib/Game', - ['DeathMarkers@4.0.0']='./modules/DeathMarkers', - ['FactorioStdLib.Color@^0.8.0']='./modules/FactorioStdLib/Color', - ['FactorioStdLib.Color@0.8.0']='./modules/FactorioStdLib/Color', - ['PlayerAutoColor@4.0.0']='./modules/PlayerAutoColor', - ['DamagePopup@4.0.0']='./modules/DamagePopup', - ['FactorioStdLib.Game@0.8.0']='./modules/FactorioStdLib/Game', - ['WornPaths@4.0.0']='./modules/WornPaths', - ['SpawnArea@4.0.0']='./modules/SpawnArea', - ['HealthIndicator@1.0.1']='./modules/HealthIndicator', - ['FactorioStdLib@^0.8.0']='./modules/FactorioStdLib', - ['FactorioStdLib@0.8.0']='./modules/FactorioStdLib', - ['ExpGamingLib@^4.0.0']='./modules/ExpGamingLib', - ['ExpGamingLib@4.0.0']='./modules/ExpGamingLib', - ['ExpGamingCore.Command@^4.0.0']='./modules/ExpGamingCore/Command', - ['ExpGamingCore.Server@^4.0.0']='./modules/ExpGamingCore/Server', - ['ExpGamingCore.Command@4.0.0']='./modules/ExpGamingCore/Command', - ['ExpGamingCommands.home@4.0.0']='./modules/ExpGamingCommands/home', - ['ExpGamingCommands.cheatMode@4.0.0']='./modules/ExpGamingCommands/cheatMode', - ['ExpGamingCore.Server@4.0.0']='./modules/ExpGamingCore/Server', - ['ExpGamingCore.Group@^4.0.0']='./modules/ExpGamingCore/Group', - ['ExpGamingCore.Group@4.0.0']='./modules/ExpGamingCore/Group', - ['ExpGamingCore.Role@^4.0.0']='./modules/ExpGamingCore/Role', - ['ExpGamingCore.Role@4.0.0']='./modules/ExpGamingCore/Role', - ['ExpGamingCommands.tags@4.0.0']='./modules/ExpGamingCommands/tags', - ['ExpGamingCommands.kill@4.0.0']='./modules/ExpGamingCommands/kill', - ['ExpGamingCommands.bonus@4.0.0']='./modules/ExpGamingCommands/bonus', - ['ExpGamingBot.autoChat@4.0.0']='./modules/ExpGamingBot/autoChat', - ['ExpGamingCore.Gui@^4.0.0']='./modules/ExpGamingCore/Gui', - ['ExpGamingCore.Gui@4.0.0']='./modules/ExpGamingCore/Gui', - ['WarpPoints@4.0.0']='./modules/WarpPoints', - ['GuiAnnouncements@4.0.0']='./modules/GuiAnnouncements', - ['GameSettingsGui@4.0.0']='./modules/GameSettingsGui', - ['ExpGamingInfo.Tasklist@4.0.0']='./modules/ExpGamingInfo/Tasklist', - ['ExpGamingCore.Sync@^4.0.0']='./modules/ExpGamingCore/Sync', - ['ExpGamingPlayer.polls@4.0.0']='./modules/ExpGamingPlayer/polls', - ['ExpGamingPlayer.playerInfo@4.0.0']='./modules/ExpGamingPlayer/playerInfo', - ['ExpGamingPlayer.afkKick@4.0.0']='./modules/ExpGamingPlayer/afkKick', - ['ExpGamingCore.Sync@4.0.0']='./modules/ExpGamingCore/Sync', - ['ExpGamingInfo.Science@4.0.0']='./modules/ExpGamingInfo/Science', - ['ExpGamingInfo.Rockets@4.0.0']='./modules/ExpGamingInfo/Rockets', - ['ExpGamingInfo.Readme@4.0.0']='./modules/ExpGamingInfo/Readme', - ['ExpGamingInfo@4.0.0']='./modules/ExpGamingInfo', - ['ExpGamingCore@4.0.0']='./modules/ExpGamingCore', - ['ExpGamingBot.discordAlerts@4.0.0']='./modules/ExpGamingBot/discordAlerts', - ['ExpGamingBot.autoMessage@4.0.0']='./modules/ExpGamingBot/autoMessage', - ['ExpGamingBot@4.0.0']='./modules/ExpGamingBot', - ['ExpGamingAdmin.AdminLib@^4.0.0']='./modules/ExpGamingAdmin/AdminLib', - ['ExpGamingAdmin.AdminLib@4.0.0']='./modules/ExpGamingAdmin/AdminLib', - ['ExpGamingAdmin.TempBan@^4.0.0']='./modules/ExpGamingAdmin/TempBan', - ['ExpGamingAdmin.ClearInventory@4.0.0']='./modules/ExpGamingAdmin/ClearInventory', - ['ExpGamingAdmin.TempBan@4.0.0']='./modules/ExpGamingAdmin/TempBan', - ['ExpGamingCommands.repair@4.0.0']='./modules/ExpGamingCommands/repair', - ['ExpGamingPlayer.playerList@4.0.0']='./modules/ExpGamingPlayer/playerList', - ['ExpGamingAdmin.Reports@4.0.0']='./modules/ExpGamingAdmin/Reports', - ['ExpGamingAdmin.Warnings@^4.0.0']='./modules/ExpGamingAdmin/Warnings', - ['ExpGamingAdmin.Warnings@4.0.0']='./modules/ExpGamingAdmin/Warnings', - ['ExpGamingPlayer.inventorySearch@4.0.0']='./modules/ExpGamingPlayer/inventorySearch', - ['ExpGamingPlayer@4.0.0']='./modules/ExpGamingPlayer', - ['ExpGamingAdmin.Gui@^4.0.0']='./modules/ExpGamingAdmin/Gui', - ['ExpGamingAdmin.Gui@4.0.0']='./modules/ExpGamingAdmin/Gui', - ['ExpGamingAdmin.Teleport@^4.0.0']='./modules/ExpGamingAdmin/Teleport', - ['ExpGamingAdmin.Teleport@4.0.0']='./modules/ExpGamingAdmin/Teleport', - ['ExpGamingCommands.teleport@4.0.0']='./modules/ExpGamingCommands/teleport', - ['ExpGamingCommands@4.0.0']='./modules/ExpGamingCommands', - ['ExpGamingAdmin.Kick@4.0.0']='./modules/ExpGamingAdmin/Kick', - ['ExpGamingAdmin.Jail@4.0.0']='./modules/ExpGamingAdmin/Jail', - ['ExpGamingAdmin.Commands@4.0.0']='./modules/ExpGamingAdmin/Commands', - ['ExpGamingAdmin.Ban@4.0.0']='./modules/ExpGamingAdmin/Ban', - ['ExpGamingAdmin@4.0.0']='./modules/ExpGamingAdmin', - ['DeconControl@4.0.0']='./modules/DeconControl', - ['ChatPopup@4.0.0']='./modules/ChatPopup', - ['AdvancedStartingItems@4.0.0']='./modules/AdvancedStartingItems', + ['AdvancedStartingItems']={'./modules/AdvancedStartingItems',}, + ['ChatPopup']={'./modules/ChatPopup','FactorioStdLib.Game','FactorioStdLib.Color'}, + ['DamagePopup']={'./modules/DamagePopup','FactorioStdLib.Color'}, + ['DeathMarkers']={'./modules/DeathMarkers',}, + ['DeconControl']={'./modules/DeconControl','ExpGamingCore.Server','FactorioStdLib.Game','ExpGamingLib'}, + ['ExpGamingAdmin']={'./modules/ExpGamingAdmin','FactorioStdLib.Game'}, + ['ExpGamingBot']={'./modules/ExpGamingBot',}, + ['ExpGamingCommands']={'./modules/ExpGamingCommands',}, + ['ExpGamingCore']={'./modules/ExpGamingCore',}, + ['ExpGamingInfo']={'./modules/ExpGamingInfo',}, + ['ExpGamingLib']={'./modules/ExpGamingLib','FactorioStdLib.Game','FactorioStdLib.Color','FactorioStdLib.Table'}, + ['ExpGamingPlayer']={'./modules/ExpGamingPlayer',}, + ['FactorioStdLib']={'./modules/FactorioStdLib',}, + ['GameSettingsGui']={'./modules/GameSettingsGui','ExpGamingCore.Server','ExpGamingCore.Gui'}, + ['GuiAnnouncements']={'./modules/GuiAnnouncements','FactorioStdLib.Game','ExpGamingCore.Role','ExpGamingCore.Gui'}, + ['PlayerAutoColor']={'./modules/PlayerAutoColor','FactorioStdLib.Color'}, + ['SpawnArea']={'./modules/SpawnArea','FactorioStdLib.Game'}, + ['WarpPoints']={'./modules/WarpPoints','FactorioStdLib.Game','ExpGamingCore.Gui'}, + ['WornPaths']={'./modules/WornPaths','FactorioStdLib.Game'}, + ['ExpGamingAdmin.Gui']={'./modules/ExpGamingAdmin/Gui','ExpGamingAdmin.AdminLib','ExpGamingCore.Gui','ExpGamingCore.Role','FactorioStdLib.Game','mod-gui'}, + ['ExpGamingAdmin.Ban']={'./modules/ExpGamingAdmin/Ban','ExpGamingAdmin.AdminLib','ExpGamingAdmin.Gui','ExpGamingCore.Server','FactorioStdLib.Game'}, + ['ExpGamingAdmin.Reports']={'./modules/ExpGamingAdmin/Reports','ExpGamingAdmin.AdminLib','ExpGamingCore.Server','ExpGamingCore.Role','FactorioStdLib.Game','ExpGamingCore.Gui'}, + ['ExpGamingAdmin.ClearInventory']={'./modules/ExpGamingAdmin/ClearInventory','ExpGamingAdmin.AdminLib','FactorioStdLib.Game'}, + ['ExpGamingAdmin.TempBan']={'./modules/ExpGamingAdmin/TempBan','ExpGamingAdmin.AdminLib','ExpGamingCore.Server','ExpGamingCore.Role','FactorioStdLib.Game'}, + ['ExpGamingAdmin.Teleport']={'./modules/ExpGamingAdmin/Teleport','ExpGamingAdmin.AdminLib','ExpGamingAdmin.Gui','FactorioStdLib.Game'}, + ['ExpGamingAdmin.Commands']={'./modules/ExpGamingAdmin/Commands','ExpGamingLib','ExpGamingCore.Command','ExpGamingAdmin.AdminLib'}, + ['ExpGamingAdmin.Jail']={'./modules/ExpGamingAdmin/Jail','ExpGamingAdmin.AdminLib','ExpGamingAdmin.Gui','ExpGamingCore.Server','ExpGamingCore.Role','FactorioStdLib.Game'}, + ['ExpGamingAdmin.Warnings']={'./modules/ExpGamingAdmin/Warnings','ExpGamingAdmin.AdminLib','ExpGamingCore.Server','ExpGamingCore.Role','FactorioStdLib.Game'}, + ['ExpGamingAdmin.Kick']={'./modules/ExpGamingAdmin/Kick','ExpGamingAdmin.AdminLib','ExpGamingAdmin.Gui','ExpGamingCore.Server','FactorioStdLib.Game'}, + ['ExpGamingBot.autoMessage']={'./modules/ExpGamingBot/autoMessage','ExpGamingCore.Server','FactorioStdLib.Game'}, + ['ExpGamingBot.discordAlerts']={'./modules/ExpGamingBot/discordAlerts','ExpGamingCore.Sync','FactorioStdLib.Color','FactorioStdLib.Game'}, + ['ExpGamingBot.autoChat']={'./modules/ExpGamingBot/autoChat','FactorioStdLib.Game','ExpGamingCore.Server'}, + ['ExpGamingCommands.cheatMode']={'./modules/ExpGamingCommands/cheatMode','ExpGamingCore.Command'}, + ['ExpGamingCommands.repair']={'./modules/ExpGamingCommands/repair','ExpGamingLib','FactorioStdLib.Game','ExpGamingCore.Role'}, + ['ExpGamingCommands.tags']={'./modules/ExpGamingCommands/tags','ExpGamingLib','ExpGamingCore.Command','FactorioStdLib.Game'}, + ['ExpGamingCommands.home']={'./modules/ExpGamingCommands/home','FactorioStdLib.Game','ExpGamingCore.Command'}, + ['ExpGamingCore.Command']={'./modules/ExpGamingCore/Command','ExpGamingLib','FactorioStdLib.Table','FactorioStdLib.Color','FactorioStdLib.Game'}, + ['ExpGamingCommands.teleport']={'./modules/ExpGamingCommands/teleport','ExpGamingCore.Command','ExpGamingAdmin.Teleport','ExpGamingAdmin.AdminLib'}, + ['ExpGamingCommands.bonus']={'./modules/ExpGamingCommands/bonus','FactorioStdLib.Game','ExpGamingLib','ExpGamingCore.Command','ExpGamingCore.Role'}, + ['ExpGamingCommands.kill']={'./modules/ExpGamingCommands/kill','ExpGamingCore.Command','ExpGamingCore.Role','FactorioStdLib.Game'}, + ['ExpGamingCore.Server']={'./modules/ExpGamingCore/Server','ExpGamingLib','FactorioStdLib.Table','FactorioStdLib.Color','FactorioStdLib.String','FactorioStdLib.Game'}, + ['ExpGamingCore.Gui']={'./modules/ExpGamingCore/Gui','ExpGamingLib','FactorioStdLib.Table','FactorioStdLib.Color','FactorioStdLib.Game'}, + ['ExpGamingInfo.Science']={'./modules/ExpGamingInfo/Science','ExpGamingCore.Gui','FactorioStdLib.Game'}, + ['ExpGamingPlayer.playerList']={'./modules/ExpGamingPlayer/playerList','FactorioStdLib.Game','ExpGamingCore.Gui'}, + ['ExpGamingCore.Sync']={'./modules/ExpGamingCore/Sync','ExpGamingLib','FactorioStdLib.Color','FactorioStdLib.Game','FactorioStdLib.Table'}, + ['ExpGamingCore.Role']={'./modules/ExpGamingCore/Role','ExpGamingLib','FactorioStdLib.Table','FactorioStdLib.Game','ExpGamingCore.Group'}, + ['ExpGamingInfo.Readme']={'./modules/ExpGamingInfo/Readme','ExpGamingCore.Gui','FactorioStdLib.Game'}, + ['ExpGamingInfo.Rockets']={'./modules/ExpGamingInfo/Rockets','ExpGamingCore.Gui','FactorioStdLib.Game'}, + ['ExpGamingCore.Group']={'./modules/ExpGamingCore/Group','FactorioStdLib','ExpGamingLib','FactorioStdLib.Game'}, + ['ExpGamingInfo.Tasklist']={'./modules/ExpGamingInfo/Tasklist','ExpGamingCore.Gui','ExpGamingCore.Role','FactorioStdLib.Game'}, + ['ExpGamingPlayer.playerInfo']={'./modules/ExpGamingPlayer/playerInfo','FactorioStdLib.Game','ExpGamingCore.Gui'}, + ['ExpGamingPlayer.afkKick']={'./modules/ExpGamingPlayer/afkKick','FactorioStdLib.Game','ExpGamingCore.Gui'}, + ['FactorioStdLib.Table']={'./modules/FactorioStdLib/Table',}, + ['ExpGamingPlayer.polls']={'./modules/ExpGamingPlayer/polls','ExpGamingCore.Gui','ExpGamingCore.Server'}, + ['FactorioStdLib.Color']={'./modules/FactorioStdLib/Color',}, + ['FactorioStdLib.Game']={'./modules/FactorioStdLib/Game',}, + ['FactorioStdLib.String']={'./modules/FactorioStdLib/String',}, + ['ExpGamingPlayer.inventorySearch']={'./modules/ExpGamingPlayer/inventorySearch','ExpGamingLib','ExpGamingAdmin.TempBan','ExpGamingAdmin.Warnings','FactorioStdLib.Game','ExpGamingAdmin.AdminLib'}, + ['ExpGamingCore.Gui.center']={'./modules/ExpGamingCore/Gui/center','mod-gui','FactorioStdLib.Game','FactorioStdLib.Color','ExpGamingCore.Gui','ExpGamingCore.Gui.inputs'}, + ['ExpGamingCore.Gui.popup']={'./modules/ExpGamingCore/Gui/popup','mod-gui','FactorioStdLib.Game','ExpGamingCore.Gui','ExpGamingCore.Gui.inputs'}, + ['ExpGamingCore.Gui.toolbar']={'./modules/ExpGamingCore/Gui/toolbar','mod-gui','FactorioStdLib.Game','ExpGamingCore.Gui','ExpGamingCore.Gui.inputs'}, + ['ExpGamingCore.Gui.left']={'./modules/ExpGamingCore/Gui/left','mod-gui','FactorioStdLib.Game','ExpGamingCore.Server','FactorioStdLib.Color','ExpGamingCore.Gui','ExpGamingCore.Gui.inputs'}, + ['ExpGamingCore.Gui.inputs']={'./modules/ExpGamingCore/Gui/inputs','mod-gui','FactorioStdLib.Color','FactorioStdLib.Game','ExpGamingCore.Gui'}, } \ No newline at end of file diff --git a/modules/softmod.json b/modules/softmod.json new file mode 100644 index 00000000..d74c2446 --- /dev/null +++ b/modules/softmod.json @@ -0,0 +1,33 @@ +{ + "name": "ExpGamingScenario", + "version": "4.0.0", + "description": "The basic scenario used on ExpGaming public servers", + "author": "ExpGaming", + "contact": "https://explosivegaming.nl", + "license": "https://github.com/explosivegaming/scenario/blob/master/LICENSE", + "keywords": [ + "ExpGaming", + "Vanila Plus" + ], + "softmods": { + "AdvancedStartingItems": "4.0.0", + "ChatPopup": "4.0.0", + "DamagePopup": "4.0.0", + "DeathMarkers": "4.0.0", + "DeconControl": "4.0.0", + "ExpGamingAdmin": "4.0.0", + "ExpGamingBot": "4.0.0", + "ExpGamingCommands": "4.0.0", + "ExpGamingCore": "4.0.0", + "ExpGamingInfo": "4.0.0", + "ExpGamingLib": "4.0.0", + "ExpGamingPlayer": "4.0.0", + "FactorioStdLib": "0.8.0", + "GameSettingsGui": "4.0.0", + "GuiAnnouncements": "4.0.0", + "PlayerAutoColor": "4.0.0", + "SpawnArea": "4.0.0", + "WarpPoints": "4.0.0", + "WornPaths": "4.0.0" + } +} diff --git a/softmod.json b/softmod.json deleted file mode 100644 index 3790c5d1..00000000 --- a/softmod.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "name": "ExpGamingScenario", - "version": "0.16.51", - "type": "Scenario", - "description": "Explosive gaming's factorio secenario ran on every public server", - "modules": { - "ExpGamingCore": "^4.0.0", - "ExpGamingLib": "^4.0.0", - "FactorioStdLib.Color": "^0.8.0", - "FactorioStdLib.Game": "^0.8.0", - "FactorioStdLib.String": "^0.8.0", - "FactorioStdLib.Table": "^0.8.0", - "FactorioStdLib": "^0.8.0", - "ExpGamingCommands": "^4.0.0", - "ExpGamingPlayer": "^4.0.0", - "ExpGamingAdmin": "^4.0.0", - "ExpGamingBot": "^4.0.0", - "AdvancedStartingItems": "^4.0.0", - "ChatPopup": "^4.0.0", - "DamagePopup": "^4.0.0", - "DeathMarkers": "^4.0.0", - "DeconControl": "^4.0.0", - "ExpGamingInfo": "^4.0.0", - "GameSettingsGui": "^4.0.0", - "GuiAnnouncements": "^4.0.0", - "HealthIndicator": "^1.0.1", - "PlayerAutoColor": "^4.0.0", - "SpawnArea": "^4.0.0", - "WarpPoints": "^4.0.0", - "WornPaths": "^4.0.0" - } -} \ No newline at end of file