Looking to implement code from the Into the Renaissance scenario into my mod

Frossa

Prince
Joined
Apr 29, 2012
Messages
413
Location
Sweden
First off I want to say that I am a complete newbie to Lua and that my understanding of what I'm truly dealing with is very limited.
The Into the Renaissance scenario has a feature where you inherit the Founder Beliefs of a Religion if you capture its Holy City. I want to replicate this feature for my own modded scenario, but only for a Japanese context, so the owner of Kyoto inherits the Founder Beliefs of Shinto if they count as a Japanese daimyo. (I already have another script that founds and spreads Religions as soon as the game starts.)
The code to achieve this in the ItR scenario is found in TurnsRemaining.lua (DLC\Expansion\Scenarios\MedievalScenario\TurnsRemaining.lua), and I've copied and modified it in a way that I think it would in theory do what I want it to do. But there obviously things missing:
Spoiler :
Code:
GameEvents.CityCaptureComplete.Add(function(iOldOwner, bIsCapital, iX, iY, iNewOwner, iPop, bConquest)

    local plot = Map.GetPlot(iX, iY);
    local cCity = plot:GetPlotCity();
    local iNewOwner = cCity:GetOwner();
    local civType = Players[iNewOwner]:GetCivilizationType();
   
    local pShintoHolyCity = Game.GetHolyCityForReligion(GameInfoTypes["RELIGION_SHINTO"], -1);

    local popupInfo = {
        Data1 = 500,
        Type = ButtonPopupTypes.BUTTONPOPUP_TEXT,
    }
                   
    if (cCity == pShintoHolyCity) then
        if (civType == GameInfo.Civilizations["CIVILIZATION_JAPAN"].ID or
            civType == GameInfo.Civilizations["CIVILIZATION_KOREA"].ID then
            Game.SetFounder(GameInfoTypes["RELIGION_SHINTO"], iNewOwner);
        else
            Game.SetFounder(GameInfoTypes["RELIGION_SHINTO"], GetPersistentProperty("KyotoPlayer"));
        end           

    end

end
First of all I suspect the code is incomplete without referring to a function in the first row, but I am uncertain what put here, as in the original code this part is preceded by a ton of different functionalities that I don't think are directly necessary, or would perhaps need further definition to work. Secondly I'm uncertain "pShintoHolyCity" means anything, that's just something I inferred in lieu of "pIslamHolyCity", etc. And lastly, I don't know if "PersistentProperty" serves any purpose in the code as I have laid it out, it's simply just some element present in the original code that I decided to keep just in case.

As I have absolutely no experience in coding, I may be either over- or undercomplicating things massively with this. Any help at all would be greatly appreciated.
 
Top Bottom