Describe the legacy role type

get_player_roles always returns at least the default or root role, so
get_player_highest_role never returns nil, and callers were right to
treat it that way.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
bbassie
2026-08-07 15:31:43 +00:00
co-authored by Claude Opus 5
parent ce3b490554
commit 7bb874f73f
+17 -1
View File
@@ -117,6 +117,21 @@ local Groups = require("modules.exp_legacy.expcore.permission_groups")
local Colours = ExpUtil.color local Colours = ExpUtil.color
local write_json = ExpUtil.write_json local write_json = ExpUtil.write_json
--- @class Roles.Role
--- @field name string
--- @field short_hand string
--- @field index number Position within the role order
--- @field allowed_actions table<string, boolean>
--- @field allow_all_actions boolean
--- @field flags table<string, boolean>
--- @field disallowed_actions table<string, boolean>?
--- @field permission_group ([boolean, string] | string)?
--- @field custom_tag string?
--- @field custom_color Color?
--- @field parent string?
--- @field block_auto_assign boolean?
--- @field auto_assign_condition function?
local Roles = { local Roles = {
_prototype = {}, _prototype = {},
config = { config = {
@@ -348,6 +363,7 @@ end
local role = Roles.get_player_highest_role(game.player) local role = Roles.get_player_highest_role(game.player)
]] ]]
--- @return Roles.Role
function Roles.get_player_highest_role(player) function Roles.get_player_highest_role(player)
local roles = Roles.get_player_roles(player) local roles = Roles.get_player_roles(player)
local highest local highest
@@ -357,7 +373,7 @@ function Roles.get_player_highest_role(player)
end end
end end
return highest return assert(highest, "Player has no roles")
end end
--- Assignment. --- Assignment.