mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 04:21:41 +09:00
Few minor bug fixes
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user