C++/Lua Request Thread

Tpangolin, you can easily detect when a Great Person is created using the code bane linked to but many of the effects with tourism will be tricky to implement. There is no way in lua to directly change a player's tourism. It might be possible to give a player one-time tourism by adding a building that provided techEnhancedTourism and removing that building at the start of the player's next turn. But then the tourism would be subject to any city specific multipliers (from social policies) or civilization wide trait specific multipliers (brazil). It is much easier to work with non-Tourism yields (Culture, Gold, Faith, etc).
 
Two ways of directly adding Tourism:

1. Exact amount
Create a dummy unit and a dummy policy. Set the dummy policy to provide a boost of tourism when you create the dummy unit. Give your Civ the dummy policy, and, when you want to provide the tourism amount, make a function to create the dummy unit and immediately kill it.

2.Variable amount based on Tourism output
Create a dummy unit with the Concert Tour ability. Make a function to create a copy of the unit, then use PushMission to force it to use the Concert Tour immediately.
 
So kinda new to the site. I have like 10 mods that havent been released yet lol. Anyway i have no experience with Lua and i know what im looking for requires that. My request is if it is possible for golden ages to be started by coups? Also if its possible to modify science and production during golden ages in xml?
 
is [it] possible for golden ages to be started by coups? Also if its possible to modify science and production during golden ages in xml?
While it is possible to start Golden Ages via lua player:ChangeGoldenAgeTurns(int) there is no event that can be used to detect when a city-state is coup'd.

Also if its possible to modify science and production during golden ages in xml?
Production is already boosted during Golden Ages. If you wanted to boost Science it would be a bit clunky but you would have to test each turn to see if a player is in a Golden Age and if so add Science separately. This Science wouldn't show up properly in the per-turn UI though.
 
I kinda guessed those wouldnt be possible. so what about a building that allows two cities to connect without a use of a road or a harbor? wonder if thats even possible
 
I'm not well versed in Civilization V modding but I have a question in relation to some plan of mine: is it possible to restrict a city from growing? Basically, letting it have a food surplus but not actually growing.

I'm sure this can be done in the DLL; would it be possible with Lua only?
 
Though you can check whether avoid growth is set with
Code:
bool City:IsForcedAvoidGrowth()
there's no equivalent setter. However, you could always use
Code:
void City:SetFood(int newValue)
and set it to zero every turn.
 
Though you can check whether avoid growth is set with
Code:
bool City:IsForcedAvoidGrowth()
there's no equivalent setter. However, you could always use
Code:
void City:SetFood(int newValue)
and set it to zero every turn.
That sounds good, thank you.
 
Hi, you may have seen some of my earlier posts about mods and I want to make some good ones but I have 0 experience with Lua. SQL and XML all makes (almost) perfect sense to me. But I want to make it so that every turn a particular unit (conscript army)
has a 20% chance of disbanning. As I have no Lua knowledge I have no idea where to even start.

Thanks!
 
Hey there, we need some lua that makes a land unit (Lantaka) have the ability to fire without setting up when embarked.

We also need the unit to provide the same yields as a Great Work of Art (+2 Culture, +2 Tourism).
 
I'm adding a Clergy specialist to most "standard" religious buildings; most of the work is either done (thanks to a friend's code) or easily added (thanks to Sneaks' tutorial). Unfortunately, I lack enough technical skill to add one feature: making Clergy contribute GP points toward spawning a Great Prophet. If BNW allows doing that with Lua alone, could someone please post the code I would need? Many thanks!
 
I know there's a lot of hardcoding in this area, so I wouldn't be surprised, but are you saying that using just XML or SQL in the Specialists table (GreatPeopleRateChange and GreatPeopleUnitClass) doesn't work?

If not, the wiki entry here has all the Lua getters and setters for Specialists and Great People for city objects.
 
AFAIK making a specialist contribute GP points to any unit class works as Nutty described.

It's specialists producing faith that doesn't work.
 
AFAIK making a specialist contribute GP points to any unit class works as Nutty described.

It's specialists producing faith that doesn't work.

Ahh, OK; my friend's Lua script should solve the Faith problem (and the UI problem that any new specialist type creates). I'll add in the XML entry as planned.
 
Hi, i talked about this in other threads:

I'd like a lua script to add X tiles into a city once a certain policy has been taken (liberty opener, maybe another later in Order)

I already made it work with DLL modding, but its incompatible with other mods this way.

Thanks!
 
Hi, you may have seen some of my earlier posts about mods and I want to make some good ones but I have 0 experience with Lua. SQL and XML all makes (almost) perfect sense to me. But I want to make it so that every turn a particular unit (conscript army)
has a 20% chance of disbanning. As I have no Lua knowledge I have no idea where to even start.

Thanks!
 
Hi, i talked about this in other threads:

I'd like a lua script to add X tiles into a city once a certain policy has been taken (liberty opener, maybe another later in Order)

I already made it work with DLL modding, but its incompatible with other mods this way.

Thanks!

OK, so i did most of what's needed to be done with that one, but im still missing a command or two in lua:

Can anyone please tell me the command for checking the next plot to aquire, and then aquiring it? Or direct me to where i can find the command?

Thanks!
 
checking the next plot to aquire, and then aquiring it? Or direct me to where i can find the command?

Look in CityView.lua when the Purchase Plot option is active - the next plots to acquire are highlighted in purple (the game picks a random one) and the code to acquire it is basically the buy tile code
 
I'm working on a new civilization which has a scout which after having explored 50 tiles may be expended for a unique Great work of Writing and gives a faith boost. Is this possible to code with Lua, and could somebody possibly write that for me, please?:)
 
Look in CityView.lua when the Purchase Plot option is active - the next plots to acquire are highlighted in purple (the game picks a random one) and the code to acquire it is basically the buy tile code

Its working now, thanks!

if anyone in the future wants to know how i did it:


Spoiler :
function OnCityFounded(iPlayer, iCityX, iCityY)
local pPlayer = Players[iPlayer];
if (pPlayer == nil) then return; end

local pPlot = Map.GetPlot(iCityX, iCityY);
if (pPlot == nil) then return; end

local pCity = pPlot:GetPlotCity();
if (pCity == nil) then return; end

if (pPlayer:HasPolicy(GameInfo.Policies["POLICY_LIBERTY"].ID)) then
if (pCity == nil) then return; end

for i = 1, 3, 1 do
local plot = pCity:GetNextBuyablePlot();
plot:SetOwner(pCity:GetOwner());

end
end
end

GameEvents.PlayerCityFounded.Add( OnCityFounded );
 
Back
Top Bottom