mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-30 20:41:41 +09:00
Fixed 4 bugs
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
local Admin = self
|
local Admin = self
|
||||||
local Role = require('ExpGamingCore.Role')
|
local Role = require('ExpGamingCore.Role')
|
||||||
|
local Server = require('ExpGamingCore.Server')
|
||||||
|
|
||||||
--- Used to jail a player which stops them from moving
|
--- Used to jail a player which stops them from moving
|
||||||
-- @command jail
|
-- @command jail
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ script.on_event(defines.events.on_tick,function(event)
|
|||||||
local time_to_remove = remove_warnings_time[role.index]
|
local time_to_remove = remove_warnings_time[role.index]
|
||||||
if (game.tick % time_to_remove) == 0 then
|
if (game.tick % time_to_remove) == 0 then
|
||||||
global[name]=warnings-1
|
global[name]=warnings-1
|
||||||
if global.warnings[name] > 5 then
|
if global[name] > 5 then
|
||||||
player_return({'ExpGamingAdmin-Warnings.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.textcolor.low,name)
|
player_return({'ExpGamingAdmin-Warnings.remove-warn',global[name],tick_to_display_format(time_to_remove)},defines.textcolor.low,name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
local Game = require('FactorioStdLib.Game')
|
local Game = require('FactorioStdLib.Game')
|
||||||
local Role -- ExpGamingCore.Role@^4.0.0
|
local Role -- ExpGamingCore.Role@^4.0.0
|
||||||
local Sync -- ExpGamingCore.Sync@^4.0.0
|
local Sync -- ExpGamingCore.Sync@^4.0.0
|
||||||
|
local Server -- ExpGamingCore.Server@^4.0.0
|
||||||
|
|
||||||
-- Module Define
|
-- Module Define
|
||||||
local module_verbose = false
|
local module_verbose = false
|
||||||
@@ -15,7 +16,10 @@ local Admin = {
|
|||||||
on_init=function()
|
on_init=function()
|
||||||
if loaded_modules['ExpGamingCore.Role'] then Role = require('ExpGamingCore.Role') 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.Sync'] then Sync = require('ExpGamingCore.Sync') end
|
||||||
if loaded_modules['ExpGamingCore.Server'] then require('ExpGamingCore.Server').add_module_to_interface('Admin','ExpGamingAdmin') end
|
if loaded_modules['ExpGamingCore.Server'] then
|
||||||
|
Server = require('ExpGamingCore.Server')
|
||||||
|
Server.add_module_to_interface('Admin','ExpGamingAdmin')
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
actions={},
|
actions={},
|
||||||
action_functions={},
|
action_functions={},
|
||||||
@@ -79,10 +83,10 @@ end
|
|||||||
function Admin.clear_player(player,by_player)
|
function Admin.clear_player(player,by_player)
|
||||||
local player, by_player = Admin.valid_players(player,by_player)
|
local player, by_player = Admin.valid_players(player,by_player)
|
||||||
if not player then return end
|
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 Server and 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 Admin.clear_warings then Admin.clear_warings(player,by_player,true) end
|
||||||
if Admin.clear_reports then Admin.clear_reports(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 Server and Role.has_flag(player,'is_jail') then Server.interface(Role.revert,true,player,by_player,2) end
|
||||||
if Sync then Sync.emit_embeded{
|
if Sync then Sync.emit_embeded{
|
||||||
title='Player Clear',
|
title='Player Clear',
|
||||||
color=Color.to_hex(defines.textcolor.low),
|
color=Color.to_hex(defines.textcolor.low),
|
||||||
|
|||||||
@@ -103,10 +103,10 @@ end
|
|||||||
-- @usage Role.get(player) -- returns group of player
|
-- @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 indenifier
|
||||||
-- @treturn table the group which was found or nil
|
-- @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)
|
local player = game and Game.get_player(mixed)
|
||||||
if player == SERVER then return {Role.meta.server} end
|
if player == SERVER then return {Role.meta.server} end
|
||||||
if player then
|
if not forceIsRole and player then
|
||||||
local rtn = {}
|
local rtn = {}
|
||||||
if not global.players[player.index] then return Role.meta.default and {Role.meta.default} or {} end
|
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
|
for _,role in pairs(global.players[player.index]) do table.insert(rtn,Role.get(role)) end
|
||||||
@@ -275,16 +275,19 @@ end
|
|||||||
-- @tparam[opt=false] boolean inv true to print to roles below, false to print to roles above
|
-- @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 recived the message
|
||||||
function Role.print(role,rtn,colour,inv)
|
function Role.print(role,rtn,colour,inv)
|
||||||
local role = Role.get(role)
|
local role = Role.get(role,true)
|
||||||
if not type_error(role,'table','Invalid argument #1 to Role.print, role is invalid.') then return end
|
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 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
|
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 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
|
local ctn = 0
|
||||||
for index,_role in pairs(Role.roles) do
|
local i = role.index
|
||||||
if print or _role == role then ctn=ctn+_role:print(message,colour) end
|
while true do
|
||||||
if _role == role then if print then break else print = true end end
|
local _role = Role.get(i,true)
|
||||||
|
if not role then break end
|
||||||
|
ctn=ctn+_role:print(message,colour)
|
||||||
|
i=i+change
|
||||||
end
|
end
|
||||||
return ctn
|
return ctn
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user