diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2017-06-19 00:07:01 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2017-06-19 00:07:01 -0400 |
| commit | 461a29d8fdb2fd6c86a77912e9c2232e1f101ca8 (patch) | |
| tree | ed76c1a1abf64369ee36b88533e78a8a94566631 /gamemode/core | |
| parent | 0ae33ad32868af226fba6d887320aa87aa19d3a4 (diff) | |
| download | artery-461a29d8fdb2fd6c86a77912e9c2232e1f101ca8.tar.gz artery-461a29d8fdb2fd6c86a77912e9c2232e1f101ca8.tar.bz2 artery-461a29d8fdb2fd6c86a77912e9c2232e1f101ca8.zip | |
Massive updates
Lots of stuff was updated, mostly to support addons.
Inventory tracking is also updated a little and a bug fixed in inventory.
Nrequire now probably won't crash the client, no matter how many times
it's used.
Diffstat (limited to 'gamemode/core')
| -rw-r--r-- | gamemode/core/combat/cl_weaponswing.lua | 25 | ||||
| -rw-r--r-- | gamemode/core/combat/sv_weaponswing.lua | 53 | ||||
| -rw-r--r-- | gamemode/core/dataloader/cl_loadglobals.lua | 29 | ||||
| -rw-r--r-- | gamemode/core/dataloader/sv_loadglobals.lua | 70 | ||||
| -rw-r--r-- | gamemode/core/inventory/common/animations/sh_swing_mele.lua | 500 | ||||
| -rw-r--r-- | gamemode/core/inventory/inventory.lua | 11 | ||||
| -rw-r--r-- | gamemode/core/inventory/sv_invtracker.lua | 5 | ||||
| -rw-r--r-- | gamemode/core/pac/sv_pac.lua | 4 |
8 files changed, 681 insertions, 16 deletions
diff --git a/gamemode/core/combat/cl_weaponswing.lua b/gamemode/core/combat/cl_weaponswing.lua index 8ed9637..46603ba 100644 --- a/gamemode/core/combat/cl_weaponswing.lua +++ b/gamemode/core/combat/cl_weaponswing.lua @@ -1,5 +1,5 @@ local CLIENT_PAC_DIR = "artery/client/pacs" - +local itm = nrequire("item.lua") local ball function finddmgpoint(name) local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name) @@ -8,6 +8,16 @@ function finddmgpoint(name) ball = LocalPlayer():FindPACPart(outfit, "wep_point") print("point is",ball,type(ball)) end +function finddmgbox(who,name) + local filepath = string.format(CLIENT_PAC_DIR .. "/%s.txt",name) + local filetext = file.Read(filepath,"DATA") + assert(filetext ~= nil, string.format("Could not find a pac file for name %q (%s)",name,filepath)) + local outfit = CompileString(string.format("return {%s}",filetext),name)() + assert(outfit ~= nil, string.format("Failed to compile %q",filetext)) + ball = who:FindPACPart(outfit, "wep_box") + print("box is", ball,type(ball)) + assert(ball ~= pac.NULL, string.format("Could not find a prop called %q on pac %q","web_box",name)) +end local swingtbl = {} local tracking = false @@ -16,16 +26,19 @@ net.Receive("artery_doanimation",function() local animname = net.ReadString() local animtime = net.ReadDouble() local wepname = net.ReadString() + local pacname = net.ReadString() local animdir = net.ReadString() + local who = net.ReadEntity() swingtbl = {} + --pac.SetupENT(who) + finddmgbox(who,pacname) tracking = true - finddmgpoint(wepname) print("Doing animation:",animname,animtime,echoname) - LocalPlayer():SetLuaAnimation(animname) + who:SetLuaAnimation(animname) timer.Simple(animtime,function() tracking = false - LocalPlayer():StopLuaAnimation(animname) + who:StopLuaAnimation(animname) net.Start("artery_notifyserverofswing") net.WriteString(wepname) net.WriteString(animdir) @@ -44,9 +57,10 @@ concommand.Add("artery_startanimation",function(ply,cmd,args) end) end) +--[[ local lastpos hook.Add("Tick","trace_weppos",function() - if not ball then return end + if not ball or not ball.Entity then return end if lastpos == nil then lastpos = ball.Entity:GetPos() end --`print("Distance between ", ball.Entity:GetPos(), "and", lastpos, " is" ,ball.Entity:GetPos():Distance(lastpos)) if ball.Entity:GetPos():Distance(lastpos) > 2 and tracking then @@ -55,3 +69,4 @@ hook.Add("Tick","trace_weppos",function() end lastpos = ball.Entity:GetPos() end) +]] diff --git a/gamemode/core/combat/sv_weaponswing.lua b/gamemode/core/combat/sv_weaponswing.lua index f238497..408e7d2 100644 --- a/gamemode/core/combat/sv_weaponswing.lua +++ b/gamemode/core/combat/sv_weaponswing.lua @@ -2,6 +2,7 @@ This file tells you what weapons need their swings recalculated ]] local itm = nrequire("core/inventory/item.lua") +local inv = nrequire("core/inventory/inventory.lua") local ws = {} --Cache swing hits, if we used one once, we'll probably use it again soon @@ -41,10 +42,52 @@ function ws.makeSwingable(tbl) swingable[tbl.Name] = tbl end +local function record_animations_for(swingable, e) + print("recording animations on", e) + PrintTable(swingable) + local einv = e.data.inventories[1] + local spot = einv:FindPlaceFor(swingable) + assert(spot != nil, "Could not equip the npc with that") + einv:Put(spot,swingable) + for k,v in pairs(swingable.attacks) do + net.Start("artery_doanimation") + net.WriteString(v.anim) + net.WriteDouble(v.time) + net.WriteString(swingable.Name) + net.WriteString(swingable.pacname) + net.WriteString(".") + net.WriteEntity(e) + net.Broadcast() + end + timer.Simple(5,function() + --assert(IsValid(einv),"Npc's inventory is no longer valid!") + einv:Remove(spot) + end) +end + +--Create a fake thing in front of the player, do the swing animations, and record them. concommand.Add("artery_recordanimations",function(ply,cmd,args) + e = ents.Create("npc_citizen") + e:SetPos(ply:GetEyeTrace().HitPos) + e:Spawn() + e.data = {inventories = {}} + local einv = inv.CreateInventory("Equipment") + einv.id = 1 + einv.Owner = e + e.data.inventories[einv.id] = einv + local i = 1 + for k,v in pairs(swingable) do + timer.Simple(5*i,function() + record_animations_for(v,e) + end) + i = i + 1 + end + + --[[ local animqueuetime = 0 for k,v in pairs(swingable) do --equip the right item + print("equipable inventory:") local eqi = ply.data.inventories[1] print(ply.data.inventories[1]) @@ -60,16 +103,18 @@ concommand.Add("artery_recordanimations",function(ply,cmd,args) print("Doing attack:") print(i,":",j) net.Start("artery_doanimation") - net.WriteString(j.anim) - net.WriteDouble(j.time) - net.WriteString(v.Name) - net.WriteString(i) + net.WriteString(j.anim) --Animation name (to return) + net.WriteDouble(j.time) --Timeing of the animation + net.WriteString(v.Name) --Name of the item (to return) + net.WriteString(v.pacname) --Name of the pac for this item + net.WriteString(i) --direction of the animation (to return) net.Send(ply) end) animqueuetime = animqueuetime + j.time + 1 end end + ]] end) diff --git a/gamemode/core/dataloader/cl_loadglobals.lua b/gamemode/core/dataloader/cl_loadglobals.lua new file mode 100644 index 0000000..919ecb5 --- /dev/null +++ b/gamemode/core/dataloader/cl_loadglobals.lua @@ -0,0 +1,29 @@ + +net.Receive("artery_respondfile",function() + local filename = net.ReadString() + local filetext = net.ReadString() + local dirname = string.GetPathFromFilename(filename) + file.CreateDir("artery/client/files/" .. dirname) + file.Write("artery/client/files/" .. filename,filetext) + CompileString(filetext,filename)() +end) + +net.Receive("artery_loadfile",function() + local filename = net.ReadString() + local hash = net.ReadUInt(32) + local cache = file.Read("artery/client/files/" .. filename,"DATA") + if cache == nil then --We don't have this file downloaded! + net.Start("artery_requestcsfile") + net.WriteString(filename) + net.SendToServer() + return + end + local thash = tonumber(util.CRC(cache)) + if hash != thash then + net.Start("artery_requestcsfile") + net.WriteString(filename) + net.SendToServer() + else + CompileString(cache,filename)() + end +end) diff --git a/gamemode/core/dataloader/sv_loadglobals.lua b/gamemode/core/dataloader/sv_loadglobals.lua new file mode 100644 index 0000000..85bbc5f --- /dev/null +++ b/gamemode/core/dataloader/sv_loadglobals.lua @@ -0,0 +1,70 @@ +print("Load globals called") + +local function ExecuteOnFolder(dir, recursive, func) + recursive = recursive ~= nil and recursive or false + local path = "data/artery/" + local fpath = table.concat({path,dir,"/*"}) + local files, directories = file.Find(fpath,"GAME") + for k,v in pairs(files) do + local callpath = table.concat({path,dir,"/",v}) + func(callpath) + end + if recursive then + for k,v in pairs(directories) do + local npath = table.concat({dir,"/",v}) + ExecuteOnFolder(npath,true,func) + end + end +end + +util.AddNetworkString("artery_loadfile") +util.AddNetworkString("artery_requestcsfile") +util.AddNetworkString("artery_respondfile") +local toload = {} +local function loadglobals() + ExecuteOnFolder("global",true,function(f) + local filetxt = file.Read(f,"GAME") + local filename = string.GetFileFromFilename(f) + if string.find(filename,"^cl_") then + toload[f] = filetxt + elseif string.find(filename,"^sv_") then + CompileString(filetxt,f)() + else + toload[f] = filetxt + CompileString(filetxt,f)() + end + end) +end + +local function load_cs_files(ply) + for k,v in pairs(toload) do + net.Start("artery_loadfile") + net.WriteString(k) + local hash = util.CRC(v) + net.WriteUInt(tonumber(hash),32) + net.Send(ply) + end +end + +hook.Add("PlayerInitialSpawn","artery_loadglobals",function(ply) + timer.Simple(1,function() + load_cs_files(ply) + end) +end) + +net.Receive("artery_requestcsfile",function(ln,ply) + local which = net.ReadString() + net.Start("artery_respondfile") + net.WriteString(which) + net.WriteString(toload[which]) + net.Send(ply) +end) + +concommand.Add("artery_reloadglobals",function(ply,cmd,args) + if not ply:IsAdmin() then return end + loadglobals() + for k,v in pairs(player.GetAll()) do + load_cs_files(v) + end +end) +loadglobals() diff --git a/gamemode/core/inventory/common/animations/sh_swing_mele.lua b/gamemode/core/inventory/common/animations/sh_swing_mele.lua new file mode 100644 index 0000000..4521ddd --- /dev/null +++ b/gamemode/core/inventory/common/animations/sh_swing_mele.lua @@ -0,0 +1,500 @@ +print("Hello from sh_swing_mele.lua!") + +RegisterLuaAnimation('swing_onehand_left', { + FrameData = { + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_L_Forearm'] = { + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + RF = 14.9983 + }, + ['ValveBiped.Bip01_L_Forearm'] = { + RU = 58.1181, + RR = 27.0889 + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + RU = -7.9421, + RR = 34.3556, + RF = 4.4799 + }, + ['ValveBiped.Bip01_Spine4'] = { + RF = 39.5103 + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + RR = 47.4665, + RF = -19.7371 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + RU = -129.4263, + RR = -47.9277 + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RR = 2.574 + } + }, + FrameRate = 5 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + RF = -18.8755 + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RU = 90, + RR = -4.5286, + RF = -100.8045 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + RU = 23.8203, + RR = -38.9972, + RF = -25.2662 + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + RU = -7.9421, + RR = 34.3556, + RF = 4.4799 + }, + ['ValveBiped.Bip01_L_Forearm'] = { + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + }, + ['ValveBiped.Bip01_L_Forearm'] = { + } + }, + FrameRate = 1.6667 + } + }, + Type = TYPE_GESTURE +}) + +RegisterLuaAnimation('swing_onehand_overhead', { + FrameData = { + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_L_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + RU = -14.9433, + RR = -26.7191, + RF = 10.6193 + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RU = 83.616, + RR = 93.0582, + RF = 62.0103 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + RU = -111.0966, + RR = -74.1549, + RF = -62.4384 + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + RR = -2.5225, + RF = -39.26 + }, + ['ValveBiped.Bip01_L_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + RU = -9.0093, + RR = 14.4999, + RF = 25.671 + } + }, + FrameRate = 5 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + RF = 14.4193 + }, + ['ValveBiped.Bip01_Neck1'] = { + RU = 10.6282, + RR = 9.7472, + RF = -42.9906 + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + RU = -14.9433, + RR = -26.7191, + RF = 10.6193 + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RU = 98.1268, + RR = 5.534, + RF = 96.1386 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + RU = -203.1287, + RR = -120.029, + RF = -2.2254 + }, + ['ValveBiped.Bip01_Spine1'] = { + RF = 9.6129 + }, + ['ValveBiped.Bip01_Spine4'] = { + RU = 18.6599, + RF = 43.4352 + }, + ['ValveBiped.Bip01_L_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + RU = -41.5509, + RR = -6.2725, + RF = 16.9206 + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_L_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + } + }, + FrameRate = 1.6667 + } + }, + Type = TYPE_GESTURE +}) + +RegisterLuaAnimation('swing_onehand_right', { + FrameData = { + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_L_Forearm'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + RF = -13.0166 + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RU = 64.7312, + RR = -12.5429, + RF = -0.7 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + RF = -26.2859 + }, + ['ValveBiped.Bip01_L_Forearm'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + RU = -2.0679, + RR = -3.5029, + RF = 87.3164 + } + }, + FrameRate = 5 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + RF = 47.2023 + }, + ['ValveBiped.Bip01_Neck1'] = { + RR = -15.9212, + RF = -57.372 + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + RR = 21.3645, + RF = 0.6008 + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RU = 64.7168, + RR = -50.8221, + RF = -48.8765 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + RR = -35.8651, + RF = -47.1548 + }, + ['ValveBiped.Bip01_Spine1'] = { + RF = 11.3894 + }, + ['ValveBiped.Bip01_Spine4'] = { + RF = 36.4235 + }, + ['ValveBiped.Bip01_L_Forearm'] = { + RU = 49.4639, + RR = -10.0868, + RF = 6.7341 + }, + ['ValveBiped.Bip01_R_Hand'] = { + RU = -2.0679, + RR = 44.9745, + RF = 85.4281 + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_L_Forearm'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + } + }, + FrameRate = 1.6667 + } + }, + Type = TYPE_GESTURE +}) + +RegisterLuaAnimation('swing_onehand_stab', { + FrameData = { + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_L_Forearm'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + RF = -18.294 + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_L_Forearm'] = { + RU = -23.5308, + RF = -3.6617 + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + RU = -22.1427 + }, + ['ValveBiped.Bip01_Spine1'] = { + RF = -11.4656 + }, + ['ValveBiped.Bip01_Spine4'] = { + RF = -4.7217 + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RU = 24.4736, + RR = -3.368 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + RU = 4.3187, + RR = 2.4775, + RF = -147.3305 + }, + ['ValveBiped.Bip01_R_Hand'] = { + RU = -43.7725, + RR = -3.349, + RF = -3.218 + } + }, + FrameRate = 5 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + RF = 25.4603 + }, + ['ValveBiped.Bip01_Neck1'] = { + RR = -20.3889, + RF = -45.1608 + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + RU = 3.6368, + RR = 20.8097, + RF = 6.6735 + }, + ['ValveBiped.Bip01_R_Forearm'] = { + RU = 83.1342, + RR = -4.2804, + RF = -21.4632 + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + RU = -11.8714, + RR = 4.3073, + RF = -65.2235 + }, + ['ValveBiped.Bip01_Spine1'] = { + RF = 45.7756 + }, + ['ValveBiped.Bip01_Spine4'] = { + RF = 4.61 + }, + ['ValveBiped.Bip01_L_Forearm'] = { + RU = -23.5308, + RF = -3.6617 + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + RU = -22.1427 + }, + ['ValveBiped.Bip01_R_Hand'] = { + RU = -48.1903, + RR = -24.3979, + RF = 53.5558 + } + }, + FrameRate = 10 + }, + { + BoneInfo = { + ['ValveBiped.Bip01_Spine2'] = { + }, + ['ValveBiped.Bip01_Neck1'] = { + }, + ['ValveBiped.Bip01_R_Clavicle'] = { + }, + ['ValveBiped.Bip01_R_Forearm'] = { + }, + ['ValveBiped.Bip01_R_UpperArm'] = { + }, + ['ValveBiped.Bip01_Spine1'] = { + }, + ['ValveBiped.Bip01_Spine4'] = { + }, + ['ValveBiped.Bip01_L_Forearm'] = { + }, + ['ValveBiped.Bip01_L_UpperArm'] = { + }, + ['ValveBiped.Bip01_R_Hand'] = { + } + }, + FrameRate = 1.6667 + } + }, + Type = TYPE_GESTURE +}) diff --git a/gamemode/core/inventory/inventory.lua b/gamemode/core/inventory/inventory.lua index 62e4819..f28cc18 100644 --- a/gamemode/core/inventory/inventory.lua +++ b/gamemode/core/inventory/inventory.lua @@ -119,8 +119,11 @@ function inv.RegisterInventory(tbl) assert(type(tbl[v[1]]) == v[2], string.format("Attempted to register inventory with field %q of type %q when it should have been %q",v[1],type(tbl[v[1]]),v[2])) end - assert(inventories[tbl.Name] == nil, - string.format("Attempted to register 2 inventories with the same name: %q", tbl.Name)) + --assert(inventories[tbl.Name] == nil, + -- string.format("Attempted to register 2 inventories with the same name: %q", tbl.Name)) + if inventories[tbl.Name] ~= nil then + MsgC(Color(255,255,0),"Registering 2 inventories with the same name:" .. tbl.Name) + end assert((tbl.AddObserver == nil and tbl.RemoveObserver == nil) or (tbl.AddObserver ~= nil and tbl.RemoveObserver ~= nil), "AddObserver and RemoveObserver must be defined in pairs") @@ -145,10 +148,10 @@ function inv.CreateInventoryFromData(name,data) local tinv = inv.CreateInventory(name) --print("tinv was", tinv) --PrintTable(tinv) - tinv:DeSerialize(data) + local ret = tinv:DeSerialize(data) --print("is now",tinv) --PrintTable(tinv) - return tinv + return ret end --Must be called in a coroutine. diff --git a/gamemode/core/inventory/sv_invtracker.lua b/gamemode/core/inventory/sv_invtracker.lua index 56407e2..d4e7d79 100644 --- a/gamemode/core/inventory/sv_invtracker.lua +++ b/gamemode/core/inventory/sv_invtracker.lua @@ -145,7 +145,7 @@ function track.NotifyPlayerOfInventory(ply,inv) net.WriteString(inv.Name) net.WriteUInt(#initaldat,32) net.WriteData(initaldat,#initaldat) - print("Before sending, inv owner is", inv.Owner) + print("Before sending, inv owner is", inv.Owner, "and type is",inv.Name) net.WriteEntity(inv.Owner) net.Send(ply) end @@ -264,8 +264,7 @@ concommand.Add("artery_GiveItem",function(ply,cmd,args) xpcall(function() ply:GiveItem(itm.GetItemByName(args[1])) end,function(err) - print("Could not give that item!:") - print(err) + print("Could not give that item!:", err) end) end) diff --git a/gamemode/core/pac/sv_pac.lua b/gamemode/core/pac/sv_pac.lua index 30d2ef7..ad54106 100644 --- a/gamemode/core/pac/sv_pac.lua +++ b/gamemode/core/pac/sv_pac.lua @@ -70,11 +70,15 @@ local function loadhashes() end loadhashes() concommand.Add("artery_reload_pac_hashes",loadhashes) +concommand.Add("artery_print_pac_hashes",function(ply,cmd,args) + PrintTable(pachashes) +end) local appliedpacs = {} function p3.ApplyPac(what, name) print("Applying pac", name, "to",what) + assert(pachashes[name],string.format("Tried to apply pac %s which didn't have a hash. Pac hashes are:%s",name,table.ToString(pachashes,"pachashes",true))) appliedpacs[what] = appliedpacs[what] or {} appliedpacs[what][name] = pachashes[name] net.Start("artery_applypac") |
