mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-27 03:25:23 +09:00
No more warnings
This commit is contained in:
@@ -398,26 +398,26 @@ function Common.player_return(value, colour, player)
|
||||
colour = Common.type_check(colour, "table") and colour or Colours[colour] ~= Colours.white and Colours[colour] or Colours.white
|
||||
player = player or game.player
|
||||
-- converts the value to a string
|
||||
local returnAsString
|
||||
local string_return
|
||||
if Common.type_check(value, "table") or type(value) == "userdata" then
|
||||
if Common.type_check(value.__self, "userdata") or type(value) == "userdata" then
|
||||
-- value is userdata
|
||||
returnAsString = "Cant Display Userdata"
|
||||
string_return = "Cant Display Userdata"
|
||||
elseif Common.type_check(value[1], "string") and string.find(value[1], ".+[.].+") and not string.find(value[1], "%s") then
|
||||
-- value is a locale string
|
||||
returnAsString = value
|
||||
string_return = value
|
||||
elseif getmetatable(value) ~= nil and not tostring(value):find("table: 0x") then
|
||||
-- value has a tostring meta method
|
||||
returnAsString = tostring(value)
|
||||
string_return = tostring(value)
|
||||
else
|
||||
-- value is a table
|
||||
returnAsString = table.inspect(value, { depth = 5, indent = " ", newline = "\n" })
|
||||
string_return = table.inspect(value, { depth = 5, indent = " ", newline = "\n" })
|
||||
end
|
||||
elseif Common.type_check(value, "function") then
|
||||
-- value is a function
|
||||
returnAsString = "Cant Display Functions"
|
||||
string_return = "Cant Display Functions"
|
||||
else
|
||||
returnAsString = tostring(value)
|
||||
string_return = tostring(value)
|
||||
end
|
||||
-- returns to the player or the server
|
||||
if player then
|
||||
@@ -426,9 +426,9 @@ function Common.player_return(value, colour, 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" }
|
||||
player.print(returnAsString, colour)
|
||||
player.print(string_return, colour)
|
||||
else
|
||||
rcon.print(returnAsString)
|
||||
rcon.print(string_return)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -469,7 +469,11 @@ function Common.format_time(ticks, options)
|
||||
local days, hours = max_days, max_hours - math.floor(max_days) * 24
|
||||
local minutes, seconds = max_minutes - math.floor(max_hours) * 60, max_seconds - math.floor(max_minutes) * 60
|
||||
-- Handles overflow of disabled denominations
|
||||
local rtn_days, rtn_hours, rtn_minutes, rtn_seconds = math.floor(days), math.floor(hours), math.floor(minutes), math.floor(seconds)
|
||||
local rtn_days, rtn_hours, rtn_minutes, rtn_seconds =
|
||||
math.floor(days) --[[@as string | number | table]],
|
||||
math.floor(hours) --[[@as string | number | table]],
|
||||
math.floor(minutes) --[[@as string | number | table]],
|
||||
math.floor(seconds) --[[@as string | number | table]]
|
||||
if not options.days then
|
||||
rtn_hours = rtn_hours + rtn_days * 24
|
||||
end
|
||||
@@ -496,10 +500,10 @@ function Common.format_time(ticks, options)
|
||||
local div = options.string and " " or "time-format.simple-format-tagged"
|
||||
if options.time then
|
||||
div = options.string and ":" or "time-format.simple-format-div"
|
||||
suffix = false
|
||||
-- suffix = false -- Can't get the types to work
|
||||
end
|
||||
-- Adds formatting
|
||||
if suffix ~= false then
|
||||
if not options.time then -- Can't get the types to work
|
||||
if options.string then
|
||||
-- format it as a string
|
||||
local long = suffix == ""
|
||||
|
||||
@@ -158,8 +158,8 @@ local trace = debug.traceback
|
||||
--- Save datastores in the global table
|
||||
Storage.register(Data, function(tbl)
|
||||
Data = tbl
|
||||
for datastoreName, datastore in pairs(Datastores) do
|
||||
datastore.data = Data[datastoreName]
|
||||
for name, datastore in pairs(Datastores) do
|
||||
datastore.data = Data[name]
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -174,7 +174,7 @@ DatastoreManager.metatable = {
|
||||
}
|
||||
|
||||
--[[-- Make a new datastore connection, if a connection already exists then it is returned
|
||||
@tparam string datastoreName The name that you want the new datastore to have, this can not have any whitespace
|
||||
@tparam string datastore_name The name that you want the new datastore to have, this can not have any whitespace
|
||||
@tparam[opt=false] boolean saveToDisk When set to true, using the save method with write the data to datastore.pipe
|
||||
@tparam[opt=false] boolean autoSave When set to true, using any method which modifies data will cause the data to be saved
|
||||
@tparam[opt=false] boolean propagateChanges When set to true, using the save method will send the data to all other connected servers
|
||||
@@ -184,19 +184,19 @@ DatastoreManager.metatable = {
|
||||
local ExampleData = Datastore.connect('ExampleData', true) -- saveToDisk
|
||||
|
||||
]]
|
||||
function DatastoreManager.connect(datastoreName, saveToDisk, autoSave, propagateChanges)
|
||||
if Datastores[datastoreName] then return Datastores[datastoreName] end
|
||||
function DatastoreManager.connect(datastore_name, save_to_disk, autosave, propagate_changes)
|
||||
if Datastores[datastore_name] then return Datastores[datastore_name] end
|
||||
if package.lifecycle ~= package.lifecycle_stage.control then
|
||||
-- Only allow this function to be called during the control stage
|
||||
error("New datastore connection can not be created during runtime", 2)
|
||||
end
|
||||
|
||||
local new_datastore = {
|
||||
name = datastoreName,
|
||||
value_name = datastoreName,
|
||||
auto_save = autoSave or false,
|
||||
save_to_disk = saveToDisk or false,
|
||||
propagate_changes = propagateChanges or false,
|
||||
name = datastore_name,
|
||||
value_name = datastore_name,
|
||||
auto_save = autosave or false,
|
||||
save_to_disk = save_to_disk or false,
|
||||
propagate_changes = propagate_changes or false,
|
||||
serializer = false,
|
||||
parent = false,
|
||||
children = {},
|
||||
@@ -205,28 +205,28 @@ function DatastoreManager.connect(datastoreName, saveToDisk, autoSave, propagate
|
||||
data = {},
|
||||
}
|
||||
|
||||
Data[datastoreName] = new_datastore.data
|
||||
Datastores[datastoreName] = new_datastore
|
||||
Data[datastore_name] = new_datastore.data
|
||||
Datastores[datastore_name] = new_datastore
|
||||
return setmetatable(new_datastore, DatastoreManager.metatable)
|
||||
end
|
||||
|
||||
--[[-- Make a new datastore that stores its data inside of another one
|
||||
@tparam string datastoreName The name of the datastore that will contain the data for the new datastore
|
||||
@tparam string subDatastoreName The name of the new datastore, this name will also be used as the key inside the parent datastore
|
||||
@tparam string datastore_name The name of the datastore that will contain the data for the new datastore
|
||||
@tparam string subdatastore_name The name of the new datastore, this name will also be used as the key inside the parent datastore
|
||||
@treturn table The new datastore connection that can be used to access and modify data in the datastore
|
||||
|
||||
@usage-- Setting up a datastore which stores its data inside of another datastore
|
||||
local BarData = Datastore.combine('ExampleData', 'Bar')
|
||||
|
||||
]]
|
||||
function DatastoreManager.combine(datastoreName, subDatastoreName)
|
||||
local datastore = assert(Datastores[datastoreName], "Datastore not found " .. tostring(datastoreName))
|
||||
return datastore:combine(subDatastoreName)
|
||||
function DatastoreManager.combine(datastore_name, subdatastore_name)
|
||||
local datastore = assert(Datastores[datastore_name], "Datastore not found " .. tostring(datastore_name))
|
||||
return datastore:combine(subdatastore_name)
|
||||
end
|
||||
|
||||
--[[-- Ingest the result from a request, this is used through a rcon interface to sync data
|
||||
@tparam string action The action that should be done, can be: remove, message, propagate, or request
|
||||
@tparam string datastoreName The name of the datastore that should have the action done to it
|
||||
@tparam string datastore_name The name of the datastore that should have the action done to it
|
||||
@tparam string key The key of that datastore that is having the action done to it
|
||||
@tparam string valueJson The json string for the value being ingested, remove does not require a value
|
||||
|
||||
@@ -234,20 +234,20 @@ end
|
||||
Datastore.ingest('request', 'ExampleData', 'TestKey', 'Foo')
|
||||
|
||||
]]
|
||||
function DatastoreManager.ingest(action, datastoreName, key, valueJson)
|
||||
local datastore = assert(Datastores[datastoreName], "Datastore ingest error, Datastore not found " .. tostring(datastoreName))
|
||||
function DatastoreManager.ingest(action, datastore_name, key, value_json)
|
||||
local datastore = assert(Datastores[datastore_name], "Datastore ingest error, Datastore not found " .. tostring(datastore_name))
|
||||
assert(type(action) == "string", "Datastore ingest error, Action is not a string got: " .. type(action))
|
||||
assert(type(key) == "string", "Datastore ingest error, Key is not a string got: " .. type(key))
|
||||
|
||||
if action == "remove" then
|
||||
datastore:raw_set(key)
|
||||
elseif action == "message" then
|
||||
local success, value = pcall(game.json_to_table, valueJson)
|
||||
if not success or value == nil then value = tonumber(valueJson) or valueJson end
|
||||
local success, value = pcall(game.json_to_table, value_json)
|
||||
if not success or value == nil then value = tonumber(value_json) or value_json end
|
||||
datastore:raise_event("on_message", key, value)
|
||||
elseif action == "propagate" or action == "request" then
|
||||
local success, value = pcall(game.json_to_table, valueJson)
|
||||
if not success or value == nil then value = tonumber(valueJson) or valueJson end
|
||||
local success, value = pcall(game.json_to_table, value_json)
|
||||
if not success or value == nil then value = tonumber(value_json) or value_json end
|
||||
local old_value = datastore:raw_get(key)
|
||||
value = datastore:raise_event("on_load", key, value, old_value)
|
||||
datastore:set(key, value)
|
||||
@@ -255,7 +255,7 @@ function DatastoreManager.ingest(action, datastoreName, key, valueJson)
|
||||
end
|
||||
|
||||
--[[-- Debug, Use to get all datastores, or return debug info on a datastore
|
||||
@tparam[opt] string datastoreName The name of the datastore to get the debug info of
|
||||
@tparam[opt] string datastore_name The name of the datastore to get the debug info of
|
||||
|
||||
@usage-- Get all the datastores
|
||||
local datastores = Datastore.debug()
|
||||
@@ -264,9 +264,9 @@ local datastores = Datastore.debug()
|
||||
local debug_info = Datastore.debug('ExampleData')
|
||||
|
||||
]]
|
||||
function DatastoreManager.debug(datastoreName)
|
||||
if not datastoreName then return Datastores end
|
||||
local datastore = assert(Datastores[datastoreName], "Datastore not found " .. tostring(datastoreName))
|
||||
function DatastoreManager.debug(datastore_name)
|
||||
if not datastore_name then return Datastores end
|
||||
local datastore = assert(Datastores[datastore_name], "Datastore not found " .. tostring(datastore_name))
|
||||
return datastore:debug()
|
||||
end
|
||||
|
||||
@@ -279,8 +279,8 @@ local ExampleData = Datastore.connect('ExampleData')
|
||||
ExampleData:set_serializer(Datastore.name_serializer)
|
||||
|
||||
]]
|
||||
function DatastoreManager.name_serializer(rawKey)
|
||||
return rawKey.name
|
||||
function DatastoreManager.name_serializer(raw_key)
|
||||
return raw_key.name
|
||||
end
|
||||
|
||||
----- Datastore Internal
|
||||
@@ -328,7 +328,7 @@ end
|
||||
local value = self:raw_get('TestKey')
|
||||
|
||||
]]
|
||||
function Datastore:raw_get(key, fromChild)
|
||||
function Datastore:raw_get(key, from_child)
|
||||
local data = self.data
|
||||
if self.parent then
|
||||
data = self.parent:raw_get(key, true)
|
||||
@@ -336,7 +336,7 @@ function Datastore:raw_get(key, fromChild)
|
||||
end
|
||||
local value = data[key]
|
||||
if value ~= nil then return value end
|
||||
if fromChild then value = {} end
|
||||
if from_child then value = {} end
|
||||
data[key] = value
|
||||
return value
|
||||
end
|
||||
@@ -367,10 +367,10 @@ local function serialize_error(err) error("An error ocurred in a datastore seria
|
||||
key = self:serialize(key)
|
||||
|
||||
]]
|
||||
function Datastore:serialize(rawKey)
|
||||
if type(rawKey) == "string" then return rawKey end
|
||||
function Datastore:serialize(raw_key)
|
||||
if type(raw_key) == "string" then return raw_key end
|
||||
assert(self.serializer, "Datastore does not have a serializer and received non string key")
|
||||
local success, key = xpcall(self.serializer, serialize_error, rawKey)
|
||||
local success, key = xpcall(self.serializer, serialize_error, raw_key)
|
||||
return success and key or nil
|
||||
end
|
||||
|
||||
@@ -398,7 +398,7 @@ end
|
||||
-- @section datastore-local
|
||||
|
||||
--[[-- Create a new datastore which is stores its data inside of this datastore
|
||||
@tparam string subDatastoreName The name of the datastore that will have its data stored in this datastore
|
||||
@tparam string subdatastore_name The name of the datastore that will have its data stored in this datastore
|
||||
@treturn table The new datastore that was created inside of this datastore
|
||||
|
||||
@usage-- Add a new sub datastore
|
||||
@@ -406,10 +406,10 @@ local ExampleData = Datastore.connect('ExampleData')
|
||||
local BarData = ExampleData:combine('Bar')
|
||||
|
||||
]]
|
||||
function Datastore:combine(subDatastoreName)
|
||||
local new_datastore = DatastoreManager.connect(self.name .. "." .. subDatastoreName)
|
||||
self.children[subDatastoreName] = new_datastore
|
||||
new_datastore.value_name = subDatastoreName
|
||||
function Datastore:combine(subdatastore_name)
|
||||
local new_datastore = DatastoreManager.connect(self.name .. "." .. subdatastore_name)
|
||||
self.children[subdatastore_name] = new_datastore
|
||||
new_datastore.value_name = subdatastore_name
|
||||
new_datastore.serializer = self.serializer
|
||||
new_datastore.auto_save = self.auto_save
|
||||
new_datastore.parent = self
|
||||
@@ -442,9 +442,9 @@ local ExampleData = Datastore.connect('ExampleData')
|
||||
ExampleData:set_default('Foo')
|
||||
|
||||
]]
|
||||
function Datastore:set_default(value, allowSet)
|
||||
function Datastore:set_default(value, allow_set)
|
||||
self.default = value
|
||||
self.allow_set_to_default = allowSet
|
||||
self.allow_set_to_default = allow_set
|
||||
end
|
||||
|
||||
--[[-- Set metadata tags on this datastore which can be accessed by other scripts
|
||||
|
||||
@@ -133,10 +133,10 @@ local Event = _C.opt_require("modules/exp_legacy/utils/event")
|
||||
|
||||
if Roles and Event then
|
||||
Event.add(Roles.events.on_role_assigned, function(e)
|
||||
Gui.update_top_flow(game.get_player(e.player_index))
|
||||
Gui.update_top_flow(game.players[e.player_index])
|
||||
end)
|
||||
Event.add(Roles.events.on_role_unassigned, function(e)
|
||||
Gui.update_top_flow(game.get_player(e.player_index))
|
||||
Gui.update_top_flow(game.players[e.player_index])
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
@@ -226,6 +226,7 @@ function Gui._prototype_element:triggers_events(element)
|
||||
element.tags = { ExpGui_event_triggers = { self.uid } }
|
||||
return element
|
||||
elseif not tags.ExpGui_event_triggers then
|
||||
--- @diagnostic disable-next-line: name-style-check
|
||||
tags.ExpGui_event_triggers = { self.uid }
|
||||
elseif table.array_contains(tags.ExpGui_event_triggers, self.uid) then
|
||||
error("Element::triggers_events called multiple times on the same element with the same definition")
|
||||
|
||||
@@ -27,7 +27,7 @@ local Game = require("modules.exp_legacy.utils.game") --- @dep utils.game
|
||||
local Event = require("modules/exp_legacy/utils/event") --- @dep utils.event
|
||||
local Async = require("modules/exp_util/async")
|
||||
|
||||
local Permissions_Groups = {
|
||||
local PermissionsGroups = {
|
||||
groups = {}, -- store for the different groups that are created
|
||||
_prototype = {}, -- stores functions that are used on group instances
|
||||
}
|
||||
@@ -37,14 +37,14 @@ local add_to_permission_group_async =
|
||||
Async.register(function(permission_group, player)
|
||||
permission_group.add_player(player)
|
||||
end)
|
||||
Permissions_Groups.add_to_permission_group_async = add_to_permission_group_async
|
||||
PermissionsGroups.add_to_permission_group_async = add_to_permission_group_async
|
||||
|
||||
-- Async function to remove players from permission groups
|
||||
local remove_from_permission_group_async =
|
||||
Async.register(function(permission_group, player)
|
||||
permission_group.remove_player(player)
|
||||
end)
|
||||
Permissions_Groups.remove_from_permission_group_async = remove_from_permission_group_async
|
||||
PermissionsGroups.remove_from_permission_group_async = remove_from_permission_group_async
|
||||
|
||||
--- Getters.
|
||||
-- Functions that get permission groups
|
||||
@@ -58,15 +58,15 @@ Permissions_Groups.remove_from_permission_group_async = remove_from_permission_g
|
||||
Groups.new_group('Admin')
|
||||
|
||||
]]
|
||||
function Permissions_Groups.new_group(name)
|
||||
function PermissionsGroups.new_group(name)
|
||||
local group = setmetatable({
|
||||
name = name,
|
||||
actions = {},
|
||||
allow_all_actions = true,
|
||||
}, {
|
||||
__index = Permissions_Groups._prototype,
|
||||
__index = PermissionsGroups._prototype,
|
||||
})
|
||||
Permissions_Groups.groups[name] = group
|
||||
PermissionsGroups.groups[name] = group
|
||||
return group
|
||||
end
|
||||
|
||||
@@ -78,8 +78,8 @@ end
|
||||
local admin_group = Groups.get_group_by_name('Admin')
|
||||
|
||||
]]
|
||||
function Permissions_Groups.get_group_by_name(name)
|
||||
return Permissions_Groups.groups[name]
|
||||
function PermissionsGroups.get_group_by_name(name)
|
||||
return PermissionsGroups.groups[name]
|
||||
end
|
||||
|
||||
--[[-- Returns the group that a player is in
|
||||
@@ -90,12 +90,12 @@ end
|
||||
local group = Groups.get_group_from_player(game.player)
|
||||
|
||||
]]
|
||||
function Permissions_Groups.get_group_from_player(player)
|
||||
function PermissionsGroups.get_group_from_player(player)
|
||||
player = Game.get_player_from_any(player)
|
||||
if not player then return end
|
||||
local group = player.permission_group
|
||||
if group then
|
||||
return Permissions_Groups.groups[group.name]
|
||||
return PermissionsGroups.groups[group.name]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -109,8 +109,8 @@ end
|
||||
Groups.reload_permissions()
|
||||
|
||||
]]
|
||||
function Permissions_Groups.reload_permissions()
|
||||
for _, group in pairs(Permissions_Groups.groups) do
|
||||
function PermissionsGroups.reload_permissions()
|
||||
for _, group in pairs(PermissionsGroups.groups) do
|
||||
group:create()
|
||||
end
|
||||
end
|
||||
@@ -124,9 +124,9 @@ end
|
||||
Groups.set_player_group(game.player, 'Admin')
|
||||
|
||||
]]
|
||||
function Permissions_Groups.set_player_group(player, group)
|
||||
function PermissionsGroups.set_player_group(player, group)
|
||||
player = Game.get_player_from_any(player)
|
||||
group = Permissions_Groups.get_group_by_name(group)
|
||||
group = PermissionsGroups.get_group_by_name(group)
|
||||
if not group or not player then return false end
|
||||
group:add_player(player)
|
||||
return true
|
||||
@@ -145,7 +145,7 @@ end
|
||||
group:set_action('toggle_map_editor', false)
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:set_action(action, state)
|
||||
function PermissionsGroups._prototype:set_action(action, state)
|
||||
local input_action = defines.input_action[action]
|
||||
if input_action == nil then input_action = action end
|
||||
assert(type(input_action) == "number", tostring(action) .. " is not a valid input action")
|
||||
@@ -163,7 +163,7 @@ group:allow{
|
||||
}
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:allow(actions)
|
||||
function PermissionsGroups._prototype:allow(actions)
|
||||
if type(actions) ~= "table" then
|
||||
actions = { actions }
|
||||
end
|
||||
@@ -188,7 +188,7 @@ group:disallow{
|
||||
}
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:disallow(actions)
|
||||
function PermissionsGroups._prototype:disallow(actions)
|
||||
if type(actions) ~= "table" then
|
||||
actions = { actions }
|
||||
end
|
||||
@@ -206,7 +206,7 @@ end
|
||||
group:allow_all()
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:allow_all()
|
||||
function PermissionsGroups._prototype:allow_all()
|
||||
self.allow_all_actions = true
|
||||
return self
|
||||
end
|
||||
@@ -218,7 +218,7 @@ end
|
||||
group:disallow_all()
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:disallow_all()
|
||||
function PermissionsGroups._prototype:disallow_all()
|
||||
self.allow_all_actions = false
|
||||
return self
|
||||
end
|
||||
@@ -231,7 +231,7 @@ end
|
||||
local allowed = group:is_allowed('write_to_console')
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:is_allowed(action)
|
||||
function PermissionsGroups._prototype:is_allowed(action)
|
||||
if type(action) == "string" then
|
||||
action = defines.input_action[action]
|
||||
end
|
||||
@@ -253,10 +253,10 @@ end
|
||||
group:create()
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:create()
|
||||
function PermissionsGroups._prototype:create()
|
||||
local group = self:get_raw()
|
||||
if not group then
|
||||
group = game.permissions.create_group(self.name)
|
||||
group = game.permissions.create_group(self.name) --[[@as LuaPermissionGroup]]
|
||||
end
|
||||
for _, action in pairs(defines.input_action) do
|
||||
group.set_allows_action(action, self:is_allowed(action))
|
||||
@@ -272,7 +272,7 @@ end
|
||||
local permission_group = group:get_raw()
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:get_raw()
|
||||
function PermissionsGroups._prototype:get_raw()
|
||||
return game.permissions.get_group(self.name)
|
||||
end
|
||||
|
||||
@@ -284,7 +284,7 @@ end
|
||||
group:add_player(game.player)
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:add_player(player)
|
||||
function PermissionsGroups._prototype:add_player(player)
|
||||
player = Game.get_player_from_any(player)
|
||||
local group = self:get_raw()
|
||||
if not group or not player then return false end
|
||||
@@ -300,7 +300,7 @@ end
|
||||
group:remove_player(game.player)
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:remove_player(player)
|
||||
function PermissionsGroups._prototype:remove_player(player)
|
||||
player = Game.get_player_from_any(player)
|
||||
local group = self:get_raw()
|
||||
if not group or not player then return false end
|
||||
@@ -319,7 +319,7 @@ local online_players = group:get_players()
|
||||
local online_players = group:get_players(true)
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:get_players(online)
|
||||
function PermissionsGroups._prototype:get_players(online)
|
||||
local players = {}
|
||||
local group = self:get_raw()
|
||||
if group then
|
||||
@@ -344,7 +344,7 @@ end
|
||||
group:print('Hello, World!')
|
||||
|
||||
]]
|
||||
function Permissions_Groups._prototype:print(message)
|
||||
function PermissionsGroups._prototype:print(message)
|
||||
local players = self:get_players(true)
|
||||
for _, player in pairs(players) do
|
||||
player.print(message)
|
||||
@@ -355,7 +355,7 @@ end
|
||||
|
||||
-- when the game starts it will make the permission groups
|
||||
Event.on_init(function()
|
||||
Permissions_Groups.reload_permissions()
|
||||
PermissionsGroups.reload_permissions()
|
||||
end)
|
||||
|
||||
return Permissions_Groups
|
||||
return PermissionsGroups
|
||||
|
||||
@@ -107,23 +107,23 @@ end)
|
||||
|
||||
--- Remove data that the player doesnt want to have stored
|
||||
PlayerData:on_save(function(player_name, player_data)
|
||||
local dataPreference = DataSavingPreference:get(player_name)
|
||||
dataPreference = PreferenceEnum[dataPreference]
|
||||
if dataPreference == PreferenceEnum.All then
|
||||
local data_preference = DataSavingPreference:get(player_name)
|
||||
data_preference = PreferenceEnum[data_preference]
|
||||
if data_preference == PreferenceEnum.All then
|
||||
player_data.valid = nil
|
||||
return player_data
|
||||
end
|
||||
|
||||
local saved_player_data = { PlayerRequired = player_data.PlayerRequired, DataSavingPreference = PreferenceEnum[dataPreference] }
|
||||
if dataPreference <= PreferenceEnum.Settings then saved_player_data.PlayerSettings = player_data.PlayerSettings end
|
||||
if dataPreference <= PreferenceEnum.Statistics then saved_player_data.PlayerStatistics = player_data.PlayerStatistics end
|
||||
local saved_player_data = { PlayerRequired = player_data.PlayerRequired, DataSavingPreference = PreferenceEnum[data_preference] }
|
||||
if data_preference <= PreferenceEnum.Settings then saved_player_data["PlayerSettings"] = player_data.PlayerSettings end
|
||||
if data_preference <= PreferenceEnum.Statistics then saved_player_data["PlayerStatistics"] = player_data.PlayerStatistics end
|
||||
|
||||
return saved_player_data
|
||||
end)
|
||||
|
||||
--- Display your data preference when your data loads
|
||||
DataSavingPreference:on_load(function(player_name, dataPreference)
|
||||
game.players[player_name].print{ "expcore-data.get-preference", dataPreference or DataSavingPreference.default }
|
||||
DataSavingPreference:on_load(function(player_name, data_preference)
|
||||
game.players[player_name].print{ "expcore-data.get-preference", data_preference or DataSavingPreference.default }
|
||||
end)
|
||||
|
||||
--- Load player data when they join
|
||||
|
||||
@@ -200,8 +200,8 @@ function Roles.debug()
|
||||
for index, role_name in ipairs(Roles.config.order) do
|
||||
local role = Roles.config.roles[role_name]
|
||||
local color = role.custom_color or Colours.white
|
||||
color = string.format("[color=%d, %d, %d]", color.r, color.g, color.b)
|
||||
output = output .. string.format("\n%s %s) %s[/color]", color, index, serpent.line(role))
|
||||
local color_str = string.format("[color=%d, %d, %d]", color.r, color.g, color.b)
|
||||
output = output .. string.format("\n%s %s) %s[/color]", color_str, index, serpent.line(role))
|
||||
end
|
||||
|
||||
return output
|
||||
@@ -341,7 +341,6 @@ local role = Roles.get_player_highest_role(game.player)
|
||||
]]
|
||||
function Roles.get_player_highest_role(player)
|
||||
local roles = Roles.get_player_roles(player)
|
||||
if not roles then return end
|
||||
local highest
|
||||
for _, role in ipairs(roles) do
|
||||
if not highest or role.index < highest.index then
|
||||
|
||||
Reference in New Issue
Block a user