aboutsummaryrefslogtreecommitdiff
path: root/gamemode/core/pac
diff options
context:
space:
mode:
Diffstat (limited to 'gamemode/core/pac')
-rw-r--r--gamemode/core/pac/cl_pac.lua3
-rw-r--r--gamemode/core/pac/sv_pac.lua31
2 files changed, 26 insertions, 8 deletions
diff --git a/gamemode/core/pac/cl_pac.lua b/gamemode/core/pac/cl_pac.lua
index 063e1b1..490ad31 100644
--- a/gamemode/core/pac/cl_pac.lua
+++ b/gamemode/core/pac/cl_pac.lua
@@ -1,6 +1,3 @@
---[[
- A lazy loader for pac3 costumes, used for weapons/armor/ect.
-]]
--As soon as the client connects, request the names of all the pac's on the server
diff --git a/gamemode/core/pac/sv_pac.lua b/gamemode/core/pac/sv_pac.lua
index 229b258..0764162 100644
--- a/gamemode/core/pac/sv_pac.lua
+++ b/gamemode/core/pac/sv_pac.lua
@@ -1,8 +1,9 @@
---[[
- The server side lazy loader for pac3 costumes
- PAC3 outfits are not downloaded until they are needed, we can keep the inital download to join the server pretty small this way.
- The downside is that the game might lag a little when someone wears something that is rare/new and everyone has to download it.
+--- The server side lazy loader for pac3 costumes.
+--PAC3 outfits are not downloaded until they are needed, we can keep the inital download to join the server pretty small this way.
+-- The downside is that the game might lag a little when someone wears something that is rare/new and everyone has to download it.
+--@module sv_pac.lua
+--[[
Console Commands:
artery_reload_pacs
The server will cache PAC's so it dosen't need to read form disk every time. If you're live editing pac's on the server, and are wondering why your changes aren't showing, use this command. There is no command to clear client cache, because applying a pac also sends a hash of the pac to the client, and the client re-downloads if the hashes are different.
@@ -56,6 +57,11 @@ end )
local pacsources = {
["data/artery/pacs/"] = "GAME"
}
+--- Add a resource that we can load pacs from.
+-- Automatically tries to reload when a pac can't be found
+-- Starts out with "data/artery/pacs/" = "GAME"
+--@tparam string filepath the path to search for pacs
+--@tparam string|bool from the game path ("GAME" | "LUA" | "DATA" | "MOD"), can also be a boolean (true="GAME" | false="DATA")
function p3.AddPacSource(filepath,from)
pacsources[filepath] = from
end
@@ -74,16 +80,26 @@ local function loadhashes()
end
end
loadhashes()
+
+---Reloads the hashes.
+-- Run this if you changed a pac and want to reload it. ![Requires admin](./req_admin)
+--@concommand artery_reload_pac_hashes
concommand.Add("artery_reload_pac_hashes",function(ply,cmd,args)
if not ply:IsAdmin() then return end
loadhashes()
end)
+
+---Print the pac hashes.
+-- Prints all the pac hashes that are loaded (for debugging).
+--@concommand artery_print_pac_hashes
concommand.Add("artery_print_pac_hashes",function(ply,cmd,args)
PrintTable(pachashes)
end)
local appliedpacs = {}
+---Apply a pac to an entity.
+-- Applies a pac to an entity, pac should be a file name (not path!) without the .txt
function p3.ApplyPac(what, name)
log.debug(string.format("Applying pac %q to %q",name,tostring(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)))
@@ -100,6 +116,8 @@ function p3.ApplyPac(what, name)
net.Broadcast()
end
+---Remove a pac to an entity.
+-- Removes a pac to an entity, pac should be a file name without the .txt
function p3.RemovePac(what, name)
log.debug(string.format("Removeing pac %q from %q",name,tostring(what)))
assert(appliedpacs[what][name],"Attempted to remove a pac that an entity is not wearing!")
@@ -114,6 +132,8 @@ function p3.RemovePac(what, name)
net.Broadcast()
end
+---Find the pacs applied to an entity
+-- Find all the pacs applied to a certain entity.
function p3.GetPacs(what)
return appliedpacs[what] or {}
end
@@ -194,7 +214,8 @@ net.Receive("artery_requestpac",function(ln,ply)
end)
---Does all the things needed to edit pac's live
+---Reload pacs.
+-- Does all the things needed to edit pac's live
concommand.Add("artery_reload_pacs",function(ply,cmd,args)
if not ply:IsAdmin() then return end
pac_cache = {}