From 35f93e5bebca1e8fccb65242c1a542360e3581ed Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Mon, 9 Oct 2023 17:11:27 -0500 Subject: [PATCH 1/4] Doc(animHelper): Emmylua annotations --- scripts/animHelper.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/animHelper.lua b/scripts/animHelper.lua index 5f02b982..a687850b 100644 --- a/scripts/animHelper.lua +++ b/scripts/animHelper.lua @@ -11,6 +11,10 @@ local generalAnimAliases = { act_impatient = "idle6", check_missing_item = "idle local femaleAnimAliases = { adjust_hair = "idle4", touch_hip = "idle5" } local beastAnimAliases = { act_confused = "idle9", look_around = "idle2", touch_hands = "idle6" } +--- Get player's current animation +--- @param pid integer +--- @param animAlias string +--- @return string animation function animHelper.GetAnimation(pid, animAlias) -- Is this animation included in the default animation names? @@ -49,6 +53,9 @@ function animHelper.GetAnimation(pid, animAlias) return "invalid" end +--- Get all animations a particular player could play +--- @param pid integer +--- @return string[] function animHelper.GetValidList(pid) local validList = {} @@ -89,6 +96,10 @@ function animHelper.GetValidList(pid) return tableHelper.concatenateFromIndex(validList, 1, ", ") end +--- Play a specific animation on a specific pid +--- @param pid integer +--- @param animAlias string +--- @return bool success function animHelper.PlayAnimation(pid, animAlias) local defaultAnim = animHelper.GetAnimation(pid, animAlias) From a17b2f8f96c8e4a5d6e8eb980922339493a3309e Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Mon, 9 Oct 2023 19:52:15 -0500 Subject: [PATCH 2/4] Doc(animHelper): Better annotations for animHelper --- scripts/animHelper.lua | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/scripts/animHelper.lua b/scripts/animHelper.lua index a687850b..cb9140e0 100644 --- a/scripts/animHelper.lua +++ b/scripts/animHelper.lua @@ -1,20 +1,38 @@ tableHelper = require("tableHelper") +--- Unsigned int representing player id +--- @class PlayerID + +--- Master table for all animHelper functions +--- @class AnimHelper +--- @field GetAnimation fun(pid: PlayerID, animAlias: string): string +--- @field GetValidList fun(pid: PlayerID): string[] local animHelper = {} +--- Literal animation names common to all races and genders +--- @class AnimTable +--- @field animNames string[] local defaultAnimNames = { "hit1", "hit2", "hit3", "hit4", "hit5", "idle2", "idle3", "idle4", "idle5", "idle6", "idle7", "idle8", "idle9", "pickprobe" } +--- Animation names common to all races and genders +--- @class AnimAliases local generalAnimAliases = { act_impatient = "idle6", check_missing_item = "idle9", examine_hand = "idle7", look_behind = "idle3", shift_feet = "idle2", scratch_neck = "idle4", touch_chin = "idle8", touch_shoulder = "idle5" } + +--- Dictionary of female animation aliases mapped to their literal names +--- @class FemaleAnimAliases local femaleAnimAliases = { adjust_hair = "idle4", touch_hip = "idle5" } + +--- Dictionary of beast animation aliases mapped to their literal names +--- @class BeastAnimAliases local beastAnimAliases = { act_confused = "idle9", look_around = "idle2", touch_hands = "idle6" } ---- Get player's current animation ---- @param pid integer ---- @param animAlias string ---- @return string animation +--- Retrieve a real animation name using its alias relative to player race/gender +--- @param pid integer The playerID +--- @param animAlias string Practical name for the animation, used as a table key in the animAlias tables +--- @return string animation Literal animation name or invalid if the anim does not exist for this race/gender function animHelper.GetAnimation(pid, animAlias) -- Is this animation included in the default animation names? @@ -54,8 +72,8 @@ function animHelper.GetAnimation(pid, animAlias) end --- Get all animations a particular player could play ---- @param pid integer ---- @return string[] +--- @param pid PlayerID Player whose animation list is requested +--- @return string[] animList All literal animation names valid for this PlayerID function animHelper.GetValidList(pid) local validList = {} @@ -82,13 +100,13 @@ function animHelper.GetValidList(pid) end if isBeast then - for beastAlias, defaultAnim in pairs(beastAnimAliases) do + for beastAlias, _ in pairs(beastAnimAliases) do table.insert(validList, beastAlias) end end if isFemale then - for femaleAlias, defaultAnim in pairs(femaleAnimAliases) do + for femaleAlias, _ in pairs(femaleAnimAliases) do table.insert(validList, femaleAlias) end end @@ -96,10 +114,10 @@ function animHelper.GetValidList(pid) return tableHelper.concatenateFromIndex(validList, 1, ", ") end ---- Play a specific animation on a specific pid ---- @param pid integer ---- @param animAlias string ---- @return bool success +--- Given a specific animation alias, play it on the target PlayerID +--- @param pid PlayerID Player to animate +--- @param animAlias string Animation to run, see AnimAliases, FemaleAnimAliases, and BeastAnimAliases classes for aliases +--- @return boolean success Whether the animation played function animHelper.PlayAnimation(pid, animAlias) local defaultAnim = animHelper.GetAnimation(pid, animAlias) From 8f8eb688dbf81d0d751136524f5f5584a1adda9c Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Mon, 9 Oct 2023 19:59:54 -0500 Subject: [PATCH 3/4] Doc(Core): Add file for common class/type definitions --- scripts/animHelper.lua | 3 --- scripts/serverCore.lua | 1 + 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/animHelper.lua b/scripts/animHelper.lua index cb9140e0..c660ac80 100644 --- a/scripts/animHelper.lua +++ b/scripts/animHelper.lua @@ -1,8 +1,5 @@ tableHelper = require("tableHelper") ---- Unsigned int representing player id ---- @class PlayerID - --- Master table for all animHelper functions --- @class AnimHelper --- @field GetAnimation fun(pid: PlayerID, animAlias: string): string diff --git a/scripts/serverCore.lua b/scripts/serverCore.lua index 8d3cea33..02ef15f3 100644 --- a/scripts/serverCore.lua +++ b/scripts/serverCore.lua @@ -1,4 +1,5 @@ require("wrapper") +require("types") require("utils") require("enumerations") tableHelper = require("tableHelper") From 8fe69a416040d69130944e4b72da7005fab4b0cf Mon Sep 17 00:00:00 2001 From: Dave Corley Date: Mon, 9 Oct 2023 20:34:09 -0500 Subject: [PATCH 4/4] Fix(doc): Actually include types.lua --- scripts/types.lua | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 scripts/types.lua diff --git a/scripts/types.lua b/scripts/types.lua new file mode 100644 index 00000000..3bace592 --- /dev/null +++ b/scripts/types.lua @@ -0,0 +1,2 @@ +--- Unsigned int representing player id +--- @class PlayerID