Added Module: ExpGamingCore

This commit is contained in:
Cooldude2606
2018-05-30 13:50:38 +01:00
parent eeb44c0c93
commit 24598e594a
33 changed files with 250 additions and 189 deletions

View File

@@ -1,10 +0,0 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
Contact a member of management on our discord to seek permission to use our code.
Any changes that you may make to the code are yours but that does not make the script yours.
Discord: https://discord.gg/r6dC2uK
]]
--Please Only Edit Below This Line-----------------------------------------------------------
-- this file will just contain all the diffrent requires

View File

@@ -1,43 +0,0 @@
--[[
Explosive Gaming
This file can be used with permission but this and the credit below must remain in the file.
Contact a member of management on our discord to seek permission to use our code.
Any changes that you may make to the code are yours but that does not make the script yours.
Discord: https://discord.gg/r6dC2uK
]]
--[[
ExpCore
This file allow you to only require this one file to return the diffent libarys.
This file will return a function which can be used to access only the part you want.
Pass a table with the names of the objects you want and it will be return in that order
]]
local StdExpCoreLib = {}
require('commands')
StdExpCoreLib.Ranking = require('ranking')
StdExpCoreLib.Server = require('server')
StdExpCoreLib.Sync = require('sync')
StdExpCoreLib.Gui = require('gui')
verbose('Begain Gui Part Loading')
StdExpCoreLib.Gui:_load_parts{
'inputs',
'toolbar',
'center',
'left',
'popup'
}
return function(rtn)
local _return = {}
for _,name in pairs(rtn) do
if StdExpCoreLib[name] then
verbose('Core File Extraction: '..name)
table.insert(_return,StdExpCoreLib[name])
end
end
return unpack(_return)
end

View File

@@ -74,7 +74,7 @@ Manager.verbose = function(rtn,action)
else rtn='[FSM] '..tostring(rtn) end else rtn='[FSM] '..tostring(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 -- 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 -- if action is true then it will always trigger verbose
if module_verbose or action and (action == true or settings[action]) or settings[state] then if module_verbose or action and (action == true or settings[action]) or (not action and settings[state]) then
if type(settings.output) == 'function' then if type(settings.output) == 'function' then
-- calls the output function, not pcalled as if this fails some thing is very wrong -- calls the output function, not pcalled as if this fails some thing is very wrong
settings.output(rtn) settings.output(rtn)
@@ -159,10 +159,12 @@ Manager.sandbox = setmetatable({
module_exports=false module_exports=false
},{ },{
__metatable=false, __metatable=false,
__index=ReadOnlyManager,
__call=function(tbl,callback,env,...) __call=function(tbl,callback,env,...)
if type(callback) == 'function' then if type(callback) == 'function' then
-- creates a new sandbox env -- creates a new sandbox env
local sandbox = tbl() local sandbox = tbl()
local env = type(env) == 'table' and env or type(env) ~= 'nil' and {env} or {}
-- new indexs are saved into sandbox and if _G does not have the index then look in sandbox -- new indexs are saved into sandbox and if _G does not have the index then look in sandbox
setmetatable(env,{__index=sandbox}) setmetatable(env,{__index=sandbox})
setmetatable(_G,{__index=env,__newindex=sandbox}) setmetatable(_G,{__index=env,__newindex=sandbox})
@@ -190,17 +192,17 @@ Manager.loadModules = setmetatable({},
-- ReadOnlyManager used to trigger verbose change -- ReadOnlyManager used to trigger verbose change
ReadOnlyManager.currentState = 'moduleLoad' ReadOnlyManager.currentState = 'moduleLoad'
-- goes though the index looking for modules -- goes though the index looking for modules
for module_name,location in pairs (moduleIndex) do for module_name,path in pairs(moduleIndex) do
Manager.verbose('Loading module: "'..module_name..'"; Location: '..location) Manager.verbose('Loading module: "'..module_name..'"; path: '..path)
-- runs the module in a sandbox env -- runs the module in a sandbox env
local sandbox, success, module = Manager.sandbox(require,{module_name=setupModuleName(module_name),module_location=location},location) local sandbox, success, module = Manager.sandbox(require,{module_name=setupModuleName(module_name),module_path=path},path..'/control')
-- extracts the module into a global index table for later use -- extracts the module into a global index table for later use
if success then if success then
-- verbose to notifie of any globals that were attempted to be created -- verbose to notifie of any globals that were attempted to be created
local globals = '' local globals = ''
for key,value in pairs(sandbox) do globals = globals..key..', ' end 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 if globals ~= '' then Manager.verbose('Globals caught in "'..module_name..'": '..globals:sub(1,-3),'errorCaught') end
Manager.verbose('Successfully loaded: "'..module_name..'"; Location: '..location) Manager.verbose('Successfully loaded: "'..module_name..'"; path: '..path)
-- sets that it has been loaded and adds to the loaded index -- 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 you prefere module_exports can be used rather than returning the module
if type(tbl[module_name]) == 'nil' then if type(tbl[module_name]) == 'nil' then
@@ -229,7 +231,7 @@ Manager.loadModules = setmetatable({},
-- if there is a module by this name in _G ex table then it will be indexed to the new module -- 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 rawget(_G,module_name) and type(tbl[module_name]) == 'table' then setmetatable(rawget(_G,module_name),{__index=tbl[module_name]}) end
else else
Manager.verbose('Failed load: "'..module_name..'"; Location: '..location..' ('..module..')','errorCaught') Manager.verbose('Failed load: "'..module_name..'"; path: '..path..' ('..module..')','errorCaught')
end end
end end
-- new state for the manager to allow control of verbose -- new state for the manager to allow control of verbose
@@ -239,8 +241,8 @@ Manager.loadModules = setmetatable({},
-- looks for init so that init or on_init can be used -- 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.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 if type(data) == 'table' and data.on_init and type(data.on_init) == 'function' then
Manager.verbose('Initiating module: "'..module_name) Manager.verbose('Initiating module: "'..module_name..'"')
local sandbox, success, err = Manager.sandbox(data.on_init,{module_name=setupModuleName(module_name)},data) local sandbox, success, err = Manager.sandbox(data.on_init,{module_name=setupModuleName(module_name),module_path=moduleIndex[module_name]},data)
if success then if success then
Manager.verbose('Successfully Initiated: "'..module_name..'"') Manager.verbose('Successfully Initiated: "'..module_name..'"')
else else
@@ -397,7 +399,7 @@ Manager.event = setmetatable({
for module_name,callback in pairs(tbl[event_name]) do for module_name,callback in pairs(tbl[event_name]) do
-- loops over the call backs and which module it is from -- 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 if type(callback) ~= 'function' then error('Invalid Event Callback: "'..event_name..'/'..module_name..'"') end
local sandbox, success, err = Manager.sandbox(callback,{module_name=setupModuleName(module_name)},new_callback,...) local sandbox, success, err = Manager.sandbox(callback,{module_name=setupModuleName(module_name),module_path=moduleIndex[module_name]},new_callback,...)
if not success then Manager.verbose('Event Failed: "'..tbl.names[event_name]..'/'..module_name..'" ('..err..')','errorCaught') error('Event Failed: "'..event_name..'/'..module_name..'" ('..err..')') end if not success then Manager.verbose('Event Failed: "'..tbl.names[event_name]..'/'..module_name..'" ('..err..')','errorCaught') error('Event Failed: "'..event_name..'/'..module_name..'" ('..err..')') end
-- if stop constant is returned then stop further processing -- 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: "'..module_name..'"','errorCaught') break end
@@ -410,14 +412,19 @@ Manager.event = setmetatable({
-- checks for a global module name that is present -- checks for a global module name that is present
local module_name = module_name or 'FSM' local module_name = module_name or 'FSM'
-- converts the key to a number index for the event -- converts the key to a number index for the event
key = tonumber(key) or tbl.names[key] Manager.verbose('Added Handler: "'..tbl.names[key]..'"','eventRegistered')
Manager.verbose('Added Handler: "'..tbl.names[key]..'"','errorCaught')
-- 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 -- 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
if not rawget(rawget(tbl,'__events'),key) then rawget(tbl,'__event')(key,function(...) tbl(...) end) rawset(rawget(tbl,'__events'),key,{}) end if not rawget(rawget(tbl,'__events'),key) then
if 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] -- adds callback to Manager.event.__events[event_id][module_name]
rawset(rawget(rawget(tbl,'__events'),key),module_name,value) rawset(rawget(rawget(tbl,'__events'),key),module_name,value)
end, end,
__index=function(tbl,key) __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 -- proforms different look ups depentding weather the current module has an event handler registered
if module_name then if module_name 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 -- 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
@@ -458,12 +465,9 @@ rawset(Manager.event,'names',setmetatable({},{
-- 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 chache
if rawget(tbl,key) then return rawget(tbl,key) end if rawget(tbl,key) then return rawget(tbl,key) end
-- if it is a core event then it will simply return -- if it is a core event then it will simply return
if key == 'on_init' or key == 'init' then if key == -1 then rawset(tbl,key,'__init')
rawset(tbl,key,-1) elseif key == -2 then rawset(tbl,key,'__load')
elseif key == 'on_load' or key == 'load' then elseif key == -3 then rawset(tbl,key,'__config')
rawset(tbl,key,-2)
elseif key == 'on_configuration_changed' or key == 'configuration_changed' then
rawset(tbl,key,-3)
else else
-- if it is not a core event then it does a value look up on Manager.events aka defines.events -- if it is not a core event then it does a value look up on Manager.events aka defines.events
for event,id in pairs(rawget(Manager.event,'events')) do for event,id in pairs(rawget(Manager.event,'events')) do
@@ -473,19 +477,18 @@ rawset(Manager.event,'names',setmetatable({},{
-- returns the value from the chache after being loaded in -- returns the value from the chache after being loaded in
return rawget(tbl,key) return rawget(tbl,key)
-- if it is a string then no reverse look up is required -- if it is a string then no reverse look up is required
else return rawget(rawget(Manager.event,'events'),key) end else
if key == 'on_init' or key == 'init' or key == '__init' then return -1
elseif key == 'on_load' or key == 'load' or key == '__load' then return -2
elseif key == 'on_configuration_changed' or key == 'configuration_changed' or key == '__config' then return -3
else return rawget(rawget(Manager.event,'events'),key) end
end
end end
})) }))
--over rides for the base values; can be called though Event --over rides for the base values; can be called though Event
Event=setmetatable({},{__index=function(tbl,key) return Manager.event[key] or script[key] or error('Invalid Index To Table Event') end}) Event=setmetatable({},{__index=function(tbl,key) return Manager.event[key] or script[key] or error('Invalid Index To Table Event') end})
script.mod_name = setmetatable({},{ script.mod_name = setmetatable({},{__index=_G.module_name})
__index=function(tbl,key) return _G.module_name end,
__newindex=function(tbl,key,value) error('Module Name Is Read Only') end,
__tostring=function(tbl) return _G.module_name end,
__concat=function(tbl,val) return _G.module_name..val end,
__metatable=false,
})
script.on_event=Manager.event script.on_event=Manager.event
script.raise_event=Manager.event script.raise_event=Manager.event
script.on_init=function(callback) Manager.event(-1,callback) end script.on_init=function(callback) Manager.event(-1,callback) end

View File

@@ -16,7 +16,7 @@ Manager.setVerbose{
moduleLoad=true, -- when a module is required by the manager moduleLoad=true, -- when a module is required by the manager
moduleInit=true, -- when and within the initation of a module moduleInit=true, -- when and within the initation of a module
moduleEnv=true, -- during module runtime, this is a global option set within each module for fine control moduleEnv=true, -- during module runtime, this is a global option set within each module for fine control
eventRegistered=true, -- when a module registers its event handlers eventRegistered=false, -- when a module registers its event handlers
errorCaught=true, -- when an error is caught during runtime errorCaught=true, -- when an error is caught during runtime
output=Manager._verbose -- can be: can be: print || log || other function output=Manager._verbose -- can be: can be: print || log || other function
} }

View File

@@ -173,7 +173,7 @@
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#json">json (lua_table)</a></td> <td class="name" nowrap><a href="#json">json (lua_table)</a></td>
<td class="summary">Simmilar to table.to_string but converts a lua table to a json one</td> <td class="summary">Simmilar to table.tostring but converts a lua table to a json one</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#autokey">autokey (tbl, str)</a></td> <td class="name" nowrap><a href="#autokey">autokey (tbl, str)</a></td>
@@ -1004,7 +1004,7 @@ some_func(<span class="number">1</span>,<span class="number">2</span>) <span cla
<strong>json (lua_table)</strong> <strong>json (lua_table)</strong>
</dt> </dt>
<dd> <dd>
Simmilar to table.to_string but converts a lua table to a json one Simmilar to table.tostring but converts a lua table to a json one
<h3>Parameters:</h3> <h3>Parameters:</h3>

View File

@@ -0,0 +1,9 @@
[commands]
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
invalid-inputs=Invalid Input, /__1__ __2__
invalid-range=Invalid Range, Min: __1__, Max: __2__
invalid-length=Invalid Length, Max: __1__
invalid-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
offline-player=Player is offline: Command failed to run
dead-player=Player is dead: Command failed to run
command-ran=Command Complete

View File

@@ -0,0 +1,4 @@
[gui]
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
cant-open=You can't open this panel right now, reason: __1__
cant-open-no-reason=You can't open this panel right now

View File

@@ -0,0 +1,7 @@
[ranking]
all-rank-print=[Everyone]: __1__
rank-print=[__1__]: __2__
rank-up=__1__ was promoted to __2__ by __3__
rank-down=__1__ was demoted to __2__ by __3__
rank-given=You have been given the __1__ Rank!
tag-reset=Your Tag was reset due to a Rank change

View File

@@ -1,22 +0,0 @@
[commands]
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
invalid-inputs=Invalid Input, /__1__ __2__
invalid-range=Invalid Range, Min: __1__, Max: __2__
invalid-length=Invalid Length, Max: __1__
invalid-player=Invaild Player Name, __1__ ,try using tab key to auto-complete the name
offline-player=Player is offline: Command failed to run
dead-player=Player is dead: Command failed to run
command-ran=Command Complete
[ranking]
all-rank-print=[Everyone]: __1__
rank-print=[__1__]: __2__
rank-up=__1__ was promoted to __2__ by __3__
rank-down=__1__ was demoted to __2__ by __3__
rank-given=You have been given the __1__ Rank!
tag-reset=Your Tag was reset due to a Rank change
[gui]
unauthorized=401 - Unauthorized: Access is denied due to invalid credentials
cant-open=You can't open this panel right now, reason: __1__
cant-open-no-reason=You can't open this panel right now

View File

@@ -88,7 +88,7 @@ local function run_custom_command(command)
game.tick game.tick
..' Player: "'..player_name..'"' ..' Player: "'..player_name..'"'
..' Failed to use command (Unauthorized): "'..command.name..'"' ..' Failed to use command (Unauthorized): "'..command.name..'"'
..' With args of: '..table.to_string(command_args(command,command_data)) ..' With args of: '..table.tostring(command_args(command,command_data))
..'\n' ..'\n'
, true, 0) , true, 0)
return return
@@ -102,7 +102,7 @@ local function run_custom_command(command)
game.tick game.tick
..' Player: "'..player_name..'"' ..' Player: "'..player_name..'"'
..' Failed to use command (Invalid Args): "'..command.name..'"' ..' Failed to use command (Invalid Args): "'..command.name..'"'
..' With args of: '..table.to_string(args) ..' With args of: '..table.tostring(args)
..'\n' ..'\n'
, true, 0) , true, 0)
return return
@@ -115,15 +115,15 @@ local function run_custom_command(command)
game.tick game.tick
..' Player: "'..player_name..'"' ..' Player: "'..player_name..'"'
..' Used command: "'..command.name..'"' ..' Used command: "'..command.name..'"'
..' With args of: '..table.to_string(args) ..' With args of: '..table.tostring(args)
..'\n' ..'\n'
, true, 0) , true, 0)
end end
-- this is a set of constants you can use -- this is a set of constants you can use
commands._add_command = commands.add_command --if you dont want to use the custom commands interface commands._add_command = commands.add_command --if you dont want to use the custom commands interface
commands._expgaming = true --if you want to test if the custom commands are present commands.expgaming = true --if you want to test if the custom commands are present
commands.error = 'COMMAND_ERROR' --if returned during a custom command, Command Complete message not printed commands.error = {} --if returned during a custom command, Command Complete message not printed
--- Used to define commands --- Used to define commands
-- @usage inputs = {'player','reason',true} -- @usage inputs = {'player','reason',true}
-- commands.add_command('ban','bans a player',inputs,function() return end) -- commands.add_command('ban','bans a player',inputs,function() return end)

View File

@@ -26,12 +26,11 @@ end
function Gui._get_data(key) return Gui_data[key] end function Gui._get_data(key) return Gui_data[key] end
function Gui:_load_parts(parts) Gui.center = require(module_path..'/GuiParts/center')
for _,part in pairs(parts) do Gui.inputs = require(module_path..'/GuiParts/inputs')
verbose('Gui Extraction: '..part) Gui.left = require(module_path..'/GuiParts/left')
self[part] = require('GuiParts/'..part) Gui.popup = require(module_path..'/GuiParts/popup')
end Gui.toolbar = require(module_path..'/GuiParts/toolbar')
end
--- Add a white bar to any gui frame --- Add a white bar to any gui frame
-- @usage Gui.bar(frame,100) -- @usage Gui.bar(frame,100)
@@ -65,34 +64,38 @@ function Gui.set_dropdown_index(dropdown,_item)
return dropdown return dropdown
end end
Event.register(-1,function(event) Gui.on_init=function(self)
Server.new_thread{ Gui.test = require(module_path..'/GuiParts/test')
name='camera-follow', if not Server then return end
data={cams={},cam_index=1,players={}} Event.register(-1,function(event)
}:on_event('tick',function(self) Server.new_thread{
local _cam = self.data.cams[self.data.cam_index] name='camera-follow',
if not _cam then self.data.cam_index = 1 _cam = self.data.cams[self.data.cam_index] end data={cams={},cam_index=1,players={}}
if not _cam then return end }:on_event('tick',function(self)
if not _cam.cam.valid then table.remove(self.data.cams,self.data.cam_index) local _cam = self.data.cams[self.data.cam_index]
elseif not _cam.entity.valid then table.remove(self.data.cams,self.data.cam_index) if not _cam then self.data.cam_index = 1 _cam = self.data.cams[self.data.cam_index] end
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end self.data.cam_index = self.data.cam_index+1 if not _cam then return end
end if not _cam.cam.valid then table.remove(self.data.cams,self.data.cam_index)
end):on_event('error',function(self,err) elseif not _cam.entity.valid then table.remove(self.data.cams,self.data.cam_index)
-- posible error handling if needed else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end self.data.cam_index = self.data.cam_index+1
error(err)
end):on_event(defines.events.on_player_respawned,function(self,event)
if self.data.players[event.player_index] then
local remove = {}
for index,cam in pairs(self.data.players[event.player_index]) do
Gui.cam_link{cam=cam,entity=Game.get_player(event).character}
if not cam.valid then table.insert(remove,index) end
end end
for _,index in pairs(remove) do end):on_event('error',function(self,err)
table.remove(self.data.players[event.player_index],index) -- posible error handling if needed
error(err)
end):on_event(defines.events.on_player_respawned,function(self,event)
if self.data.players[event.player_index] then
local remove = {}
for index,cam in pairs(self.data.players[event.player_index]) do
Gui.cam_link{cam=cam,entity=Game.get_player(event).character}
if not cam.valid then table.insert(remove,index) end
end
for _,index in pairs(remove) do
table.remove(self.data.players[event.player_index],index)
end
end end
end end):open()
end):open() end)
end) end
--- 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 depeading 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,frame=frame,width=50,hight=50,zoom=1}

View File

@@ -384,4 +384,9 @@ Event.register(defines.events.on_tick,function(event)
end end
end) end)
Ranking.on_init=function(self)
require(module_path.."/base_ranks")
require(module_path.."/config_ranks")
end
return Ranking return Ranking

View File

@@ -139,8 +139,6 @@ function Server._thread_handler(event)
end) end)
end end
for _,event in pairs(defines.events) do Event.register(event,Server._thread_handler) end
--[[ cant be used V --[[ cant be used V
--- Adds a event handler to tell threads about events --- Adds a event handler to tell threads about events
-- @usage Server.add_thread_handler(defines.event) -- @usage Server.add_thread_handler(defines.event)
@@ -193,18 +191,6 @@ function Server.interface(callback,use_thread,...)
end end
end end
if commands._expgaming then
commands.add_command('interface', 'Runs the given input from the script', {'code',true}, function(event,args)
local callback = args.code
if not string.find(callback,'%s') and not string.find(callback,'return') then callback = 'return '..callback end
if game.player then callback = 'local player, surface, force, position, entity, tile = game.player, game.player.surface, game.player.force, game.player.position, game.player.selected, game.player.surface.get_tile(game.player.position);'..callback end
if Ranking and Ranking.get_rank and game.player then callback = 'local rank = Ranking.get_rank(game.player);'..callback end
local success, err = Server.interface(callback)
if not success and is_type(err,'string') then local _end = string.find(err,'stack traceback') if _end then err = string.sub(err,0,_end-2) end end
if err or err == false then player_return(err) end
end)
end
-- thread allows you to run fuinction async to the main game -- thread allows you to run fuinction async to the main game
--- Returns a new thread object --- Returns a new thread object
-- @usage new_thread = thread:create() -- @usage new_thread = thread:create()
@@ -393,6 +379,21 @@ Event.register(-2,function(event)
end end
end) end)
Server.on_init=function(self)
Event.register(defines.event,Server._thread_handler)
if pcall(function() return commands._expgaming end) then
commands.add_command('interface', 'Runs the given input from the script', {'code',true}, function(event,args)
local callback = args.code
if not string.find(callback,'%s') and not string.find(callback,'return') then callback = 'return '..callback end
if game.player then callback = 'local player, surface, force, position, entity, tile = game.player, game.player.surface, game.player.force, game.player.position, game.player.selected, game.player.surface.get_tile(game.player.position);'..callback end
if Ranking and Ranking.get_rank and game.player then callback = 'local rank = Ranking.get_rank(game.player);'..callback end
local success, err = Server.interface(callback)
if not success and is_type(err,'string') then local _end = string.find(err,'stack traceback') if _end then err = string.sub(err,0,_end-2) end end
if err or err == false then player_return(err) end
end)
end
end
return Server return Server
--[[ --[[
Thread Example: Thread Example:

View File

@@ -15,7 +15,7 @@ local Sync_updates = {}
--- Used as a faster way to get to the ranking function, overrides previous --- Used as a faster way to get to the ranking function, overrides previous
-- @usage Sync.set_ranks{name=rank_name} -- @usage Sync.set_ranks{name=rank_name}
function Sync.set_ranks(...) function Sync.set_ranks(...)
Ranking._base_preset(...) if Ranking then Ranking._base_preset(...) else error('Ranking module not installed') end
end end
--- Used to standidise the tick format for any sync info --- Used to standidise the tick format for any sync info
@@ -91,11 +91,10 @@ function Sync.emit_embeded(args)
end end
-- set up error handle -- set up error handle
verbose('Set New Error Handle') error.addHandler('Discord Emit',function(err)
_G.error_handle = function(err)
local color = _G.Color and Color.to_hex(defines.textcolor.bg) or '0x0' local color = _G.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_embeded{title='SCRIPT ERROR',color=color,description='There was an error in the script @Developers ',Error=err}
end end)
--- used to get the number of admins currently online --- used to get the number of admins currently online
-- @usage Sync.count_admins() -- @usage Sync.count_admins()
@@ -128,6 +127,7 @@ end
-- @treturn table contains the ranks and the players in that rank -- @treturn table contains the ranks and the players in that rank
function Sync.count_ranks() function Sync.count_ranks()
if not game then return {'Offline'} end if not game then return {'Offline'} end
if not Ranking then return {'Ranking module not installed'} end
local _ranks = {} local _ranks = {}
for power,rank in pairs(Ranking._ranks()) do for power,rank in pairs(Ranking._ranks()) do
local players = rank:get_players() local players = rank:get_players()
@@ -278,16 +278,21 @@ function Sync.add_to_gui(element,...)
return true return true
end end
-- Examples for Sync.add_to_gui
-- adds a basic string to the table Sync.on_init=function(self)
Sync.add_to_gui('Welcome to the Explosive Gaming comunity! This is one of many servers which we host.') -- Examples for Sync.add_to_gui
-- adds a string that can have depentant values -- adds a basic string to the table
Sync.add_to_gui(function(player,frame) Sync.add_to_gui('Welcome to the Explosive Gaming comunity! This is one of many servers which we host.')
return 'You have been assigned the rank \''..Ranking.get_rank(player).name..'\'' if Ranking then
end) -- adds a string that can have depentant values
Sync.add_to_gui(function(player,frame) Sync.add_to_gui(function(player,frame)
return 'This server will reset at: '..Sync.info().reset_time return 'You have been assigned the rank \''..Ranking.get_rank(player).name..'\''
end) end)
end
Sync.add_to_gui(function(player,frame)
return 'This server will reset at: '..Sync.info().reset_time
end)
end
-- if readme is included then see addons/guis/readme.lua for more examples -- if readme is included then see addons/guis/readme.lua for more examples
-- used to load the gui infomation when _G.Gui is not yet loaded -- used to load the gui infomation when _G.Gui is not yet loaded

View File

@@ -0,0 +1,75 @@
{
"name": "ExpGamingCore",
"module": "Collection",
"description": "Explosive Gaming Core Files",
"keywords": ["Library","Lib","ExpGaming","Core"],
"version": "3.4.0",
"location": "url",
"submodules": {
"Commands": {
"name": "Commands",
"module": "commands",
"description": "A better command handler than the base game.",
"keywords": ["Library","Lib","ExpGaming","Core","Commands"],
"version": "3.4.0",
"location": "url",
"dependencies": {
"ExpGamingLib": ">=3.0.0",
"ExpGamingCore/Ranking": ">=3.0.0"
}
},
"Gui": {
"name": "Gui",
"module": "Gui",
"description": "Adds a objective version to custom guis.",
"keywords": ["Library","Lib","ExpGaming","Core","Gui","ExpGui"],
"version": "3.4.0",
"location": "url",
"dependencies": {
"FactorioModGui": ">=1.0.0",
"ExpGamingLib": ">=3.0.0",
"ExpGamingCore/Ranking": ">=3.0.0",
"ExpGamingCore/Server": "?>=3.0.0"
}
},
"Ranking": {
"name": "Ranking",
"module": "Ranking",
"description": "A full ranking system for factorio.",
"keywords": ["Library","Lib","ExpGaming","Core","Ranking","Ranks","Permissions","Roles"],
"version": "3.4.0",
"location": "url",
"dependencies": {
"ExpGamingLib": ">=3.0.0"
}
},
"Server": {
"name": "Server",
"module": "Server",
"description": "Adds a thread system and event listening and a admin bypass (recommend to disable /c and use optional /interface)",
"keywords": ["Library","Lib","ExpGaming","Core","Server","Thread","Interface","Events"],
"version": "3.4.0",
"location": "url",
"dependencies": {
"ExpGamingLib": ">=3.0.0",
"ExpGamingCore/Ranking": "?>=3.0.0",
"ExpGamingCore/Commands": "?>=3.0.0"
}
},
"Sync": {
"name": "Sync",
"module": "Sync",
"description": "Allows syncing with an outside server and info panle.",
"keywords": ["Library","Lib","ExpGaming","Core","Info","Sync","External","Discord"],
"version": "3.4.0",
"location": "url",
"dependencies": {
"ExpGamingLib": ">=3.0.0",
"Ranking": "?>=3.0.0"
}
}
},
"author": "Cooldude2606",
"contact": "Discord: Cooldude2606#5241",
"license": "https://github.com/badgamernl/explosivegaming-main/blob/master/LICENSE"
}

View File

@@ -3,12 +3,12 @@
"module": "ExpLib", "module": "ExpLib",
"description": "Adds some common functions used though out all ExpGaming modules", "description": "Adds some common functions used though out all ExpGaming modules",
"keywords": ["ExpGaming","Lib"], "keywords": ["ExpGaming","Lib"],
"version": "1.0.0", "version": "3.4.0",
"location": "nil", "location": "url",
"main": "control",
"dependencies": { "dependencies": {
"StdLib/Game": ">=1.0.0", "StdLib.Game": ">=0.8.0",
"StdLib/Color": ">=1.0.0" "StdLib.Color": ">=0.8.0",
"StdLib.Table": ">=0.8.0"
}, },
"author": "Cooldude2606", "author": "Cooldude2606",
"contact": "Discord: Cooldude2606#5241", "contact": "Discord: Cooldude2606#5241",

View File

@@ -0,0 +1,6 @@
--- Redirect to factorio mod-gui
-- @module Factorio Mod Gui
-- @alias mod-gui
-- @author Factorio Dev Team
return require("mod-gui")

View File

@@ -0,0 +1,12 @@
{
"name": "FactorioModGui",
"module": "mod_gui",
"description": "A way to standadise the way mods hanndle their guis.",
"keywords": ["Factorio","Gui","Non-Download","Included"],
"version": "1.0.0",
"location": "url",
"dependencies": {},
"author": "Factorio Dev Team",
"contact": "Any other questions please feel free to ask on the modding help forum.",
"license": "C:/Program Files (x86)/Steam/steamapps/common/Factorio/data/licenses.txt"
}

View File

@@ -410,7 +410,7 @@ function table.val_to_str(v)
end end
return '"'..string.gsub(v,'"', '\\"' )..'"' return '"'..string.gsub(v,'"', '\\"' )..'"'
else else
return "table" == type( v) and table.to_string(v) or return "table" == type( v) and table.tostring(v) or
"function" == type(v) and '"cant-display-function"' or "function" == type(v) and '"cant-display-function"' or
"userdata" == type(v) and '"cant-display-userdata"' or "userdata" == type(v) and '"cant-display-userdata"' or
tostring(v) tostring(v)
@@ -450,7 +450,7 @@ function table.tostring(tbl)
return "{"..table.concat(result,",") .."}" return "{"..table.concat(result,",") .."}"
end end
--- Simmilar to table.to_string but converts a lua table to a json one --- Simmilar to table.tostring but converts a lua table to a json one
-- @usage local a = {k1='foo',k2='bar'} -- @usage local a = {k1='foo',k2='bar'}
-- talbe.json(a) -- return '{"k1":"foo","k2":"bar"}' -- talbe.json(a) -- return '{"k1":"foo","k2":"bar"}'
-- @tparam table lua_table the table to convert -- @tparam table lua_table the table to convert

View File

@@ -1,10 +1,10 @@
{ {
"name": "FactorioStdLib", "name": "FactorioStdLib",
"module": "StdLib", "module": "Collection",
"description": "Factorio Standard Library Projects", "description": "Factorio Standard Library Projects",
"keywords": ["Standard Library","Lib","StdLib"], "keywords": ["Standard Library","Lib","StdLib"],
"version": "0.8.0", "version": "0.8.0",
"location": "nil", "location": "url",
"submodules": { "submodules": {
"Color": { "Color": {
"name": "Color", "name": "Color",
@@ -12,7 +12,7 @@
"description": "A defines module for retrieving colors by name.", "description": "A defines module for retrieving colors by name.",
"keywords": ["Standard Library","Lib","StdLib","Color","Extends"], "keywords": ["Standard Library","Lib","StdLib","Color","Extends"],
"version": "0.8.0", "version": "0.8.0",
"location": "color", "location": "url",
"dependencies": {} "dependencies": {}
}, },
"Game": { "Game": {
@@ -21,7 +21,7 @@
"description": "The game module.", "description": "The game module.",
"keywords": ["Standard Library","Lib","StdLib","Game","Extends"], "keywords": ["Standard Library","Lib","StdLib","Game","Extends"],
"version": "0.8.0", "version": "0.8.0",
"location": "game", "location": "url",
"dependencies": {} "dependencies": {}
}, },
"String": { "String": {
@@ -30,7 +30,7 @@
"description": "Extends Lua 5.2 string.", "description": "Extends Lua 5.2 string.",
"keywords": ["Standard Library","Lib","StdLib","String","Extends"], "keywords": ["Standard Library","Lib","StdLib","String","Extends"],
"version": "0.8.0", "version": "0.8.0",
"location": "string", "location": "url",
"dependencies": {} "dependencies": {}
}, },
"Table": { "Table": {
@@ -39,7 +39,7 @@
"description": "Extends Lua 5.2 table.", "description": "Extends Lua 5.2 table.",
"keywords": ["Standard Library","Lib","StdLib","Table","Extends"], "keywords": ["Standard Library","Lib","StdLib","Table","Extends"],
"version": "0.8.0", "version": "0.8.0",
"location": "table", "location": "url",
"dependencies": {} "dependencies": {}
}, },
"Time": { "Time": {
@@ -48,7 +48,7 @@
"description": "A defines module for retrieving the number of ticks in 1 unit of time.", "description": "A defines module for retrieving the number of ticks in 1 unit of time.",
"keywords": ["Standard Library","Lib","StdLib","Time","Extends"], "keywords": ["Standard Library","Lib","StdLib","Time","Extends"],
"version": "0.8.0", "version": "0.8.0",
"location": "time", "location": "url",
"dependencies": {} "dependencies": {}
} }
}, },

View File

@@ -1,10 +1,16 @@
--- Used to index the files to be loaded --- Used to index the files to be loaded
-- @script index.lua -- @script index.lua
return { return {
['ExpLib']='/modules/ExpGamingLib/control', ['mod_gui']='/modules/FactorioModGui',
['Game']='/modules/FactorioStdLib/game', ['ExpLib']='/modules/ExpGamingLib',
['Time']='/modules/FactorioStdLib/time', ['Game']='/modules/FactorioStdLib/Game',
['Color']='/modules/FactorioStdLib/color', ['Time']='/modules/FactorioStdLib/Time',
['table']='/modules/FactorioStdLib/table', ['Color']='/modules/FactorioStdLib/Color',
['string']='/modules/FactorioStdLib/string', ['table']='/modules/FactorioStdLib/Table',
['string']='/modules/FactorioStdLib/String',
['Ranking']='/modules/ExpGamingCore/Ranking',
['commands']='/modules/ExpGamingCore/Commands',
['Gui']='/modules/ExpGamingCore/Gui',
['Server']='/modules/ExpGamingCore/Server',
['Sync']='/modules/ExpGamingCore/Sync',
} }