diff --git a/gamemode/core/libs/cl_menu.lua b/gamemode/core/libs/cl_menu.lua index 93374e24..bf891154 100644 --- a/gamemode/core/libs/cl_menu.lua +++ b/gamemode/core/libs/cl_menu.lua @@ -1,7 +1,20 @@ +-- @module nut.menu +-- @moduleCommentStart +-- Library functions for nut.menu +-- @moduleCommentEnd + nut.menu = nut.menu or {} nut.menu.list = nut.menu.list or {} +-- @type function nut.menu.add(options, positions, onRemove) +-- @typeCommentStart -- Adds a new menu to the list of drawn menus. +-- @typeCommentEnd +-- @realm client +-- @table options A table of button text as keys and their callbacks as values. +-- @vector position The position of the menu or an entity to follow. +-- @function onRemove A function to call after the menu has faded out. +-- @treturn number The index of the menu in the list. function nut.menu.add(options, position, onRemove) -- Set up the width of the menu. local width = 0 @@ -43,7 +56,11 @@ end -- Gradient for subtle effects. local gradient = Material("vgui/gradient-u") +-- @type function nut.menu.drawAll() +-- @typeCommentStart -- A function to draw all of the active menus or hide them when needed. +-- @typeCommentEnd +-- @realm client function nut.menu.drawAll() local frameTime = FrameTime() * 30 local mX, mY = ScrW() * 0.5, ScrH() * 0.5 @@ -151,7 +168,13 @@ function nut.menu.drawAll() end end --- Determines which menu is being looked at +-- @type function nut.menu.getActiveMenu() +-- @typeCommentStart +-- Determines which menu is being looked at. +-- @typeCommentEnd +-- @realm client +-- @treturn table The active menu. +-- @treturn function The currently hovered option callback. function nut.menu.getActiveMenu() local mX, mY = ScrW() * 0.5, ScrH() * 0.5 local position2 = LocalPlayer():GetPos() @@ -209,7 +232,14 @@ function nut.menu.getActiveMenu() end end +-- @type function nut.menu.onButtonPressed(menu, callback) +-- @typeCommentStart -- Handles whenever a button has been pressed. +-- @typeCommentEnd +-- @realm client +-- @int menu The menu index. +-- @func callback The callback that checks whether the button can be pressed. +-- @treturn bool Whether or not the button can be pressed. function nut.menu.onButtonPressed(menu, callback) table.remove(nut.menu.list, menu) diff --git a/gamemode/core/libs/cl_networking.lua b/gamemode/core/libs/cl_networking.lua index d1a1386b..2ba058d8 100644 --- a/gamemode/core/libs/cl_networking.lua +++ b/gamemode/core/libs/cl_networking.lua @@ -1,3 +1,10 @@ +-- @module Entity +-- @moduleCommentStart +-- Entity meta functions. +-- @moduleCommentEnd + +-- there isnt an entity meta file so its just gonna be here for now + local entityMeta = FindMetaTable("Entity") local playerMeta = FindMetaTable("Player") @@ -28,6 +35,15 @@ function getNetVar(key, default) return value ~= nil and value or default end +-- @type method Entity:getNetVar(key, default) +-- @typeCommentStart +-- Returns the networked variable of the entity. +-- @typeCommentEnd +-- @realm client +-- @classmod Entity +-- @string key The key of the networked variable. +-- @string default The default value to return if the networked variable is not set. +-- @treturn any The networked variable. function entityMeta:getNetVar(key, default) local index = self:EntIndex() @@ -38,4 +54,13 @@ function entityMeta:getNetVar(key, default) return default end +-- @type method Entity:getLocalVar(key, value) +-- @typeCommentStart +-- Returns the networked variable of a player. +-- @typeCommentEnd +-- @realm client +-- @classmod Player +-- @string key The key of the networked variable. +-- @string default The default value to return if the networked variable is not set. +-- @treturn any The networked variable. playerMeta.getLocalVar = entityMeta.getNetVar \ No newline at end of file diff --git a/gamemode/core/libs/sh_anims.lua b/gamemode/core/libs/sh_anims.lua index 6eaadf89..097f42b6 100644 --- a/gamemode/core/libs/sh_anims.lua +++ b/gamemode/core/libs/sh_anims.lua @@ -1,3 +1,8 @@ +-- @module nut.anim +-- @moduleCommentStart +-- Library functions for nut.anim +-- @moduleCommentEnd + nut.anim = nut.anim or {} nut.anim.citizen_male = { @@ -330,6 +335,13 @@ nut.anim.fastZombie = { local translations = {} +-- @type function nut.anim.setModelClass(model, class) +-- @typeCommentStart +-- Sets the animation class for a specified model. +-- @typeCommentEnd +-- @realm shared +-- @string model The model for which to set the animation class. +-- @string class The animation class to set. function nut.anim.setModelClass(model, class) if (!nut.anim[class]) then error("'"..tostring(class).."' is not a valid animation class!") @@ -342,6 +354,13 @@ end local stringLower = string.lower local stringFind = string.find +-- @type function nut.anim.getModelClass(model) +-- @typeCommentStart +-- Gets the animation class for a specified model. If an animation class has not yet been set for the model, it sets a default animation class based on the model's name. +-- @typeCommentEnd +-- @realm shared +-- @string model The model for which to get the animation class. +-- @treturn string The animation class for the specified model. function nut.anim.getModelClass(model) model = stringLower(model) local class = translations[model] @@ -355,7 +374,6 @@ function nut.anim.getModelClass(model) class = "citizen_male" end - nut.anim.setModelClass(model, class) return class end @@ -367,13 +385,23 @@ nut.anim.setModelClass("models/vortigaunt.mdl", "vort") nut.anim.setModelClass("models/vortigaunt_blue.mdl", "vort") nut.anim.setModelClass("models/vortigaunt_doctor.mdl", "vort") nut.anim.setModelClass("models/vortigaunt_slave.mdl", "vort") -nut.anim.setModelClass("models/vortigaunt_slave.mdl", "vort") nut.anim.setModelClass("models/alyx.mdl", "citizen_female") nut.anim.setModelClass("models/mossman.mdl", "citizen_female") do local playerMeta = FindMetaTable("Player") + -- @type method Player:forceSequence(sequence, callback, time, noFreeze) + -- @typeCommentStart + -- Forces the player to play a specific animation sequence. + -- @typeCommentEnd + -- @realm shared + -- @classmod Player + -- @string sequence The name of the sequence to play. + -- @func callback An optional function to call when the animation sequence is finished. + -- @int[opt] number time The time in seconds to play the animation sequence. If not set, it will use the default time for the sequence. + -- @bool[opt] noFreeze Whether to freeze the player during the animation sequence. + -- @treturn number The time in seconds for the animation sequence to complete, or false if the sequence is invalid. function playerMeta:forceSequence(sequence, callback, time, noFreeze) hook.Run("OnPlayerEnterSequence", self, sequence, callback, time, noFreeze) @@ -409,6 +437,12 @@ do return false end + -- @type method Player:leaveSequence() + -- @typeCommentStart + -- Forces the player to leave the current animation sequence they are playing. + -- @typeCommentEnd + -- @realm shared + -- @classmod Player function playerMeta:leaveSequence() hook.Run("OnPlayerLeaveSequence", self) diff --git a/gamemode/core/libs/sh_character.lua b/gamemode/core/libs/sh_character.lua index d065da49..be9ce1fb 100644 --- a/gamemode/core/libs/sh_character.lua +++ b/gamemode/core/libs/sh_character.lua @@ -55,6 +55,17 @@ if (CLIENT) then end end +-- @type function nut.char.new(data, id, client, steamID) +-- @typeCommentStart +-- Creates a new character object with the given data and metadata. +-- @typeCommentEnd +-- @realm shared +-- @classmod Character +-- @table data A table containing the character data. +-- @int[default=0] id The ID of the character. +-- @Player client The player associated with the character. +-- @string[opt] steamID The SteamID of the player associated with the character. +-- @treturn table The newly created character object. function nut.char.new(data, id, client, steamID) local character = setmetatable({vars = {}}, nut.meta.character) for k, v in pairs(nut.char.vars) do @@ -419,13 +430,42 @@ end -- Additions to the player metatable here. do local playerMeta = FindMetaTable("Player") + -- @type method Player:steamName() + -- @typeCommentStart + -- Returns the players Steam name. + -- @typeCommentEnd + -- @realm shared + -- @classmod Player + -- @treturn string The player's Steam name. playerMeta.steamName = playerMeta.steamName or playerMeta.Name + + -- @type method Player:SteamName() + -- @typeCommentStart + -- Returns the players Steam name. Alias to Player:steamName(). + -- @typeCommentEnd + -- @realm shared + -- @classmod Player + -- @treturn string The player's Steam name. playerMeta.SteamName = playerMeta.steamName + -- @type method Player:getChar() + -- @typeCommentStart + -- Returns the character associated with the player. + -- @typeCommentEnd + -- @realm shared + -- @classmod Player + -- @treturn table The character object associated with the player, or nil if no character is associated. function playerMeta:getChar() return nut.char.loaded[self.getNetVar(self, "char")] end + -- @type method Player:Name() + -- @typeCommentStart + -- Returns the name of the player's character, or the player's Steam name if the character is not available. + -- @typeCommentEnd + -- @realm shared + -- @classmod Player + -- @treturn string The name of the player's character or the player's Steam name if no character is available. function playerMeta:Name() local character = self.getChar(self) @@ -434,6 +474,21 @@ do or self.steamName(self) end + -- @type method Player:Nick() + -- @typeCommentStart + -- Returns the name of the player's character, or the player's Steam name if the character is not available. Alias to Player:Name(). + -- @typeCommentEnd + -- @realm shared + -- @classmod Player + -- @treturn string The name of the player's character or the player's Steam name if no character is available. playerMeta.Nick = playerMeta.Name + + -- @type method Player:GetName() + -- @typeCommentStart + -- Returns the name of the player's character, or the player's Steam name if the character is not available. Alias to Player:Name(). + -- @typeCommentEnd + -- @realm shared + -- @classmod Player + -- @treturn string The name of the player's character or the player's Steam name if no character is available. playerMeta.GetName = playerMeta.Name end diff --git a/gamemode/core/libs/sh_player.lua b/gamemode/core/libs/sh_player.lua index 90f49505..e614a75f 100644 --- a/gamemode/core/libs/sh_player.lua +++ b/gamemode/core/libs/sh_player.lua @@ -1,3 +1,8 @@ +-- @module Player +-- @moduleCommentStart +-- Player meta functions. +-- @moduleCommentEnd + local playerMeta = FindMetaTable("Player") nut.util.include("nutscript/gamemode/core/meta/sh_player.lua")