Defining Units

A tribe can have the following types of units: buildings (militarysites, partially_finished, productionsites, trainingsites and warehouses; headquarters are a special case of warehouse), immovables, workers, wares, and a ship.

The definitions for the tribes’ units are located in the subdirectories of data/tribes. Each subdirectory needs to have a register.lua, an init.lua and a helptexts.lua file.

  • register.lua will inform the engine about the existence of units and their attributes if they have any. This is needed for registering the objects before they are loaded.

  • init.lua will load the units if they are used in the game

  • helptexts.lua will provide the information used by the in-game help (‘Tribal Encyclopedia’) and by our website’s online Encyclopedia.

Example for init.lua:

push_textdomain("tribes")

descriptions:new_immovable_type {
   name = "berry_bush_blueberry_tiny",
   ...
}

descriptions:new_immovable_type {
   name = "berry_bush_blueberry_small",
   ...
}

descriptions:new_immovable_type {
   name = "berry_bush_blueberry_medium",
   ...
}

descriptions:new_immovable_type {
   name = "berry_bush_blueberry_ripe",
   ...
}

pop_textdomain()

The matching register.lua would look like this:

return {
   berry_bush_blueberry_tiny = { "seed_berrybush" },
   berry_bush_blueberry_small = {},
   berry_bush_blueberry_medium = { "flowering" },
   berry_bush_blueberry_ripe = { "ripe_bush" },
}

Note

If you are defining multiple unit types that can be enhanced or that will transform into each other in the same init.lua, the enhanced/transformed type needs to be listed first. Also, berry_bush_blueberry_small in this example has no attributes, so its attribute table is empty.

Available unit types: