Module:WorkshopsData/doc

Overview
Module for compiling workshops (or production buildings as they are called in-game) information from wiki data sources. Restructures the flat data tables that are produced from CsvUtils to make them more conducive to Lua methods that need to display the information.

Usage
The standard way of using this module is a call like the following:

iconFilename = WorkshopsData.getWorkshopIcon(workshopName)

This will return a string corresponding to the filename of the icon of the workshop, including the .png extension. It is preferable to call getter methods with the name of the workshop rather than retrieving the entire record for the workshop, so that your code stays protected from variations in this module. The getter methods are all called with the plain-language name of the workshop, as spelled in the game.

longDescription = WorkshopsData.getWorkshopDescription(workshopName) constructionCategory = WorkshopsData.getWorkshopCategory(workshopName) sizeX, sizeY = WorkshopsData.getWorkshopSize(workshopName) requiredGoodsTable = WorkshopsData.getWorkshopRequiredGoods(workshopName) timeSeconds = WorkshopsData.getWorkshopConstructionTime(workshopName) cityScore = WorkshopsData.getWorkshopCityScore(workshopName) isMovable = WorkshopsData.isWorkshopMoveable(workshopName) isInitiallyEssential = WorkshopsData.isWorkshopInitiallyEssential(workshopName) storageCap = WorkshopsData.getWorkshopStorage(workshopName) workplacesTable = WorkshopsData.getWorkshopWorkplaces(workshopName) recipesTable = WorkshopsData.getWorkshopRecipes(workshopName) iconFilename = WorkshopsData.getWorkshopIcon(workshopName)

And the following getter methods are all called with the workshop's ID. You will have an ID instead of a display name when dealing with other game data like, recipes, goods, etc. name = WorkshopsData.getWorkshopNameByID(workshopID) iconFilename = WorkshopsData.getWorkshopIconByID(workshopID)

As a last resort, or if you need to transform the data structure, you can call the method  or . This returns a whole record from the data table corresponding to the requested display name.

The data table for workshops has the following structure:

workshopsTable = { ["workshop1_ID"] = { ["id"] = "workshop1_ID", ["displayName"] = "Plain Language Name", ["description"] = "A long string with some HTML entities too.", ["category"] = "Construction toolbar category", ["sizeX"] = 9, size in tiles ["sizeY"] = 9, size in tiles ["requiredGoods"] = { [1] = { ["stackSize"] = 99, ["goodID"] = "good1_ID" }, [2] = { ["stackSize"] = 99, ["goodID"] = "good2_ID" }, [3] = { ... } or missing if fewer },		["constructionTime"] = 99, number of seconds ["cityScore"] = 99, points? ["movable"] = true or false, if it can be moved at any cost ["initiallyEssential"] = true or false, if a new-game-starting blueprint ["storage"] = 99, capacity ["workplaces"] = { [1] = "Any", [2] = "Any", [3] = "Any", [4] = ... representing the number of workplaces, or missing if fewer },		["recipes"] = { [1] = "recipe1_ID", [2] = "recipe2_ID", [3] = "recipe3_ID", [4] = ... or missing if fewer }	},	["workshop2_ID"] = { ...	},	["workshop3_ID"] = { ...	},	... }