From 9ae67530dc4be9eaab7b1243330e810d1d5a6fee Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 24 Oct 2016 19:00:58 -0400 Subject: Added npc system --- gamemode/shared/loadnpcs.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 gamemode/shared/loadnpcs.lua (limited to 'gamemode/shared/loadnpcs.lua') diff --git a/gamemode/shared/loadnpcs.lua b/gamemode/shared/loadnpcs.lua new file mode 100644 index 0000000..bff5135 --- /dev/null +++ b/gamemode/shared/loadnpcs.lua @@ -0,0 +1,36 @@ + +local f = include("concommands.lua") + +ART = ART or {} + +local npcs = {} + +function ART.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 +end + +function ART.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() +end + +local autocompletef +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 n = args[1] + ART.CreateNPCByName(n,ply:GetEyeTrace().HitPos) +end, +autocompletef) -- cgit v1.2.3-70-g09d2