LeeS
Imperator
lua code, needs to be specified as VFS=false and needs a "InGameUIAddin" in the "Content" tab of Modbuddy. The modinfo file should show import="0" for the file, and there should be an "entrypoint" such as this:
Actual lua code required should be:
This will, of course, only work in the player's capital city. I have tested and it is not necessary to specify the Great Work type for GetNumGreatWorks() when you want the total of all great works types. I have not tested whether you can specify the type of Great Work to only "count" the great works of a specific type.
It will be necessary for you to change "CIVILIZATION_YOUR_CIV_NAME_GOES_HERE" to the correct designation for your civilization as you named it in the XML
---------------------------------------------------------------------------------------------------------------------------------
XML for the building:
---------------------------------------------------------------------------------------------------------------------------------
If you wanted to make the lua script run for any/all cities a player has (and not just the capital), the lua script would be changed to:
There would be no need to change the XML for the building.
---------------------------------------------------------------------------------------------------------------------------------
@Salamandre
Lua scripts such as these create within themselves all the conditions necessary for placing a dummy building into a city, so it is not necessary (and is usually counter-productive) to make the building dependant on a tech, policy, or other exclusion/dependancy as part of the XML of the dummy building.
Machiavelli's PGB tables were meant by Machiavelli to be used as templates to help shorten the work needed by a mod-maker when the mod-maker wants adopting certain policies to grant certain buildings -- but in any other case Machiavelli's PGB isn't of any real use. Instead we as mod-makers just create in XML the dummy-building we need, and make our lua scripts reference the XML-name of the dummy building, as I did in this line of code:
Code:
<EntryPoints>
<EntryPoint type="InGameUIAddin" file="LUA/YourLuaFileName.lua">
<Name>CityStrategicResources</Name>
<Description>CityStrategicResources</Description>
</EntryPoint>
</EntryPoints>
Code:
local iBuildingCapitalStrategicID = GameInfoTypes.BUILDING_RESOURCES_DUMMY
local civilisationID = GameInfoTypes.CIVILIZATION_YOUR_CIV_NAME_GOES_HERE
function CapitalCityStrategicsForGreatWorks(playerID)
local pPlayer = Players[playerID]
if pPlayer:GetCivilizationType() == civilisationID then
local pCapitalCity = pPlayer:GetCapitalCity()
pCapitalCity:SetNumRealBuilding(iBuildingCapitalStrategicID, pCapitalCity:GetNumGreatWorks())
end
end
GameEvents.PlayerDoTurn.Add(CapitalCityStrategicsForGreatWorks)
It will be necessary for you to change "CIVILIZATION_YOUR_CIV_NAME_GOES_HERE" to the correct designation for your civilization as you named it in the XML
---------------------------------------------------------------------------------------------------------------------------------
XML for the building:
- Needs (obviously) to be placed in an XML file within the mod
- The XML file needs an "<OnModActivated>" -- "<UpdateDatabase>" in the ModBuddy "Actions" tab
Spoiler building definition in XML :
Code:
<GameData>
<Buildings>
<Row>
<Type>BUILDING_RESOURCES_DUMMY</Type>
<BuildingClass>BUILDINGCLASS_RESOURCES_DUMMY</BuildingClass>
<Cost>-1</Cost>
<FaithCost>-1</FaithCost>
<PrereqTech>NULL</PrereqTech>
<GreatWorkCount>-1</GreatWorkCount>
<ArtDefineTag>NONE</ArtDefineTag>
<MinAreaSize>-1</MinAreaSize>
<NeverCapture>true</NeverCapture>
<HurryCostModifier>-1</HurryCostModifier>
<IconAtlas>BW_ATLAS_1</IconAtlas>
<PortraitIndex>19</PortraitIndex>
<Description>TXT_KEY_BUILDING_RESOURCES_DUMMY</Description>
</Row>
</Buildings>
<BuildingClasses>
<Row>
<Type>BUILDINGCLASS_RESOURCES_DUMMY</Type>
<DefaultBuilding>BUILDING_RESOURCES_DUMMY</DefaultBuilding>
<Description>TXT_KEY_BUILDING_RESOURCES_DUMMY</Description>
<NoLimit>true</NoLimit>
</Row>
</BuildingClasses>
<Building_ResourceQuantity>
<Row>
<BuildingType>BUILDING_RESOURCES_DUMMY</BuildingType>
<ResourceType>RESOURCE_ALUMINUM</ResourceType>
<Quantity>1</Quantity>
</Row>
<Row>
<BuildingType>BUILDING_RESOURCES_DUMMY</BuildingType>
<ResourceType>RESOURCE_COAL</ResourceType>
<Quantity>1</Quantity>
</Row>
<Row>
<BuildingType>BUILDING_RESOURCES_DUMMY</BuildingType>
<ResourceType>RESOURCE_URANIUM</ResourceType>
<Quantity>1</Quantity>
</Row>
<Row>
<BuildingType>BUILDING_RESOURCES_DUMMY</BuildingType>
<ResourceType>RESOURCE_IRON</ResourceType>
<Quantity>1</Quantity>
</Row>
<Row>
<BuildingType>BUILDING_RESOURCES_DUMMY</BuildingType>
<ResourceType>RESOURCE_HORSE</ResourceType>
<Quantity>1</Quantity>
</Row>
<Row>
<BuildingType>BUILDING_RESOURCES_DUMMY</BuildingType>
<ResourceType>RESOURCE_OIL</ResourceType>
<Quantity>1</Quantity>
</Row>
</Building_ResourceQuantity>
<Language_en_US>
<Row Tag="TXT_KEY_BUILDING_RESOURCES_DUMMY">
<Text>Strategic Resources</Text>
</Row>
</Language_en_US>
</GameData>
If you wanted to make the lua script run for any/all cities a player has (and not just the capital), the lua script would be changed to:
Code:
local iBuildingCityStrategicID = GameInfoTypes.BUILDING_RESOURCES_DUMMY
local civilisationID = GameInfoTypes.CIVILIZATION_YOUR_CIV_NAME_GOES_HERE
function CityStrategicsForGreatWorks(playerID)
local pPlayer = Players[playerID]
if pPlayer:GetCivilizationType() == civilisationID then
for pCity in pPlayer:Cities() do
pCity:SetNumRealBuilding(iBuildingCityStrategicID, pCity:GetNumGreatWorks())
end
end
end
GameEvents.PlayerDoTurn.Add(CityStrategicsForGreatWorks)
---------------------------------------------------------------------------------------------------------------------------------
@Salamandre
Lua scripts such as these create within themselves all the conditions necessary for placing a dummy building into a city, so it is not necessary (and is usually counter-productive) to make the building dependant on a tech, policy, or other exclusion/dependancy as part of the XML of the dummy building.
Machiavelli's PGB tables were meant by Machiavelli to be used as templates to help shorten the work needed by a mod-maker when the mod-maker wants adopting certain policies to grant certain buildings -- but in any other case Machiavelli's PGB isn't of any real use. Instead we as mod-makers just create in XML the dummy-building we need, and make our lua scripts reference the XML-name of the dummy building, as I did in this line of code:
Code:
local iBuildingCapitalStrategicID = GameInfoTypes.BUILDING_RESOURCES_DUMMY