-- BoundlessPlainsToShare
-- Author: Neirai
-- DateCreated: 11/11/2013 7:42:39 AM
--------------------------------------------------------------
-- When I enter the classical era, find me up to three possible Boundless Cities. Give them AUCOLONIALSETTLEMENT.
-- Whenever I found a city, check to see if I have enough Boundless Cities. If not, give the correct number of buildings to them, based on era.
-- Whenever I enter a new Boundless era, find me all my Boundless Cities and put the right building into them.
-- this could be messy.
function EraChangedForAussies(pEra, pPlayer)
print(Players[pPlayer]:GetCivilizationType())
print(GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA)
if Players[pPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then
print("We just changed an era, mate!")
print(pEra)
local BoundlessCount = 0
if pEra == 1 then -- this should be the first time this ever runs successfully
for pCity in Players[pPlayer]:Cities() do
if pCity:IsCoastal(1) then
print("This is a Coastal City, mate!")
print("BoundlessCount is")
print(BoundlessCount)
if BoundlessCount < 3 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"], 1)
BoundlessCount = BoundlessCount + 1
else
break
end
end
end
elseif pEra == 3 then -- there should be established Boundless Cities, and it's just a matter of finding them!
for pCity in Players[pPlayer]:Cities() do
if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUMININGTOWN"], 1)
end
end
elseif pEra == 5 then -- there should be established Boundless Cities, and it's just a matter of finding them!
for pCity in Players[pPlayer]:Cities() do
if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUREFUGEEPROGRAMME"], 1)
end
end
elseif pEra == 7 then -- there should be established Boundless Cities, and it's just a matter of finding them!
for pCity in Players[pPlayer]:Cities() do
if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUTOURISMDEPARTMENT"], 1)
end
end
end
end
end
Events.SerialEventEraChanged.Add(EraChangedForAussies)
function AussiesFoundACity(uWhere, pPlayer, pCityID)
if Players[pPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then
print("We founded a city, mate!")
local pPlayerCity = Players[pPlayer]:GetCityByID(pCityID)
local pEra = Players[pPlayer]:GetCurrentEra()
if pEra > 0 then -- if we are past special Eras
if pPlayerCity:IsCoastal(1) then -- I only care to run this if this is true.
local pFoundedPlot = pPlayerCity:Plot()
local BoundlessCities = 0
print("This is a Coastal City")
for pCity in Players[pPlayer]:Cities() do
if pCity:Plot() ~= pFoundedPlot then -- make sure this isn't the same city.
if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then
BoundlessCities = BoundlessCities + 1
if BoundlessCities == 3 then
break
end
end
end
end
print("The number of BoundlessCities:")
print(BoundlessCities)
if BoundlessCities < 3 then
pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"], 1)
end
if pEra > 2 then
pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUMININGTOWN"], 1)
end
if pEra > 4 then
pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUREFUGEEPROGRAMME"], 1)
end
if pEra > 6 then
pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUTOURISMDEPARTMENT"], 1)
end
else
print("This is not a Coastal City!")
end
end
end
end
Events.SerialEventCityCreated.Add(AussiesFoundACity)
Looking for a bit of advice on this LUA script. I've been looking through it and trying to find out why it's not working, and I can't seem to find out what's wrong.
Posting this here will help.
What this is supposed to do is put special buildings in Only the first three cities that are on a Coast. It may also need to only count the cities that Australia founds, although I haven't built that in yet. But that should be easy.
Apparently it's putting the buildings in every single coastal city.
Anyhow, give it a whirl, and bask in how bad of a LUA writer I am.
Code:-- BoundlessPlainsToShare -- Author: Neirai -- DateCreated: 11/11/2013 7:42:39 AM -------------------------------------------------------------- -- When I enter the classical era, find me up to three possible Boundless Cities. Give them AUCOLONIALSETTLEMENT. -- Whenever I found a city, check to see if I have enough Boundless Cities. If not, give the correct number of buildings to them, based on era. -- Whenever I enter a new Boundless era, find me all my Boundless Cities and put the right building into them. -- this could be messy. function EraChangedForAussies(pEra, pPlayer) print(Players[pPlayer]:GetCivilizationType()) print(GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA) if Players[pPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then print("We just changed an era, mate!") print(pEra) local BoundlessCount = 0 if pEra == 1 then -- this should be the first time this ever runs successfully for pCity in Players[pPlayer]:Cities() do if pCity:IsCoastal(1) then print("This is a Coastal City, mate!") print("BoundlessCount is") print(BoundlessCount) if BoundlessCount < 3 then pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"], 1) BoundlessCount = BoundlessCount + 1 else break end end end elseif pEra == 3 then -- there should be established Boundless Cities, and it's just a matter of finding them! for pCity in Players[pPlayer]:Cities() do if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUMININGTOWN"], 1) end end elseif pEra == 5 then -- there should be established Boundless Cities, and it's just a matter of finding them! for pCity in Players[pPlayer]:Cities() do if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUREFUGEEPROGRAMME"], 1) end end elseif pEra == 7 then -- there should be established Boundless Cities, and it's just a matter of finding them! for pCity in Players[pPlayer]:Cities() do if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUTOURISMDEPARTMENT"], 1) end end end end end Events.SerialEventEraChanged.Add(EraChangedForAussies) function AussiesFoundACity(uWhere, pPlayer, pCityID) if Players[pPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then print("We founded a city, mate!") local pPlayerCity = Players[pPlayer]:GetCityByID(pCityID) local pEra = Players[pPlayer]:GetCurrentEra() if pEra > 0 then -- if we are past special Eras if pPlayerCity:IsCoastal(1) then -- I only care to run this if this is true. local pFoundedPlot = pPlayerCity:Plot() local BoundlessCities = 0 print("This is a Coastal City") for pCity in Players[pPlayer]:Cities() do if pCity:Plot() ~= pFoundedPlot then -- make sure this isn't the same city. if pCity:GetNumBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"]) > 0 then BoundlessCities = BoundlessCities + 1 if BoundlessCities == 3 then break end end end end print("The number of BoundlessCities:") print(BoundlessCities) if BoundlessCities < 3 then pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"], 1) end if pEra > 2 then pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUMININGTOWN"], 1) end if pEra > 4 then pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUREFUGEEPROGRAMME"], 1) end if pEra > 6 then pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUTOURISMDEPARTMENT"], 1) end else print("This is not a Coastal City!") end end end end Events.SerialEventCityCreated.Add(AussiesFoundACity)
print("BoundlessCount is " .. BoundlessCount)
[s]local[/s] BoundlessCities = 0
SomeTableVariable = {} [COLOR="Green"]//It has to be defined[/COLOR]
SomeTableVariable[sth] = sth2;
SomeTableVariable[sth3] = {} [COLOR="green"]//It is table in table, so SomeTableVariabl[sth3][sth4] = sth 5;[/COLOR]
-- BoundlessPlainsToShare
-- Author: Neirai
-- DateCreated: 11/11/2013 7:42:39 AM
--------------------------------------------------------------
-- When I enter the classical era, find me up to three possible Boundless Cities. Give them AUCOLONIALSETTLEMENT.
-- Whenever I found a city, check to see if I have enough Boundless Cities. If not, give the correct number of buildings to them, based on era.
-- Whenever I enter a new Boundless era, find me all my Boundless Cities and put the right building into them.
-- this could be messy.
AustralianBoundlessCity1 = nil
AustralianBoundlessCity2 = nil
AustralianBoundlessCity3 = nil
AustralianPlayerEraNumber = 0
Events.SerialEventDawnOfManHide.Add(function(civID)
print("The Civ ID is " .. civID)
print("Aussie Civ ID is " .. GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA)
if civID:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then
local pEra = Players[pPlayer]:GetCurrentEra()
AustralianPlayerEraNumber = pEra
end
end)
function AussieTurnChangedIsEraTheSame(pPlayer)
if Players[pPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then
local pEra = Players[pPlayer]:GetCurrentEra()
if pEra > AustralianPlayerEraNumber then
EraChangedforAussies(pEra, pPlayer)
AustralianPlayerEraNumber = pEra
end
end
end
GameEvents.PlayerDoTurn.Add(AussieTurnChangedIsEraTheSame)
function AussiesFoundACity(uWhere, pPlayer, pCityID)
if Players[pPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then
print("We founded a city, mate!")
local pPlayerCity = Players[pPlayer]:GetCityByID(pCityID)
--no longer care about Eras when you do this. This is ONLY about the cities' locations, mate!
if (pPlayerCity:IsCoastal(1) == true) and (pPlayerCity:GetOriginalOwner() == Players[pPlayer]) then -- I only care to run this if this is true.
--local pFoundedPlot = pPlayerCity:Plot()
print("This is a Coastal City founded by Australia")
if AustralianBoundlessCity1 == nil then
AustralianBoundlessCity1 = pPlayerCity
print("Boundless City #1 is " .. AustralianBoundlessCity1:GetName())
elseif AustralianBoundlessCity2 == nil then
AustralianBoundlessCity2 = pPlayerCity
print("Boundless City #2 is " .. AustralianBoundlessCity2:GetName())
elseif AustralianBoundlessCity2 == nil then
AustralianBoundlessCity3 = pPlayerCity
print("Boundless City #3 is " .. AustralianBoundlessCity3:GetName())
else
print("There are no remaining slots for Boundless Cities.")
end
if pPlayerCity == AustralianBoundlessCity1 or pPlayerCity == AustralianBoundlessCity2 or pPlayerCity == AustralianBoundlessCity3 then
local pEra = Players[pPlayer]:GetCurrentEra()
if pEra > 0 then pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"], 1)
end
if pEra > 2 then
pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUMININGTOWN"], 1)
end
if pEra > 4 then
pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUREFUGEEPROGRAMME"], 1)
end
if pEra > 6 then
pPlayerCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUTOURISMDEPARTMENT"], 1)
end
end
else
print("This is not a Coastal City or it was not founded by Australia.")
end
end
end
Events.SerialEventCityCreated.Add(AussiesFoundACity)
-- Change to PlayerCityFounded(PlayerID player, int cityX, int cityY)
function EraChangedForAussies(pEra, pPlayer)
print(Players[pPlayer]:GetCivilizationType())
print(GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA)
if Players[pPlayer]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then
print("We just changed an era to era number" .. pEra .. ", mate!")
print(pEra)
for pCity in Players[pPlayer]:Cities() do
if pCity == AustraliaBoundlessCity1 or pCity == AustraliaBoundlessCity2 or pCity == AustraliaBoundlessCity3 then
print(pCity:GetName() .. " is a Boundless City, mate!")
if pEra == 1 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUCOLONIALSETTLEMENT"], 1)
elseif pEra == 3 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUMININGTOWN"], 1)
elseif pEra == 5 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUREFUGEEPROGRAMME"], 1)
elseif pEra == 7 then
pCity:SetNumRealBuilding(GameInfoTypes["BUILDING_AUTOURISMDEPARTMENT"], 1)
end
end
end
end
end
I'm not sure how to save this data, though. I assume that if you reload this code half-way through a game, it will forget who all the BoundlessCities were.
gT.AussiePlayers = {} -- create the matrix
for player in pairs(Players) do
local PlayerNumber = Players[player]:GetID()
if Players[player]:GetCivilizationType() == GameInfoTypes.CIVILIZATION_COLONIALAUSTRALIA then
gT.AussiePlayers[PlayerNumber] = {} -- create a new row
gT.AussiePlayers[PlayerNumber][AustralianBoundlessCity1] = nil
gT.AussiePlayers[PlayerNumber][AustralianBoundlessCity2] = nil
gT.AussiePlayers[PlayerNumber][AustralianBoundlessCity3] = nil
gT.AussiePlayers[PlayerNumber][AustralianPlayerEraNumber] = PreGame.GetEra()
end
end
<ShowInPedia>false</ShowInPedia>1. Custom Worker (One that only builds Australian +2 Production Mines and can upgrade into Diggers) appears under UU - how do we hide this?
Buildings are allocated to the Era their PrereqTech is in, if they have no PrereqTech, they will appear in the Ancient Era.2. All custom buildings appear in the Ancient Era. Is there any way we can hide this or allot them to other eras (or hide them)?
In the build (not the improvement) entry3. Unique +2 Production mine appears under UI and in the Tech tree - is there anyway we can hide this?
Thanks for the know-how. I'd never seen the way to hide improvements.
I once tried hiding buildings on a hidden tech, but the problem I had with that is the tech could show up in Ruins... no matter who you were playing.
Edit: is there any way to move the buildings to another Era (but not tech?)
Secondly, regarding the issue of the double mines, wouldn't it be possible to have the worker as a UU replacing the worker that can build the special mine and not the normal one? And then if this is possible you could take the old mine picture off the tech tree so there's only one.
Did you leave <GoodyTech> true by accident if you copied your hidden tech from another existing one? I'm not 100% sure the game honors this tag, but it seems likely (the techs in the DB use it appropriately).