mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-28 20:05:22 +09:00
Few minor bug fixes
This commit is contained in:
@@ -257,8 +257,8 @@ Manager.require = setmetatable({
|
||||
__require=require
|
||||
},{
|
||||
__metatable=false,
|
||||
__index=function(tbl,key) return tbl(key) end,
|
||||
__call=function(tbl,path,env)
|
||||
__index=function(tbl,key) return tbl(key,nil,true) end,
|
||||
__call=function(tbl,path,env,mute)
|
||||
local raw_require = rawget(tbl,'__require')
|
||||
local env = env or {}
|
||||
-- runs in a sand box becuase sandbox everything
|
||||
@@ -266,6 +266,7 @@ Manager.require = setmetatable({
|
||||
-- if there was no error then it assumed the path existed and returns the data
|
||||
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
|
||||
@@ -283,7 +284,7 @@ Manager.require = setmetatable({
|
||||
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
|
||||
error(data,2)
|
||||
if mute then return false else error(data,2) end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
-- @alais Admin
|
||||
|
||||
-- Module Require
|
||||
local Game = require('FactorioStdLib@^0.8.0')
|
||||
local Game = require('FactorioStdLib.Game@^0.8.0')
|
||||
local Ranking -- ExpGamingCore.Ranking@^4.0.0
|
||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||
|
||||
@@ -15,7 +15,7 @@ local Admin = {
|
||||
on_init=function()
|
||||
if loaded_modules['ExpGamingCore.Ranking@^4.0.0'] then Ranking = require('ExpGamingCore.Ranking@^4.0.0') end
|
||||
if loaded_modules['ExpGamingCore.Sync@^4.0.0'] then Sync = require('ExpGamingCore.Sync@^4.0.0') end
|
||||
if loaded_modules['ExoGamingCore.Server'] then Server.add_module_to_interface('Admin','ExpGamingAdmin') end
|
||||
if loaded_modules['ExpGamingCore.Server@^4.0.0'] then require('ExpGamingCore.Server@^4.0.0').add_module_to_interface('Admin','ExpGamingAdmin.AdminLib') end
|
||||
end,
|
||||
actions={},
|
||||
action_names={}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
-- this file should be replaced with a collection but idk if fsm can hanndle collections in a collection
|
||||
|
||||
local Admin = require('ExpGamingAdmin')
|
||||
local Admin = require('ExpGamingAdmin.AdminLib')
|
||||
|
||||
--- Used to clear all parts of a player, removing warnings, reports, jail and temp ban
|
||||
-- @command clear-all
|
||||
|
||||
@@ -151,7 +151,7 @@ local function run_custom_command(command)
|
||||
local player_name = Game.get_player(command) and Game.get_player(command).name or 'server'
|
||||
-- is the player allowed to use this command, if no ExpGamingCore.Ranking then this is ingroned
|
||||
if Ranking and Ranking.meta and Ranking.meta.rank_count > 0 and not Ranking.get_rank(player_name):allowed(command.name)
|
||||
or not Ranking and data.setAdminOnly == true and game.player and not game.player.admin then
|
||||
or not Ranking and data.admin_only == true and game.player and not game.player.admin then
|
||||
player_return({'commands.unauthorized'},defines.textcolor.crit)
|
||||
if game.player then game.player.play_sound{path='utility/cannot_build'} end
|
||||
game.write_file('commands.log',
|
||||
@@ -214,10 +214,7 @@ commands.add_command = function(name, description, inputs, callback)
|
||||
description=description,
|
||||
inputs=inputs,
|
||||
callback=callback,
|
||||
setAdminOnly=function(tbl,value)
|
||||
if is_type(tbl,'table') then if is_type(value,'boolean') then tbl.setAdminOnly = value else tbl.setAdminOnly = true end
|
||||
else if is_type(tbl,'boolean') then data[name].setAdminOnly = value else data[name].setAdminOnly = true end
|
||||
end
|
||||
admin_only=false
|
||||
}
|
||||
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)..'- '}
|
||||
|
||||
@@ -132,18 +132,25 @@ 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 _cam = global.cams[global.cam_index]
|
||||
if not _cam then global.cam_index = 1 _cam = global.cams[global.cam_index] end
|
||||
if not _cam then return 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)
|
||||
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end global.cam_index = global.cam_index+1
|
||||
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]
|
||||
if not _cam then return 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)
|
||||
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end global.cam_index = global.cam_index+1
|
||||
end
|
||||
end
|
||||
global.cam_index = global.cam_index+update
|
||||
end
|
||||
end)
|
||||
|
||||
script.on_event('on_player_respawned',function(event)
|
||||
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 = {}
|
||||
for index,cam in pairs(global.players[event.player_index]) do
|
||||
|
||||
@@ -17,29 +17,35 @@ script.on_event(-1,function(event)
|
||||
Server.new_thread{
|
||||
name='camera-follow',
|
||||
data={cams={},cam_index=1,players={}}
|
||||
}:on_event('tick',function(self)
|
||||
local _cam = 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
|
||||
if not _cam then return end
|
||||
if not _cam.cam.valid then table.remove(self.data.cams,self.data.cam_index)
|
||||
elseif not _cam.entity.valid then table.remove(self.data.cams,self.data.cam_index)
|
||||
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
|
||||
}:on_event('tick',function(self)
|
||||
local update = 4
|
||||
if self.data.cam_index >= #self.data.cams then self.data.cam_index = 1 end
|
||||
if update > #self.data.cams then update = #self.data.cams end
|
||||
for cam_offset = 0,update do
|
||||
local _cam = self.data.cams[self.data.cam_index+cam_offset]
|
||||
if not _cam then break end
|
||||
if not _cam.cam.valid then table.remove(self.data.cams,self.data.cam_index)
|
||||
elseif not _cam.entity.valid then table.remove(self.data.cams,self.data.cam_index)
|
||||
else _cam.cam.position = _cam.entity.position if not _cam.surface then _cam.cam.surface_index = _cam.entity.surface.index end
|
||||
end
|
||||
end
|
||||
self.data.cam_index = self.data.cam_index+update
|
||||
end):on_event('error',function(self,err)
|
||||
-- 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 = {}
|
||||
local player = Game.get_player(event)
|
||||
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
|
||||
if cam.valid then table.insert(self.data.cams,{cam=cam,entity=player.character,surface=player.surface})
|
||||
else table.insert(remove,index) end
|
||||
end
|
||||
for _,index in pairs(remove) do
|
||||
table.remove(self.data.players[event.player_index],index)
|
||||
for n,index in pairs(remove) do
|
||||
table.remove(self.data.players[event.player_index],index-n+1)
|
||||
end
|
||||
end
|
||||
end):open()
|
||||
end)
|
||||
|
||||
Server.add_module_to_interface('ExpGui')
|
||||
Server.add_module_to_interface('ExpGui','ExpGamingCore.Gui')
|
||||
@@ -48,4 +48,4 @@ script.on_event('on_tick',function(event)
|
||||
end)
|
||||
|
||||
Server.add_to_interface('rank',function() return Ranking.get_rank(game.player) end)
|
||||
Server.add_module_to_interface('Ranking')
|
||||
Server.add_module_to_interface('Ranking','ExpGamingCore.Ranking')
|
||||
@@ -14,9 +14,11 @@ 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 = module_name or version and moduleName..'@'..version or moduleName or error('No module name supplied')
|
||||
local moduleName = _G.moduleName or version and moduleName..'@'..version or 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
|
||||
Server.add_module_to_interface('Server','ExpGamingCore.Server')
|
||||
|
||||
--- Runs the given input from the script
|
||||
-- @command interface
|
||||
|
||||
@@ -311,7 +311,7 @@ script.on_event('on_rocket_launched',Sync.emit_update)
|
||||
function Sync:on_init()
|
||||
if loaded_modules['ExpGamingCore.Gui'] then verbose('ExpGamingCore.Gui is installed; Loading gui src') require(module_path..'/src/gui',{Sync=Sync}) end
|
||||
if loaded_modules['ExpGamingCore.Ranking'] then verbose('ExpGamingCore.Ranking is installed; Loading ranking src') require(module_path..'/src/ranking',{Sync=Sync}) end
|
||||
if loaded_modules['ExoGamingCore.Server'] then Server.add_module_to_interface('Sync') end
|
||||
if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server').add_module_to_interface('Sync','ExpGamingCore.Sync') end
|
||||
end
|
||||
|
||||
function Sync:on_post()
|
||||
|
||||
@@ -114,7 +114,7 @@ script.on_event(defines.events.on_gui_click,function(event)
|
||||
back_btn:draw(flow)
|
||||
playerInfo(event.element.name,flow,true)
|
||||
if Game.get_player(event.element.name) and event.player_index == Game.get_player(event.element.name).index then return end
|
||||
if Admin and Admin.allowed(event.player_index) then Admin.btn_flow(flow).caption = event.element.name end
|
||||
if Admin and Admin.allowed and Admin.allowed(event.player_index) then Admin.btn_flow(flow).caption = event.element.name end
|
||||
end)
|
||||
|
||||
script.on_event(defines.events.on_player_joined_game,queue_update)
|
||||
@@ -126,6 +126,6 @@ return {
|
||||
update=queue_update,
|
||||
on_init=function(self)
|
||||
if loaded_modules['ExpGamingPlayer.playerInfo'] then playerInfo = require('ExpGamingPlayer.playerInfo') end
|
||||
if loaded_modules['ExpGamingAdmin'] then Admin = require('ExpGamingAdmin') end
|
||||
if loaded_modules['ExpGamingAdmin.AdminLib'] then Admin = require('ExpGamingAdmin.AdminLib') end
|
||||
end
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
"FactorioStdLib.Game": "^0.8.0",
|
||||
"ExpGamingCore.Gui": "^4.0.0",
|
||||
"ExpGamingCore.Ranking": "?^4.0.0",
|
||||
"ExpGamingAdmin.AdminLib": "?^4.0.0",
|
||||
"ExpGamingAdmin.buttonFlow": "?^4.0.0",
|
||||
"ExpGamingAdmin.reports": "?^4.0.0",
|
||||
"ExpGamingPlayer.playerInfo": "?^4.0.0"
|
||||
|
||||
Reference in New Issue
Block a user