Workshop Library
Steam Workshop addon downloading, mounting, and management system for the Lilia framework.
Overview
The workshop library provides comprehensive functionality for managing Steam Workshop addons in the Lilia framework. It handles automatic downloading, mounting, and management of workshop content required by the gamemode and its modules. The library operates on both server and client sides, with the server gathering workshop IDs from modules and mounted addons, while the client handles downloading and mounting of required content. It includes user interface elements for download progress tracking and addon information display. The library ensures that all required workshop content is available before gameplay begins.
lia.workshop.addWorkshop
đ Purpose
Adds a workshop addon ID to the server's required workshop content list
â° When Called
Called when modules or addons need specific workshop content
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
id |
string/number | The Steam Workshop ID of the addon to add |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Add workshop addon from module configuration
local workshopId = module.WorkshopContent
if workshopId then
lia.workshop.addWorkshop(workshopId)
end
âī¸ High Complexity
-- High: Add multiple workshop addons with validation
local workshopIds = {"1234567890", "0987654321", "1122334455"}
for _, id in ipairs(workshopIds) do
if id and id ~= "" then
lia.workshop.addWorkshop(id)
end
end
lia.workshop.gather
đ Purpose
Gathers all workshop IDs from mounted addons and module configurations
â° When Called
Called during module initialization to collect all required workshop content
âŠī¸ Returns
- table - Table containing all workshop IDs that need to be downloaded
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Gather and validate workshop IDs
local workshopIds = lia.workshop.gather()
local count = table.Count(workshopIds)
print("Found " .. count .. " workshop addons")
âī¸ High Complexity
-- High: Gather workshop IDs and send to specific players
local workshopIds = lia.workshop.gather()
for _, ply in player.Iterator() do
if ply:IsAdmin() then
net.Start("liaWorkshopDownloaderStart")
net.WriteTable(workshopIds)
net.Send(ply)
end
end
lia.workshop.send
đ Purpose
Sends the cached workshop IDs to a specific player to initiate download
â° When Called
Called when a player requests workshop content or during initial spawn
âī¸ Parameters
| Parameter | Type | Description |
|---|---|---|
ply |
Player | The player to send workshop IDs to |
âŠī¸ Returns
- None
đ Realm
Server
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Send workshop IDs to admin players only
for _, ply in player.Iterator() do
if ply:IsAdmin() then
lia.workshop.send(ply)
end
end
âī¸ High Complexity
-- High: Send workshop IDs with validation and logging
local function sendToPlayer(ply)
if IsValid(ply) and ply:IsConnected() then
lia.workshop.send(ply)
print("Sent workshop IDs to " .. ply:Name())
end
end
hook.Add("PlayerInitialSpawn", "CustomWorkshopSend", function(ply)
timer.Simple(5, function()
sendToPlayer(ply)
end)
end)
lia.workshop.hasContentToDownload
đ Purpose
Checks if there are any workshop addons that need to be downloaded
â° When Called
Called to determine if the client needs to download workshop content
âŠī¸ Returns
- boolean - True if content needs to be downloaded, false otherwise
đ Realm
Client
đĄ Example Usage
đ° Low Complexity
-- Simple: Check if downloads are needed
if lia.workshop.hasContentToDownload() then
print("Workshop content needs to be downloaded")
end
đ Medium Complexity
-- Medium: Check and show notification
if lia.workshop.hasContentToDownload() then
notification.AddLegacy("Workshop content available for download", NOTIFY_GENERIC, 5)
end
âī¸ High Complexity
-- High: Check downloads and create custom UI
local function checkDownloads()
if lia.workshop.hasContentToDownload() then
local frame = vgui.Create("liaFrame")
frame:SetTitle("Workshop Downloads Available")
frame:SetSize(400, 200)
frame:Center()
frame:MakePopup()
local btn = vgui.Create("liaButton", frame)
btn:SetText("Download Now")
btn:Dock(BOTTOM)
btn.DoClick = function()
lia.workshop.mountContent()
frame:Close()
end
end
end
hook.Add("OnEntityCreated", "CheckWorkshopDownloads", function(ent)
if ent == LocalPlayer() then
timer.Simple(1, checkDownloads)
end
end)
lia.workshop.mountContent
đ Purpose
Initiates the mounting process for required workshop content with user confirmation
â° When Called
Called when the client needs to download and mount workshop addons
âŠī¸ Returns
- None
đ Realm
Client
đĄ Example Usage
đ° Low Complexity
đ Medium Complexity
-- Medium: Mount content with custom callback
lia.workshop.mountContent()
hook.Add("Think", "CheckMountComplete", function()
if not lia.workshop.hasContentToDownload() then
print("All workshop content mounted successfully")
hook.Remove("Think", "CheckMountComplete")
end
end)
âī¸ High Complexity
-- High: Mount content with progress tracking and custom UI
local function mountWithProgress()
local needed = {}
local ids = lia.workshop.serverIds or {}
for id in pairs(ids) do
if id ~= "3527535922" and not mounted(id) and not mountLocal(id) then
needed[#needed + 1] = id
end
end
if #needed > 0 then
local frame = vgui.Create("liaFrame")
frame:SetTitle("Workshop Content Download")
frame:SetSize(500, 300)
frame:Center()
frame:MakePopup()
local progressPanel = vgui.Create("Panel", frame)
progressPanel:Dock(TOP)
progressPanel:SetHeight(30)
progressPanel:DockMargin(10, 10, 10, 10)
local progressFraction = 0
local progressText = "0/" .. #needed
progressPanel.Paint = function(s, w, h)
draw.RoundedBox(4, 0, 0, w, h, Color(60, 60, 60))
draw.RoundedBox(4, 2, 2, (w - 4) * progressFraction, h - 4, lia.color.theme.primary or Color(100, 150, 255))
draw.SimpleText(progressText, "LiliaFont.17", w / 2, h / 2, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
local function updateProgress(current, total)
progressFraction = current / total
progressText = current .. "/" .. total
end
lia.workshop.mountContent()
end
end
hook.Add("PlayerInitialSpawn", "MountWorkshopContent", function(ply)
if ply == LocalPlayer() then
timer.Simple(3, mountWithProgress)
end
end)