[BNW] Faith ReplayDataSet

legojoshua12

Chieftain
Joined
Apr 19, 2018
Messages
13
I was wondering if anyone knows how to add more replaydatasets. I found a table of replay sets but faith seems to not be included in those data sets. Upon adding a faith per turn and total faith values into the xml table, I can't seem to find any lua or sdk information of where the data sets are hooked up with which attributes to what. The only stuff from the table are:
Code:
<Table name="ReplayDataSets">
        <Column name="ID" type="integer"  primarykey="true" autoincrement="true" />
        <Column name="Type" type="text"  unique="true" notnull="true" />
        <Column name="Name" type="text"  />
        <Column name="Description" type="text"  />
    </Table>
Anyone have an idea as to what I do next or am I chasing something that isn't quite possible?
 
All the base game code is in C++, see all the calls to setReplayDataValue() in CvPlayer.cpp

But that's not to say you couldn't extend it as that method is exposed to Lua - via pPlayer:setReplayDataValue(sDataSetName, iTurn, iValue) - so in theory you could add new row(s) (with XML/SQL) into the ReplayDataSets table and then with Lua hook GameEvents.PlayerDoTurn to store any required value(s) - while PlayerDoTurn fires at the start of player N's turn, it also can be used as an end of turn event for player N-1

W
 
Thank you so much for your help! The final code is as follows for everyone else to use:
Code:
<Row>
    <Type>REPLAYDATASET_TOTALFAITH</Type>
    <Description>TXT_KEY_REPLAY_DATA_TOTALFAITH</Description>
</Row>
<Row>
    <Type>REPLAYDATASET_FAITHPERTURN</Type
    <Description>TXT_KEY_REPLAY_DATA_FAITHPERTURN</Description>
</Row>
And the lua:
Code:
GameEvents.PlayerDoTurn.Add(function (iPlayer)
    local pPlayer = Players[iPlayer]
    local iTurn = Game.GetGameTurn()
    local pTotalFaith = pPlayer:GetFaith()
    local pFaithPerTurn = pPlayer:GetTotalFaithPerTurn()
    pPlayer:SetReplayDataValue("REPLAYDATASET_TOTALFAITH", iTurn, pTotalFaith)
    pPlayer:SetReplayDataValue("REPLAYDATASET_FAITHPERTURN", iTurn, pFaithPerTurn)
end);
 
Last edited:
Top Bottom