Module:ServicesData: Difference between revisions
From Against the Storm Official Wiki
(Overhauling into a small utility method for Services information, since there isn't a special data model for services anymore.) Tag: Replaced |
(adding method to get the service good ID for a service) |
||
Line 1: | Line 1: | ||
---@module ServicesData | ---@module ServicesData | ||
local ServicesData = {} | local ServicesData = {} | ||
--region Dependencies | |||
local InstitutionsData = require("Module:InstitutionsData") | |||
--endregion | |||
Line 23: | Line 29: | ||
--Yep, IDs are just names right now. | --Yep, IDs are just names right now. | ||
return name | return name | ||
end | |||
function ServicesData.getServiceGoodID(name) | |||
local recipeList = InstitutionsData:getIDsAndRecipesWhereProductID(ServicesData.getID(name)) | |||
if #recipeList > 0 then | |||
--Just need one. | |||
local recipe = recipeList[1] | |||
--Just the first slot, first option. | |||
return InstitutionsData:getRecipeIngredientOptionIDAt(recipe, 1, 1) | |||
else | |||
return nil | |||
end | |||
end | end | ||
Latest revision as of 15:35, 11 November 2024
Documentation for this module may be created at Module:ServicesData/doc
---@module ServicesData local ServicesData = {} --region Dependencies local InstitutionsData = require("Module:InstitutionsData") --endregion --region Public methods ---@public ---Gets the icon filename associated with the specified service. --- ---@param name string service ---@return string icon filename function ServicesData.getIcon(name) return "Icon_Need_" .. name .. ".png" end ---@public ---Gets the ID for the specified service --- ---@param name string service ---@return string ID function ServicesData.getID(name) --Yep, IDs are just names right now. return name end function ServicesData.getServiceGoodID(name) local recipeList = InstitutionsData:getIDsAndRecipesWhereProductID(ServicesData.getID(name)) if #recipeList > 0 then --Just need one. local recipe = recipeList[1] --Just the first slot, first option. return InstitutionsData:getRecipeIngredientOptionIDAt(recipe, 1, 1) else return nil end end --endregion return ServicesData