Creating a Tech Tree

As I am finishing up my movement system, I noticed that what would be best to continue with is the ability to create games/cities. And that would require a tech tree (because cities will give science, a quantifiable resource used in the tech tree).

Now, I have some ideas when it comes to execution of the tech tree. The current thing I have come up with is the following:

local techTree = {{requires: none, name: "duckies", cost: 50, image: "insert duck picture here", boostmethod: "get in a pond with a yellow bird"}}

But this could get messy very quickly when there is a hundred technologies, or two hundred. So, I was just wondering:

Is there anyway that the table could be organized or neater. I feel like nested tables would be best in this situation, but I honestly feel that that is messy and just wouldn’t work out. Like maybe something like this:

local techTree = {
    technology                 technology
    technology   technology
}

Thanks!

You can always try a multi-dimensional array:

local techTree = {
    ["BasicTechnology"] = {
        ["Cost"] = 50,
        ["Image"] = "quackaroo",
        ["BoostMethod"] = "questionable boost method but ok",
        ["Branches"] = {
            ["AdvancedTechnology"] = {
                -- fill...
                ["Branches"] = {...}
            }
        }
    }
}
1 Like