From 07593f0c983ac6b16161829b20ea6fde887fa7e9 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Tue, 7 Nov 2017 00:39:45 -0500 Subject: Added luadoc comments for core\npc files Only need to add comments to like half of them though. --- gamemode/core/npc/sv_npcsystem.lua | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'gamemode/core/npc/sv_npcsystem.lua') diff --git a/gamemode/core/npc/sv_npcsystem.lua b/gamemode/core/npc/sv_npcsystem.lua index d5182d7..0ed21d2 100644 --- a/gamemode/core/npc/sv_npcsystem.lua +++ b/gamemode/core/npc/sv_npcsystem.lua @@ -1,8 +1,16 @@ +---Various functions for npcs. +-- Helps you spawn monsters, townies, and shopkeepers +--@module sv_npcsystem.lua + local f = nrequire("concommands.lua") local n = {} local npcs = {} --Master table of npcs local autocompletef +---Registers an NPC. +-- Adds an npc to the global table. NPC's should have unique .Name fields, if they don't, this function will error. +--@see npc +--@tparam table npc The npc's table. function n.RegisterNPC(npc) assert(npc ~= nil, "Attempted to register a nil npc") assert(npc.Name ~= nil, "Attempted to register an npc without a name") @@ -10,6 +18,10 @@ function n.RegisterNPC(npc) autocompletef = f.AutocompleteFunction(npcs) end +---Creates an NPC. +-- Creates an npc, by name +--@tparam string npcname The npc's name +--@tparam vector3 pos The position to spawn the npc function n.CreateNPCByName(npcname, pos) assert(npcs[npcname],string.format("No npc named %q, valid names are:\n%s",npcname,table.concat(table.GetKeys(npcs),"\n"))) --print("Createing a ", npcname, " at ", pos) @@ -26,7 +38,10 @@ function n.CreateNPCByName(npcname, pos) return npc end ---Creates a shop npc with this tbl +---Creats a shop npc. +-- Creates a shop npc from a shop npc table +--@see shopnpctbl +--@tparam table npc The shop npc's table. function n.CreateShop(npc) --print("Createing shop npc") local npcent = ents.Create("npc_shop") @@ -37,7 +52,10 @@ function n.CreateShop(npc) --print("Called spawn") end ---Creates a townie npc with this tbl +---Creates a townie. +-- Creates a new townie that wanders around his areas of intrest +--@see townienpctbl +--@tparam table npc The townie npc's table. function n.CreateTownie(tbl) local npcent = ents.Create("npc_townie") for k, v in pairs(tbl) do @@ -46,7 +64,10 @@ function n.CreateTownie(tbl) npcent:Spawn() end ---Creates a new navigation node for npc's +---Create an area of intrest. +-- Creates an point that you can use in a townie's locations of intrest. +--@see navnodetbl +--@tparam table tbl The table for the nav node function n.CreateNavNode(tbl) local nodeent = ents.Create("info_townienode") assert(tbl ~= nil, "Tried to create a nil navnode") @@ -99,6 +120,9 @@ hook.Add("InitPostEntity", "artery_spawnmapnpcs", function() loadMap() end) +---Reloads the entities on the map +-- Removes and then reload all of the entities on the level ![Requires admin](./req_admin) +--@concommand artery_reloadmap concommand.Add("artery_reloadmap", function(ply,cmd,args) if not ply:IsAdmin() then return end for k, v in pairs(removeents) do @@ -112,6 +136,9 @@ concommand.Add("artery_reloadmap", function(ply,cmd,args) loadMap() end) +---Create a new npc +-- Creates a new npc a the point the player is looking ![Requires admin](./req_admin) +--@concommand artery_makenpc concommand.Add("artery_makenpc", function(ply, cmd, args) if not ply:IsAdmin() then return end local na = args[1] -- cgit v1.2.3-70-g09d2