Files
community_bridge/modules/framework/_default/client.lua
T
MrNewb 90c65dc55e Add GetResourceName function to all modules
Introduces a standardized GetResourceName function to banking, clothing, dispatch, doorlock, framework, fuel, helptext, housing, and other modules. This function returns the name of the in-use resource, improving resource identification and interoperability across the codebase.
2025-09-10 12:27:12 -04:00

36 lines
1016 B
Lua

---@diagnostic disable: duplicate-set-field
Framework = Framework or {}
local currentJobCounts = GlobalState.jobcounts or {}
AddStateBagChangeHandler('jobcounts', 'global', function(bagName, key, value)
if not value then currentJobCounts = {} return end
currentJobCounts = value
end)
---This will get the name of the in use resource.
---@return string
Framework.GetResourceName = function()
return 'default'
end
---This is an internal function that will be used to retrieve job counts later.
---@param jobName string
---@return number
Framework.GetJobCount = function(jobName)
if not currentJobCounts[jobName] then return 0 end
return currentJobCounts[jobName]
end
---This will allow passing a table of job names and returning a sum of the total count.
---@param tbl table
---@return number
Framework.GetJobCountTotal = function(tbl)
local total = 0
for _, jobName in pairs(tbl) do
total = total + Framework.GetJobCount(jobName)
end
return total
end
return Framework