-- AltSystem Data Definitions -- Contains skill data (fetched from TRP3 profile), item options, defense options, and modifier constants. AltSystem = AltSystem or {} AltSystem.Data = {} -- Skill levels and their modifiers AltSystem.Data.SkillLevels = { ["Novice"] = -2, ["Adept"] = 0, ["Expert"] = 2, ["Master"] = 4, } -- The "Inept" entry is always the first (default) skill local UNSKILLED_ENTRY = { name = "Inept", level = "Inept", modifier = -4 } -- Default/fallback skill list used when no TRP3 profile skills are found local DEFAULT_SKILLS = { { name = "Inept", level = "Inept", modifier = -4 }, { name = "Novice Skill", level = "Novice", modifier = -2 }, { name = "Adept Skill", level = "Adept", modifier = 0 }, { name = "Expert Skill", level = "Expert", modifier = 2 }, { name = "Master Skill", level = "Master", modifier = 4 }, } -- Valid skill level keywords that must appear in the trait's right field (RT) local VALID_SKILL_KEYWORDS = { "Novice", "Adept", "Expert", "Master" } -- Check if the trait's right text field contains a valid skill keyword. -- Returns true if any keyword is found, false otherwise. local function HasSkillKeyword(rightText) if not rightText or rightText == "" then return false end for _, keyword in ipairs(VALID_SKILL_KEYWORDS) do if rightText:find(keyword) then return true end end return false end -- Determine the skill level from the trait's numeric value (V2 field, 0-20 range). -- Returns the level string and modifier, or nil if the value is 0 or absent. local function ParseSkillLevel(numericValue) if not numericValue or numericValue <= 0 then return nil, nil end if numericValue >= 20 then return "Master", AltSystem.Data.SkillLevels["Master"] elseif numericValue >= 11 then return "Expert", AltSystem.Data.SkillLevels["Expert"] elseif numericValue >= 6 then return "Adept", AltSystem.Data.SkillLevels["Adept"] else return "Novice", AltSystem.Data.SkillLevels["Novice"] end end -- Fetch skills from the current TRP3 profile's personality traits. -- Returns an array of skill entries, always starting with "Inept". -- Falls back to the default list if no profile or no valid skills are found. function AltSystem.Data:RefreshSkills() local skills = {} -- Always add Inept as the first entry table.insert(skills, { name = UNSKILLED_ENTRY.name, level = UNSKILLED_ENTRY.level, modifier = UNSKILLED_ENTRY.modifier }) local foundAny = false -- Try to read personality traits from the active TRP3 profile if TRP3_API and TRP3_API.profile and TRP3_API.profile.getData then local ok, characteristics = pcall(TRP3_API.profile.getData, "player/characteristics") if ok and characteristics and characteristics.PS then for _, trait in ipairs(characteristics.PS) do local skillName = trait.LT local numericValue = trait.V2 if skillName and skillName ~= "" and HasSkillKeyword(trait.RT) then local level, modifier = ParseSkillLevel(numericValue) if level and modifier then foundAny = true table.insert(skills, { name = skillName, level = level, modifier = modifier, }) end end end end end -- If no valid skills were found, use the default fallback list (skip first "Inept" since we already added it) if not foundAny then skills = {} for _, skill in ipairs(DEFAULT_SKILLS) do table.insert(skills, { name = skill.name, level = skill.level, modifier = skill.modifier }) end end AltSystem.Data.Skills = skills return skills end -- Initialize with the default skill list AltSystem.Data.Skills = {} for _, skill in ipairs(DEFAULT_SKILLS) do table.insert(AltSystem.Data.Skills, { name = skill.name, level = skill.level, modifier = skill.modifier }) end -- Item options: name and modifier (first entry = no item) AltSystem.Data.Items = { { name = "No item", modifier = 0 }, { name = "Rare item", modifier = 3 }, { name = "Epic item", modifier = 5 }, } -- Defense options: name and modifier AltSystem.Data.Defenses = { { name = "Base armor", modifier = 0 }, { name = "Extra small armor", modifier = 1 }, { name = "Extra large armor", modifier = 2 }, } -- Shield modifier AltSystem.Data.ShieldModifier = 1