aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/npc/sv_npcsystem.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-11-07 00:39:45 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-11-07 00:39:45 -0500
commit07593f0c983ac6b16161829b20ea6fde887fa7e9 (patch)
treea6ae199a547b6b2d7f7e937b8768f4c7bed85eae /gamemode/core/npc/sv_npcsystem.lua
parent7bc4dbb94a1776729f95c319ef28f057ddcd170b (diff)
downloadartery-07593f0c983ac6b16161829b20ea6fde887fa7e9.tar.gz
artery-07593f0c983ac6b16161829b20ea6fde887fa7e9.tar.bz2
artery-07593f0c983ac6b16161829b20ea6fde887fa7e9.zip
Added luadoc comments for core\npc files
Only need to add comments to like half of them though.
Diffstat (limited to 'gamemode/core/npc/sv_npcsystem.lua')
-rw-r--r--gamemode/core/npc/sv_npcsystem.lua33
1 files changed, 30 insertions, 3 deletions
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 <npc_name>
concommand.Add("artery_makenpc", function(ply, cmd, args)
if not ply:IsAdmin() then return end
local na = args[1]