1. You have a number of variables that are related to the same item and you are using a variable naming convention to group sets of those variables together, this can quickly lead to confusion & mistakes.
Another method you can use to group related variables together is to use an Javascript Generic Object, the following basic example show what such an object could look like. It includes a <<set>> macro defining the values of the object and its properties, some <<print>> related macros to show how to output the values of the object's properties, and finally how to compare two object properties using an <<if>> macro.
<<set $building to {
"max-workers": 2,
"cost": 100,
"build-days": 10,
"days-elapsed": 0
}>>
Maximum Workers allowed: <<= $building["max-workers"]>>
Amount of money needed to build: <<= $building["cost"]>>
Number of days needed to build it: <<= $building["build-days"]>>
Number of construction days that have passed: <<= $building["days-elapsed"]>>
Has construction of the building finished? \
<<if $building["days-elapsed"] is $building["build-days"]>>\
Yes\
<<else>>\
No\
<</if>>
... obviously you would use property names that made sense to your story project.
2. You are also using numbers in your variable names to distinguish one set of related variables from another, and this can also to confusion & mistakes.
Another way to do this is to use a collection object type (like Array, Map, Generic Object, etc) to group your "building" objects together.
2a. The following basic example shows how to initially define an Array to hold two instances of the "building" object, how to later add a third "building" object to that Array, and how to reference the properties of each of the "building" objects with the array.
<<set $buildings to [
{
"max-workers": 2,
"cost": 100,
"build-days": 10,
"days-elapsed": 0
},
{
"max-workers": 3,
"cost": 80,
"build-days": 6,
"days-elapsed": 2
}
]>>
<<set $buildings.push({
"max-workers": 1,
"cost": 10,
"build-days": 2,
"days-elapsed": 1
})>>
Building 1 - Maximum Workers allowed: <<= $buildings[0]["max-workers"]>>
Building 2 - Maximum Workers allowed: <<= $buildings[1]["max-workers"]>>
Building 3 - Maximum Workers allowed: <<= $buildings[2]["max-workers"]>>
... you will notice that the first element of the Array is referenced using an index of 0 (zero) and that the second element is referenced using an index of 1 (one), this is because Javascript Arrays are zero-based.
2b. The following example is similar to 2a except it is using an Generic Object instead of an Array to contain the different "building" objects,
<<set $buildings to {
"first": {
"max-workers": 2,
"cost": 100,
"build-days": 10,
"days-elapsed": 0
},
"second": {
"max-workers": 3,
"cost": 80,
"build-days": 6,
"days-elapsed": 2
}
}>>
<<set $buildings["third"] to {
"max-workers": 1,
"cost": 10,
"build-days": 2,
"days-elapsed": 1
}>>
First Building - Maximum Workers: <<= $buildings["first"]["max-workers"]>>
Second Building - Maximum Workers: <<= $buildings["second"]["max-workers"]>>
Third Building - Maximum Workers: <<= $buildings["third"]["max-workers"]>>
WARNING: The above examples are only very basic overviews of on how to use the Generic Object and Array data types to achieve what you want.