How Task Queues Work

The Taskqueues are defined in a lua table named ‘taskqueues’ in taskqueues.lua. They take the form of “unittype” = tableOfTasks, where the table of tasks is a lua array of strings, aka unit type names to build, starting in order from the beginning to the end. Such a unit name may be corsolar ( rather than the human readable version Core Solar )

If however the taskqueue behaviour finds a function not a table, it will call that function, and expect a table in return. This way you can implement custom logic, and return different task queues each time, depending on who what or when it is called.

This is also true of the tasks themselves. Shard expects a unitname as a string, e.g. “corsolar” for a core solar plant unit, however if it finds a function, it will call the function, expecting a string as a return value.

I would suggest looking at evolutionRTS’ shard support, and especially using the way the taskqueues.lua is formatted there, rather than how its formatted in conflict terra, as it is much more flexible and easier to read/understand.

This was based on a post originally made on the spring forums, with some additions