|
|
| Line 3: |
Line 3: |
|
| |
|
|
| |
|
| --#region Cargo query and type definitions | | local BuildingDataModule = require("Module-Building_data") |
|
| |
|
| local QUERY = {
| |
| TABLE = "Buildings",
| |
| WHERE_FIELD = "page_name",
| |
| FIELDS = {
| |
| "page_name",
| |
| "guid",
| |
| "Name",
| |
| "Category",
| |
| "DisplayNameTerm_en",
| |
| "DisplayNamePluralTerm_en",
| |
| "DescriptionTerm_en",
| |
| "UpgradeTerm",
| |
| "UpgradeTerm_en",
| |
| "IconAddress",
| |
| "PlacementRules_1",
| |
| "PlacementRules_2",
| |
| "PlacementRules_3",
| |
| "PlacementRules_4",
| |
| "PlacementRules_5",
| |
| "PlacementRules_6",
| |
| "AnchorBuildingNames_1",
| |
| "AnchorBuildingNames_2",
| |
| "ConstructionResources",
| |
| "ConstructionResources_1_Name",
| |
| "ConstructionResources_1_Amount",
| |
| "ConstructionResources_2_Name",
| |
| "ConstructionResources_2_Amount",
| |
| "ConstructionResources_3_Name",
| |
| "ConstructionResources_3_Amount",
| |
| "ConstructionResources_4_Name",
| |
| "ConstructionResources_4_Amount",
| |
| "ConstructionResources_5_Name",
| |
| "ConstructionResources_5_Amount",
| |
| "ConstructionResources_6_Name",
| |
| "ConstructionResources_6_Amount",
| |
| "SecondaryPrefabAddresses_1",
| |
| "SecondaryPrefabAddresses_2",
| |
| "RepairResources_1_Name",
| |
| "RepairResources_1_Amount",
| |
| "RepairResources_2_Name",
| |
| "RepairResources_2_Amount",
| |
| "RepairResources_3_Name",
| |
| "RepairResources_3_Amount",
| |
| "RepairResources_4_Name",
| |
| "RepairResources_4_Amount",
| |
| "RepairResources_5_Name",
| |
| "RepairResources_5_Amount",
| |
| "RepairResources_6_Name",
| |
| "RepairResources_6_Amount",
| |
| "ConstructionTime",
| |
| "ConstructionPeepCount",
| |
| "UnlockMode",
| |
| "UnlockValues",
| |
| "UnlockValues_1",
| |
| "UnlockValues_2",
| |
| "UnlockValues_3",
| |
| "UnlockValues_4",
| |
| "RequiredRecords_1",
| |
| "UpgradePointsEarned",
| |
| "LockedInDemo",
| |
| "FootprintIconAddress",
| |
| "TechTreeDisplay",
| |
| "TechTreePrevious",
| |
| "TechTreeRow",
| |
| "AdjacencyBonuses",
| |
| "AdjacencyBonuses_1_GroupName",
| |
| "AdjacencyBonuses_1_Evaluator",
| |
| "AdjacencyBonuses_1_EvaluatorThreshold",
| |
| "AdjacencyBonuses_1_Action",
| |
| "AdjacencyBonuses_1_ActionNames",
| |
| "AdjacencyBonuses_1_ActionNames_1",
| |
| "AdjacencyBonuses_1_ActionNames_2",
| |
| "AdjacencyBonuses_1_ActionNames_3",
| |
| "AdjacencyBonuses_1_ActionNames_4",
| |
| "AdjacencyBonuses_1_ActionNames_5",
| |
| "AdjacencyBonuses_1_EvaluatorValue",
| |
| "AdjacencyBonuses_1_ActionValue",
| |
| "AdjacencyBonuses_2_GroupName",
| |
| "AdjacencyBonuses_2_Evaluator",
| |
| "AdjacencyBonuses_2_EvaluatorThreshold",
| |
| "AdjacencyBonuses_2_Action",
| |
| "AdjacencyBonuses_2_ActionNames",
| |
| "AdjacencyBonuses_2_ActionNames_1",
| |
| "AdjacencyBonuses_2_ActionNames_2",
| |
| "AdjacencyBonuses_2_ActionNames_3",
| |
| "AdjacencyBonuses_2_ActionNames_4",
| |
| "AdjacencyBonuses_2_ActionNames_5",
| |
| "AdjacencyBonuses_2_EvaluatorValue",
| |
| "AdjacencyBonuses_2_ActionValue",
| |
| "AdjacencyBonuses_3_GroupName",
| |
| "AdjacencyBonuses_3_Evaluator",
| |
| "AdjacencyBonuses_3_EvaluatorThreshold",
| |
| "AdjacencyBonuses_3_Action",
| |
| "AdjacencyBonuses_3_ActionNames",
| |
| "AdjacencyBonuses_3_ActionNames_1",
| |
| "AdjacencyBonuses_3_ActionNames_2",
| |
| "AdjacencyBonuses_3_ActionNames_3",
| |
| "AdjacencyBonuses_3_ActionNames_4",
| |
| "AdjacencyBonuses_3_EvaluatorValue",
| |
| "AdjacencyBonuses_3_ActionValue",
| |
| "AdjacencyBonuses_4_GroupName",
| |
| "AdjacencyBonuses_4_Evaluator",
| |
| "AdjacencyBonuses_4_EvaluatorThreshold",
| |
| "AdjacencyBonuses_4_Action",
| |
| "AdjacencyBonuses_4_ActionNames",
| |
| "AdjacencyBonuses_4_EvaluatorValue",
| |
| "AdjacencyBonuses_4_ActionValue",
| |
| "OperationRules",
| |
| "OperationRules_1",
| |
| "OperationRules_2",
| |
| "OperationRules_3",
| |
| "OperationRules_4",
| |
| "OperationRules_5",
| |
| "OperationRules_6",
| |
| "OperationRules_7",
| |
| "OperationRules_8",
| |
| "OperationRules_9",
| |
| "OperationRules_10",
| |
| "OperationRules_11",
| |
| "OperationRules_12",
| |
| "OperationRules_13",
| |
| "MaxPeeps",
| |
| "PeepExhaustionRemoved",
| |
| "PeepAgeAdded",
| |
| "PeepHappinessAdded",
| |
| "PeepHappinessCost",
| |
| "PollutionOutputMode",
| |
| "SourceOfOxygenRange",
| |
| "Resources",
| |
| "Resources_1_Name",
| |
| "Resources_1_Maximum",
| |
| "Resources_1_StorageMode",
| |
| "Resources_1_StartFull",
| |
| "Resources_1_FetchInRange",
| |
| "Resources_1_CanBeShared",
| |
| "Resources_1_CycleThoughResourceSources",
| |
| "Resources_1_GatheringMode",
| |
| "Resources_1_DistributionMode",
| |
| "Resources_1_DeliverInRange",
| |
| "Resources_1_VehicleFetchsAndDelivers",
| |
| "Resources_2_Name",
| |
| "Resources_2_Maximum",
| |
| "Resources_2_StorageMode",
| |
| "Resources_2_StartFull",
| |
| "Resources_2_FetchInRange",
| |
| "Resources_2_CanBeShared",
| |
| "Resources_2_CycleThoughResourceSources",
| |
| "Resources_2_GatheringMode",
| |
| "Resources_2_DistributionMode",
| |
| "Resources_2_DeliverInRange",
| |
| "Resources_2_VehicleFetchsAndDelivers",
| |
| "Resources_3_Name",
| |
| "Resources_3_Maximum",
| |
| "Resources_3_StorageMode",
| |
| "Resources_3_StartFull",
| |
| "Resources_3_FetchInRange",
| |
| "Resources_3_CanBeShared",
| |
| "Resources_3_CycleThoughResourceSources",
| |
| "Resources_3_GatheringMode",
| |
| "Resources_3_DistributionMode",
| |
| "Resources_3_DeliverInRange",
| |
| "Resources_3_VehicleFetchsAndDelivers",
| |
| "Resources_4_Name",
| |
| "Resources_4_Maximum",
| |
| "Resources_4_StorageMode",
| |
| "Resources_4_StartFull",
| |
| "Resources_4_FetchInRange",
| |
| "Resources_4_CanBeShared",
| |
| "Resources_4_CycleThoughResourceSources",
| |
| "Resources_4_GatheringMode",
| |
| "Resources_4_DistributionMode",
| |
| "Resources_4_DeliverInRange",
| |
| "Resources_4_VehicleFetchsAndDelivers",
| |
| "Resources_5_Name",
| |
| "Resources_5_Maximum",
| |
| "Resources_5_StorageMode",
| |
| "Resources_5_StartFull",
| |
| "Resources_5_FetchInRange",
| |
| "Resources_5_CanBeShared",
| |
| "Resources_5_CycleThoughResourceSources",
| |
| "Resources_5_GatheringMode",
| |
| "Resources_5_DistributionMode",
| |
| "Resources_5_DeliverInRange",
| |
| "Resources_5_VehicleFetchsAndDelivers",
| |
| "Resources_6_Name",
| |
| "Resources_6_Maximum",
| |
| "Resources_6_StorageMode",
| |
| "Resources_6_StartFull",
| |
| "Resources_6_FetchInRange",
| |
| "Resources_6_CanBeShared",
| |
| "Resources_6_CycleThoughResourceSources",
| |
| "Resources_6_GatheringMode",
| |
| "Resources_6_DistributionMode",
| |
| "Resources_6_DeliverInRange",
| |
| "Resources_6_VehicleFetchsAndDelivers",
| |
| "Resources_7_Name",
| |
| "Resources_7_Maximum",
| |
| "Resources_7_StorageMode",
| |
| "Resources_7_StartFull",
| |
| "Resources_7_FetchInRange",
| |
| "Resources_7_CanBeShared",
| |
| "Resources_7_CycleThoughResourceSources",
| |
| "Resources_7_GatheringMode",
| |
| "Resources_7_DistributionMode",
| |
| "Resources_7_DeliverInRange",
| |
| "Resources_7_VehicleFetchsAndDelivers",
| |
| "Resources_8_Name",
| |
| "Resources_8_Maximum",
| |
| "Resources_8_StorageMode",
| |
| "Resources_8_StartFull",
| |
| "Resources_8_FetchInRange",
| |
| "Resources_8_CanBeShared",
| |
| "Resources_8_CycleThoughResourceSources",
| |
| "Resources_8_GatheringMode",
| |
| "Resources_8_DistributionMode",
| |
| "Resources_8_DeliverInRange",
| |
| "Resources_8_VehicleFetchsAndDelivers",
| |
| "Resources_9_Name",
| |
| "Resources_9_Maximum",
| |
| "Resources_9_StorageMode",
| |
| "Resources_9_StartFull",
| |
| "Resources_9_FetchInRange",
| |
| "Resources_9_CanBeShared",
| |
| "Resources_9_CycleThoughResourceSources",
| |
| "Resources_9_GatheringMode",
| |
| "Resources_9_DistributionMode",
| |
| "Resources_9_DeliverInRange",
| |
| "Resources_9_VehicleFetchsAndDelivers",
| |
| "ResourceGroups",
| |
| "ResourceGroups_1_Type",
| |
| "ResourceGroups_1_Maximum",
| |
| "ResourceGroups_1_GatheringMode",
| |
| "ResourceGroups_1_DistributionMode",
| |
| "ResourceGroups_1_StartFullResource",
| |
| "ResourceGroups_2_Type",
| |
| "ResourceGroups_2_Maximum",
| |
| "ResourceGroups_2_GatheringMode",
| |
| "ResourceGroups_2_DistributionMode",
| |
| "ResourceGroups_2_StartFullResource",
| |
| "DefinedResourceLists",
| |
| "DefinedResourceLists_2_Name",
| |
| "DefinedResourceLists_2_Maximum",
| |
| "DefinedResourceLists_2_StorageMode",
| |
| "DefinedResourceLists_2_StartFull",
| |
| "DefinedResourceLists_2_FetchInRange",
| |
| "DefinedResourceLists_2_CanBeShared",
| |
| "DefinedResourceLists_2_CycleThoughResourceSources",
| |
| "DefinedResourceLists_2_GatheringMode",
| |
| "DefinedResourceLists_2_DistributionMode",
| |
| "DefinedResourceLists_2_DeliverInRange",
| |
| "DefinedResourceLists_2_VehicleFetchsAndDelivers",
| |
| "DefaultFetchMode",
| |
| "DefaultDeliveryMode",
| |
| "FetchTime",
| |
| "DeliveryTime",
| |
| "TotalStorageMaximum",
| |
| "MaxSeedSlots",
| |
| "BuildingTasks",
| |
| "PlayerSelectableTasks_1",
| |
| "PlayerSelectableTasks_2",
| |
| "PlayerSelectableTasks_3",
| |
| "SourceDefinition",
| |
| "Hotkey",
| |
| "ConstructionMustReplace",
| |
| "AutoUnlock",
| |
| "TechTreeListPreviousExit",
| |
| "TechTreeListEntry",
| |
| "TechTreeLineVerticalOffset",
| |
| "PowerRange",
| |
| "PeepEnergyAdded",
| |
| "PeepEnergyCost",
| |
| },
| |
| }
| |
|
| |
| --- Cargo row from querying Buildings; all values are strings at runtime.
| |
| --- @class BuildingRecord
| |
| --- @field page_name string|nil
| |
| --- @field guid string|nil
| |
| --- @field Name string|nil
| |
| --- @field Category string|nil
| |
| --- @field DisplayNameTerm_en string|nil
| |
| --- @field DisplayNamePluralTerm_en string|nil
| |
| --- @field DescriptionTerm_en string|nil
| |
| --- @field UpgradeTerm string|nil
| |
| --- @field UpgradeTerm_en string|nil
| |
| --- @field IconAddress string|nil
| |
| --- @field PlacementRules_1 string|nil
| |
| --- @field PlacementRules_2 string|nil
| |
| --- @field PlacementRules_3 string|nil
| |
| --- @field PlacementRules_4 string|nil
| |
| --- @field PlacementRules_5 string|nil
| |
| --- @field PlacementRules_6 string|nil
| |
| --- @field AnchorBuildingNames_1 string|nil
| |
| --- @field AnchorBuildingNames_2 string|nil
| |
| --- @field ConstructionResources string|nil
| |
| --- @field ConstructionResources_1_Name string|nil
| |
| --- @field ConstructionResources_1_Amount string|nil
| |
| --- @field ConstructionResources_2_Name string|nil
| |
| --- @field ConstructionResources_2_Amount string|nil
| |
| --- @field ConstructionResources_3_Name string|nil
| |
| --- @field ConstructionResources_3_Amount string|nil
| |
| --- @field ConstructionResources_4_Name string|nil
| |
| --- @field ConstructionResources_4_Amount string|nil
| |
| --- @field ConstructionResources_5_Name string|nil
| |
| --- @field ConstructionResources_5_Amount string|nil
| |
| --- @field ConstructionResources_6_Name string|nil
| |
| --- @field ConstructionResources_6_Amount string|nil
| |
| --- @field SecondaryPrefabAddresses_1 string|nil
| |
| --- @field SecondaryPrefabAddresses_2 string|nil
| |
| --- @field RepairResources_1_Name string|nil
| |
| --- @field RepairResources_1_Amount string|nil
| |
| --- @field RepairResources_2_Name string|nil
| |
| --- @field RepairResources_2_Amount string|nil
| |
| --- @field RepairResources_3_Name string|nil
| |
| --- @field RepairResources_3_Amount string|nil
| |
| --- @field RepairResources_4_Name string|nil
| |
| --- @field RepairResources_4_Amount string|nil
| |
| --- @field RepairResources_5_Name string|nil
| |
| --- @field RepairResources_5_Amount string|nil
| |
| --- @field RepairResources_6_Name string|nil
| |
| --- @field RepairResources_6_Amount string|nil
| |
| --- @field ConstructionTime string|nil
| |
| --- @field ConstructionPeepCount string|nil
| |
| --- @field UnlockMode string|nil
| |
| --- @field UnlockValues string|nil
| |
| --- @field UnlockValues_1 string|nil
| |
| --- @field UnlockValues_2 string|nil
| |
| --- @field UnlockValues_3 string|nil
| |
| --- @field UnlockValues_4 string|nil
| |
| --- @field RequiredRecords_1 string|nil
| |
| --- @field UpgradePointsEarned string|nil
| |
| --- @field LockedInDemo string|nil
| |
| --- @field FootprintIconAddress string|nil
| |
| --- @field TechTreeDisplay string|nil
| |
| --- @field TechTreePrevious string|nil
| |
| --- @field TechTreeRow string|nil
| |
| --- @field AdjacencyBonuses string|nil
| |
| --- @field AdjacencyBonuses_1_GroupName string|nil
| |
| --- @field AdjacencyBonuses_1_Evaluator string|nil
| |
| --- @field AdjacencyBonuses_1_EvaluatorThreshold string|nil
| |
| --- @field AdjacencyBonuses_1_Action string|nil
| |
| --- @field AdjacencyBonuses_1_ActionNames string|nil
| |
| --- @field AdjacencyBonuses_1_ActionNames_1 string|nil
| |
| --- @field AdjacencyBonuses_1_ActionNames_2 string|nil
| |
| --- @field AdjacencyBonuses_1_ActionNames_3 string|nil
| |
| --- @field AdjacencyBonuses_1_ActionNames_4 string|nil
| |
| --- @field AdjacencyBonuses_1_ActionNames_5 string|nil
| |
| --- @field AdjacencyBonuses_1_EvaluatorValue string|nil
| |
| --- @field AdjacencyBonuses_1_ActionValue string|nil
| |
| --- @field AdjacencyBonuses_2_GroupName string|nil
| |
| --- @field AdjacencyBonuses_2_Evaluator string|nil
| |
| --- @field AdjacencyBonuses_2_EvaluatorThreshold string|nil
| |
| --- @field AdjacencyBonuses_2_Action string|nil
| |
| --- @field AdjacencyBonuses_2_ActionNames string|nil
| |
| --- @field AdjacencyBonuses_2_ActionNames_1 string|nil
| |
| --- @field AdjacencyBonuses_2_ActionNames_2 string|nil
| |
| --- @field AdjacencyBonuses_2_ActionNames_3 string|nil
| |
| --- @field AdjacencyBonuses_2_ActionNames_4 string|nil
| |
| --- @field AdjacencyBonuses_2_ActionNames_5 string|nil
| |
| --- @field AdjacencyBonuses_2_EvaluatorValue string|nil
| |
| --- @field AdjacencyBonuses_2_ActionValue string|nil
| |
| --- @field AdjacencyBonuses_3_GroupName string|nil
| |
| --- @field AdjacencyBonuses_3_Evaluator string|nil
| |
| --- @field AdjacencyBonuses_3_EvaluatorThreshold string|nil
| |
| --- @field AdjacencyBonuses_3_Action string|nil
| |
| --- @field AdjacencyBonuses_3_ActionNames string|nil
| |
| --- @field AdjacencyBonuses_3_ActionNames_1 string|nil
| |
| --- @field AdjacencyBonuses_3_ActionNames_2 string|nil
| |
| --- @field AdjacencyBonuses_3_ActionNames_3 string|nil
| |
| --- @field AdjacencyBonuses_3_ActionNames_4 string|nil
| |
| --- @field AdjacencyBonuses_3_EvaluatorValue string|nil
| |
| --- @field AdjacencyBonuses_3_ActionValue string|nil
| |
| --- @field AdjacencyBonuses_4_GroupName string|nil
| |
| --- @field AdjacencyBonuses_4_Evaluator string|nil
| |
| --- @field AdjacencyBonuses_4_EvaluatorThreshold string|nil
| |
| --- @field AdjacencyBonuses_4_Action string|nil
| |
| --- @field AdjacencyBonuses_4_ActionNames string|nil
| |
| --- @field AdjacencyBonuses_4_EvaluatorValue string|nil
| |
| --- @field AdjacencyBonuses_4_ActionValue string|nil
| |
| --- @field OperationRules string|nil
| |
| --- @field OperationRules_1 string|nil
| |
| --- @field OperationRules_2 string|nil
| |
| --- @field OperationRules_3 string|nil
| |
| --- @field OperationRules_4 string|nil
| |
| --- @field OperationRules_5 string|nil
| |
| --- @field OperationRules_6 string|nil
| |
| --- @field OperationRules_7 string|nil
| |
| --- @field OperationRules_8 string|nil
| |
| --- @field OperationRules_9 string|nil
| |
| --- @field OperationRules_10 string|nil
| |
| --- @field OperationRules_11 string|nil
| |
| --- @field OperationRules_12 string|nil
| |
| --- @field OperationRules_13 string|nil
| |
| --- @field MaxPeeps string|nil
| |
| --- @field PeepExhaustionRemoved string|nil
| |
| --- @field PeepAgeAdded string|nil
| |
| --- @field PeepHappinessAdded string|nil
| |
| --- @field PeepHappinessCost string|nil
| |
| --- @field PollutionOutputMode string|nil
| |
| --- @field SourceOfOxygenRange string|nil
| |
| --- @field Resources string|nil
| |
| --- @field Resources_1_Name string|nil
| |
| --- @field Resources_1_Maximum string|nil
| |
| --- @field Resources_1_StorageMode string|nil
| |
| --- @field Resources_1_StartFull string|nil
| |
| --- @field Resources_1_FetchInRange string|nil
| |
| --- @field Resources_1_CanBeShared string|nil
| |
| --- @field Resources_1_CycleThoughResourceSources string|nil
| |
| --- @field Resources_1_GatheringMode string|nil
| |
| --- @field Resources_1_DistributionMode string|nil
| |
| --- @field Resources_1_DeliverInRange string|nil
| |
| --- @field Resources_1_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_2_Name string|nil
| |
| --- @field Resources_2_Maximum string|nil
| |
| --- @field Resources_2_StorageMode string|nil
| |
| --- @field Resources_2_StartFull string|nil
| |
| --- @field Resources_2_FetchInRange string|nil
| |
| --- @field Resources_2_CanBeShared string|nil
| |
| --- @field Resources_2_CycleThoughResourceSources string|nil
| |
| --- @field Resources_2_GatheringMode string|nil
| |
| --- @field Resources_2_DistributionMode string|nil
| |
| --- @field Resources_2_DeliverInRange string|nil
| |
| --- @field Resources_2_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_3_Name string|nil
| |
| --- @field Resources_3_Maximum string|nil
| |
| --- @field Resources_3_StorageMode string|nil
| |
| --- @field Resources_3_StartFull string|nil
| |
| --- @field Resources_3_FetchInRange string|nil
| |
| --- @field Resources_3_CanBeShared string|nil
| |
| --- @field Resources_3_CycleThoughResourceSources string|nil
| |
| --- @field Resources_3_GatheringMode string|nil
| |
| --- @field Resources_3_DistributionMode string|nil
| |
| --- @field Resources_3_DeliverInRange string|nil
| |
| --- @field Resources_3_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_4_Name string|nil
| |
| --- @field Resources_4_Maximum string|nil
| |
| --- @field Resources_4_StorageMode string|nil
| |
| --- @field Resources_4_StartFull string|nil
| |
| --- @field Resources_4_FetchInRange string|nil
| |
| --- @field Resources_4_CanBeShared string|nil
| |
| --- @field Resources_4_CycleThoughResourceSources string|nil
| |
| --- @field Resources_4_GatheringMode string|nil
| |
| --- @field Resources_4_DistributionMode string|nil
| |
| --- @field Resources_4_DeliverInRange string|nil
| |
| --- @field Resources_4_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_5_Name string|nil
| |
| --- @field Resources_5_Maximum string|nil
| |
| --- @field Resources_5_StorageMode string|nil
| |
| --- @field Resources_5_StartFull string|nil
| |
| --- @field Resources_5_FetchInRange string|nil
| |
| --- @field Resources_5_CanBeShared string|nil
| |
| --- @field Resources_5_CycleThoughResourceSources string|nil
| |
| --- @field Resources_5_GatheringMode string|nil
| |
| --- @field Resources_5_DistributionMode string|nil
| |
| --- @field Resources_5_DeliverInRange string|nil
| |
| --- @field Resources_5_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_6_Name string|nil
| |
| --- @field Resources_6_Maximum string|nil
| |
| --- @field Resources_6_StorageMode string|nil
| |
| --- @field Resources_6_StartFull string|nil
| |
| --- @field Resources_6_FetchInRange string|nil
| |
| --- @field Resources_6_CanBeShared string|nil
| |
| --- @field Resources_6_CycleThoughResourceSources string|nil
| |
| --- @field Resources_6_GatheringMode string|nil
| |
| --- @field Resources_6_DistributionMode string|nil
| |
| --- @field Resources_6_DeliverInRange string|nil
| |
| --- @field Resources_6_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_7_Name string|nil
| |
| --- @field Resources_7_Maximum string|nil
| |
| --- @field Resources_7_StorageMode string|nil
| |
| --- @field Resources_7_StartFull string|nil
| |
| --- @field Resources_7_FetchInRange string|nil
| |
| --- @field Resources_7_CanBeShared string|nil
| |
| --- @field Resources_7_CycleThoughResourceSources string|nil
| |
| --- @field Resources_7_GatheringMode string|nil
| |
| --- @field Resources_7_DistributionMode string|nil
| |
| --- @field Resources_7_DeliverInRange string|nil
| |
| --- @field Resources_7_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_8_Name string|nil
| |
| --- @field Resources_8_Maximum string|nil
| |
| --- @field Resources_8_StorageMode string|nil
| |
| --- @field Resources_8_StartFull string|nil
| |
| --- @field Resources_8_FetchInRange string|nil
| |
| --- @field Resources_8_CanBeShared string|nil
| |
| --- @field Resources_8_CycleThoughResourceSources string|nil
| |
| --- @field Resources_8_GatheringMode string|nil
| |
| --- @field Resources_8_DistributionMode string|nil
| |
| --- @field Resources_8_DeliverInRange string|nil
| |
| --- @field Resources_8_VehicleFetchsAndDelivers string|nil
| |
| --- @field Resources_9_Name string|nil
| |
| --- @field Resources_9_Maximum string|nil
| |
| --- @field Resources_9_StorageMode string|nil
| |
| --- @field Resources_9_StartFull string|nil
| |
| --- @field Resources_9_FetchInRange string|nil
| |
| --- @field Resources_9_CanBeShared string|nil
| |
| --- @field Resources_9_CycleThoughResourceSources string|nil
| |
| --- @field Resources_9_GatheringMode string|nil
| |
| --- @field Resources_9_DistributionMode string|nil
| |
| --- @field Resources_9_DeliverInRange string|nil
| |
| --- @field Resources_9_VehicleFetchsAndDelivers string|nil
| |
| --- @field ResourceGroups string|nil
| |
| --- @field ResourceGroups_1_Type string|nil
| |
| --- @field ResourceGroups_1_Maximum string|nil
| |
| --- @field ResourceGroups_1_GatheringMode string|nil
| |
| --- @field ResourceGroups_1_DistributionMode string|nil
| |
| --- @field ResourceGroups_1_StartFullResource string|nil
| |
| --- @field ResourceGroups_2_Type string|nil
| |
| --- @field ResourceGroups_2_Maximum string|nil
| |
| --- @field ResourceGroups_2_GatheringMode string|nil
| |
| --- @field ResourceGroups_2_DistributionMode string|nil
| |
| --- @field ResourceGroups_2_StartFullResource string|nil
| |
| --- @field DefinedResourceLists string|nil
| |
| --- @field DefinedResourceLists_2_Name string|nil
| |
| --- @field DefinedResourceLists_2_Maximum string|nil
| |
| --- @field DefinedResourceLists_2_StorageMode string|nil
| |
| --- @field DefinedResourceLists_2_StartFull string|nil
| |
| --- @field DefinedResourceLists_2_FetchInRange string|nil
| |
| --- @field DefinedResourceLists_2_CanBeShared string|nil
| |
| --- @field DefinedResourceLists_2_CycleThoughResourceSources string|nil
| |
| --- @field DefinedResourceLists_2_GatheringMode string|nil
| |
| --- @field DefinedResourceLists_2_DistributionMode string|nil
| |
| --- @field DefinedResourceLists_2_DeliverInRange string|nil
| |
| --- @field DefinedResourceLists_2_VehicleFetchsAndDelivers string|nil
| |
| --- @field DefaultFetchMode string|nil
| |
| --- @field DefaultDeliveryMode string|nil
| |
| --- @field FetchTime string|nil
| |
| --- @field DeliveryTime string|nil
| |
| --- @field TotalStorageMaximum string|nil
| |
| --- @field MaxSeedSlots string|nil
| |
| --- @field BuildingTasks string|nil
| |
| --- @field PlayerSelectableTasks_1 string|nil
| |
| --- @field PlayerSelectableTasks_2 string|nil
| |
| --- @field PlayerSelectableTasks_3 string|nil
| |
| --- @field SourceDefinition string|nil
| |
| --- @field Hotkey string|nil
| |
| --- @field ConstructionMustReplace string|nil
| |
| --- @field AutoUnlock string|nil
| |
| --- @field TechTreeListPreviousExit string|nil
| |
| --- @field TechTreeListEntry string|nil
| |
| --- @field TechTreeLineVerticalOffset string|nil
| |
| --- @field PowerRange string|nil
| |
| --- @field PeepEnergyAdded string|nil
| |
| --- @field PeepEnergyCost string|nil
| |
|
| |
| --- Returns one Buildings cargo row keyed by field name, or nil if Cargo is
| |
| --- unavailable or no row matches `page_name`.
| |
| --- @param building_name string the in-game name of the building to fetch
| |
| --- @return BuildingRecord|nil
| |
| local function fetch_building(building_name)
| |
| local cargo = mw.ext.cargo
| |
| if not cargo then return nil end
| |
| local result = cargo.query(
| |
| QUERY.TABLE,
| |
| table.concat(QUERY.FIELDS, ","), {
| |
| where = QUERY.WHERE_FIELD .. '="' .. building_name .. '"',
| |
| limit = 1,
| |
| })
| |
| if not result or #result == 0 then return nil end
| |
| return result[1]
| |
| end
| |
|
| |
|
| |
|
| |
| ---@alias ConstructionPair { name: string, amount: string }
| |
|
| |
| --- Returns a table of construction resources for the given building.
| |
| --- @param building BuildingRecord
| |
| --- @return ConstructionPair[]
| |
| local function get_construction_resources(building)
| |
| local resources = {}
| |
| for i = 1, 6 do
| |
| local name = building[string.format("ConstructionResources_%d_Name", i)]
| |
| local amount = tonumber(building[string.format("ConstructionResources_%d_Amount", i)])
| |
| if name and amount then
| |
| table.insert(resources, { name = name, amount = amount })
| |
| end
| |
| end
| |
| return resources
| |
| end
| |
|
| |
| --#endregion
| |
|
| |
|
|
| |
|
| | --#region html building helper functions |
|
| |
|
| --#region html building | | ---@alias HtmlNode table |
|
| |
|
| local INFOBOX_CLASS = "bts-infobox-building" | | local INFOBOX_CLASS = "bts-infobox-building" |
| Line 596: |
Line 16: |
| local CONSTRUCTION_CLASS = INFOBOX_CLASS .. "-construction" | | local CONSTRUCTION_CLASS = INFOBOX_CLASS .. "-construction" |
| local CONSTRUCTION_TABLE_CLASS = CONSTRUCTION_CLASS .. "-table" | | local CONSTRUCTION_TABLE_CLASS = CONSTRUCTION_CLASS .. "-table" |
| | local TASKS_CLASS = INFOBOX_CLASS .. "-tasks" |
|
| |
|
| --- @alias HtmlNode table | | --- Adds the header of the infobox to the provided html node. |
| | | ---@param div HtmlNode enclosing infobox div |
| --- Builds the header of the infobox.
| | ---@param building BuildingRecord |
| --- @param html HtmlNode enclosing infobox div | | local function build_header(div, building) |
| --- @param building BuildingRecord | | local header = div:tag("div"):addClass(HEADER_CLASS) |
| --- @return HtmlNode header
| | header:tag("h2"):wikitext(building.display_name):done() |
| local function build_header(html, building) | | header:tag("h3"):wikitext(building.category):done() |
| local header = html:tag("div"):addClass(HEADER_CLASS) | |
| header:tag("h2"):wikitext(building.DisplayNameTerm_en):done() | |
| header:tag("h3"):wikitext(building.Category):done() | |
| return header
| |
| end | | end |
|
| |
|
| --- Adds the building's description to the infobox. | | --- Adds the building's description to the provided html node. |
| --- @param html HtmlNode enclosing infobox div | | ---@param div HtmlNode enclosing infobox div |
| --- @param building BuildingRecord | | ---@param building BuildingRecord |
| --- @return HtmlNode description
| | local function build_description(div, building) |
| local function build_description(html, building) | | local description = div:tag("div"):addClass(DESCRIPTION_CLASS) |
| local description = html:tag("div"):addClass(DESCRIPTION_CLASS) | | building.description = building.description:gsub("<hb>", ""):gsub("</hb>", "") |
| --// TODO: need to convert custom formatting <hb> tags into links or something | | description:tag("p"):wikitext(building.description):done() |
| description:tag("p"):wikitext(building.DescriptionTerm_en):done() | |
| return description | | return description |
| end | | end |
|
| |
|
| local function add_construction_resource(tr, pair) | | --- Adds the construction resources to the provided html table row. |
| local td = tr:tag("td"):wikitext(pair.name)
| | ---@param tr HtmlNode table row |
| return td
| | ---@param building BuildingRecord |
| end
| | local function add_construction_resource_row(tr, building) |
| | | for _, pair in ipairs(building.construction_resources) do |
| local function add_construction_amount(tr, pair)
| | if pair.name and pair.name ~= "" and pair.amount and pair.amount ~= "" then |
| local td = tr:tag("td"):wikitext(pair.amount)
| | tr:tag("td"):wikitext(pair.name):done() |
| return td | | end |
| | end |
| end | | end |
|
| |
|
| --- Lays out the construction resources. | | --- Adds the construction amount to the provided html table row. |
| --- @param html HtmlNode enclosing infobox div | | --- @param tr HtmlNode table row |
| --- @param building BuildingRecord | | --- @param building BuildingRecord |
| --- @return HtmlNode section
| | local function add_construction_amount(tr, building) |
| local function build_construction(html, building) | | for _, pair in ipairs(building.construction_resources) do |
| local table = html:tag("div"):addClass(CONSTRUCTION_CLASS):tag("table"):addClass(CONSTRUCTION_TABLE_CLASS)
| |
| local tr_names = table:tag("tr")
| |
| local resources = get_construction_resources(building)
| |
| for _, pair in ipairs(resources) do | |
| if pair.name and pair.name ~= "" and pair.amount and pair.amount ~= "" then | | if pair.name and pair.name ~= "" and pair.amount and pair.amount ~= "" then |
| add_construction_resource(tr_names, pair) | | tr:tag("td"):wikitext(pair.amount):done() |
| end | | end |
| end | | end |
| | end |
| | |
| | --- Lays out the construction resources in the provided html node. |
| | ---@param div HtmlNode enclosing infobox div |
| | ---@param building BuildingRecord |
| | local function build_construction(div, building) |
| | if not building.construction_resources or building.construction_resources == {} then return end |
| | local table = div:tag("div"):addClass(CONSTRUCTION_CLASS):tag("table"):addClass(CONSTRUCTION_TABLE_CLASS) |
| | local tr_names = table:tag("tr") |
| | add_construction_resource_row(tr_names, building) |
| tr_names:done() | | tr_names:done() |
| local tr_amounts = table:tag("tr") | | local tr_amounts = table:tag("tr") |
| for _, pair in ipairs(resources) do | | add_construction_amount(tr_amounts, building) |
| if pair.name and pair.name ~= "" and pair.amount and pair.amount ~= "" then
| |
| add_construction_amount(tr_amounts, pair)
| |
| end
| |
| end
| |
| tr_amounts:done() | | tr_amounts:done() |
| return table | | return table |
| | end |
| | |
| | --- Lays out the building's tasks in the provided html node. |
| | ---@param div HtmlNode enclosing infobox div |
| | ---@param building BuildingRecord |
| | local function build_tasks(div, building) |
| | if not building.tasks or building.tasks == {} then return end |
| | local section = div:tag("div"):addClass(TASKS_CLASS) |
| end | | end |
|
| |
|
| --- Builds the infobox wikitext and html for the given building. | | --- Builds the infobox wikitext and html for the given building. |
| --- @param building BuildingRecord | | ---@param building BuildingRecord |
| --- @return string wikitext | | ---@return string wikitext |
| local function build_infobox(building) | | local function build_infobox(building) |
| ---@type HtmlNode | | ---@type HtmlNode |
| Line 665: |
Line 92: |
| build_description(html, building) | | build_description(html, building) |
| build_construction(html, building) | | build_construction(html, building) |
| | build_tasks(html, building) |
| return tostring(html) | | return tostring(html) |
| end | | end |
| Line 674: |
Line 102: |
| --- `#invoke` entry point. Reads `page_name` from invoke args (not the parent | | --- `#invoke` entry point. Reads `page_name` from invoke args (not the parent |
| --- template); falls back to the current page title. | | --- template); falls back to the current page title. |
| --- @param frame table Scribunto frame from `#invoke`. | | ---@param frame table Scribunto frame from `#invoke`. |
| --- @return string|nil Infobox wikitext, or nil if no cargo row exists. | | ---@return string|nil Infobox wikitext, or nil if no cargo row exists. |
| function p.render(frame) | | function p.render(frame) |
| local args = frame.args or {} | | local args = frame.args or {} |
| ---@type string | | ---@type string |
| local name = args[1] or args.page_name or mw.title.getCurrentTitle().fullText | | local name = args[1] or args.page_name or mw.title.getCurrentTitle().fullText |
| local building = fetch_building(name) | | local building = BuildingDataModule.get_building(name) |
| if not building then return nil end | | if not building then return nil end |
| local wikitext = build_infobox(building) | | local wikitext = build_infobox(building) |