diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-01-08 22:28:08 -0500 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-01-08 22:28:08 -0500 |
| commit | 98e0462e4f6b13ff26af5211409352d45dd9453e (patch) | |
| tree | fbff14dc9a0fffdda409d9989f2e34cd4bb265f6 /gamemode/core/npc/sv_npcsystem.lua | |
| parent | 4879eb1d78520ce0ac9b0bb0ef5244cf65ad7c99 (diff) | |
| download | artery-98e0462e4f6b13ff26af5211409352d45dd9453e.tar.gz artery-98e0462e4f6b13ff26af5211409352d45dd9453e.tar.bz2 artery-98e0462e4f6b13ff26af5211409352d45dd9453e.zip | |
Add a ton of icons, more work on refactoring
Diffstat (limited to 'gamemode/core/npc/sv_npcsystem.lua')
| -rw-r--r-- | gamemode/core/npc/sv_npcsystem.lua | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gamemode/core/npc/sv_npcsystem.lua b/gamemode/core/npc/sv_npcsystem.lua new file mode 100644 index 0000000..b41f4e6 --- /dev/null +++ b/gamemode/core/npc/sv_npcsystem.lua @@ -0,0 +1,39 @@ + +local f = nrequire("concommands.lua") +local n = {} +local npcs = {} --Master table of npcs +local autocompletef + +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") + npcs[npc.Name] = npc + autocompletef = f.AutocompleteFunction(npcs) +end + +function n.CreateNPCByName(npcname, pos) + print("Createing a " ,npcname ," at ", pos) + local npctbl = npcs[npcname] + local npc = ents.Create("npc_huntable") + npc:SetPos(pos) + for k,v in pairs(npctbl) do + npc[k] = v + end + npc:Spawn() + return npc +end + + +if SERVER then + autocompletef = nil +else + autocompletef = f.AutocompleteFunction(npcs) +end +concommand.Add("artery_makenpc",function(ply,cmd,args) + if not ply:IsAdmin() then return end + local na = args[1] + n.CreateNPCByName(na,ply:GetEyeTrace().HitPos) +end, +autocompletef) + +return n |
