[BNW] How can I create UB that adds extra specialist to every building with specialist slot?


Jul 2, 2022
I want to make my UB to have function that creates extra one specialist slots to every building with specialist slots when constructed.

I guess I will need help from Lua but I haven't learned long enough to figure that out. I tried to refer similar mods but their codes are too complicated for me to understand at the moment. Could anyone teach me the code I need in order to perform that function or things I can refer to?

I thought of a way

First, I will make copies of building that has specialist slot and add specialist number
Second, I will use Building_PrereqBuildingClasses and set my UB so it can be constructed after my UB is built. Then, use ReplacementBulidingClass to replace the original buildings.
Third, With Lua I will code when my UB is constructed, make orginal buildings obsolete and replace them with new buildings with extra specialist slot

I think I can do first and second step on my own using XML.. but the third part I have no idea how to make it possible.
I possibly can try this ↓

local SPBTypes = {}
SPBTypes[1] = GameInfoTypes["BUILDING_WINDMILL"]
SPBTypes[2] = GameInfoTypes["BUILDING_FACTORY"]
localSPATypes = {}
>function ReplacingBuilding(asty)
>if Civilization Type is ----
>for cities of indicated Civilization do
>if building has UB
(>and if city has religion that civilization has created) <<(if possible, I want to add this trait..)
>>Get buildings from the city that has specialist slot/matches with the building from SPBTypes
>>If it has assigned specialist slot then unassign them
>>replace the building into one of the buildings from SPATypes that matches the number(ex[1]->[1], [2]->[2])

Would this work?
Please help me with making that function ReplacingBuilding (asty)
for I am not pretty good with handling Lua script..
Last edited:
I realized my request is actually impossible and absurd after trying many ways.. It seems xml can only create upto 16 buildings per civilization..because including dummy buildings, mod caused problems every time I tried to insert 17th specialist added version building. Too much is never too good. I learnt my lesson. I should plan other function... but if you do have any solution similar to this, please share with me!>_<
Top Bottom