Lockwood27
Chieftain
- Joined
- Aug 12, 2025
- Messages
- 3
I'm hoping for some expert eyes on an issue I've been facing for like weeks (tried 50 times, I'm desperate) on macOS (Sequoia 15.6, Steam, Gathering Storm). I'm building the mod manually.
My goal is a minimal test: a Lua script that adds 1 point to the score each turn. However, the script never runs, and the score stays at 0. After fixing some initial errors, my logs now consistently point to a <span>UNIQUE constraint failed</span> error in my text file, even though I believe I've corrected it.
Since I don't have a <span>lua.log</span> on Mac, the <span>Database.log</span> is my only clue, and it seems the game is halting the loading of my mod's components because of this text file error.
This happens because I'm trying to change the text for <span>LOC_WORLD_RANKINGS_SCORE_VICTORY</span>. I've changed my XML to use <span><Update></span> instead of <span><Row></span>, but the error persists. I'm wondering if there's a subtle issue in my <span>.modinfo</span> or the XML file itself that's causing the game to misinterpret the action.
Could anyone please review my files below and see if you can spot the mistake? I've literally been banging my head against a wall and can't seem to even get off the starting line with this mod. Feel like an idiot.
<span>BalancedScoring_V1_Test.modinfo</span>
<span><?xml version="1.0" encoding="utf-8"?><br><Mod id="f5d7e9c8-a1b2-4f3c-8d5e-6a7b8c9d0e1f" version="1"><br> <Properties><br> <Name>Balanced Scoring V1 (Minimal Test)</Name><br> <Description>A new scoring system for Civilization VI.</Description><br> <Teaser>Balanced Scoring V1 Test</Teaser><br> <Authors>You</Authors><br> <CompatibleVersions>2.0</CompatibleVersions><br> </Properties><br><br> <Files><br> <File>Lua/BalancedScoring_GameManager.lua</File><br> <File>Lua/BalancedScoring_UI.lua</File><br> <File>UI/WorldRankings_Expansion2.xml</File><br> <File>XML/BalancedScoring_GameSetup.xml</File><br> <File>XML/BalancedScoring_Text.xml</File><br> </Files><br><br> <FrontEndActions><br> <UpdateDatabase id="UpdateGameSetup"><br> <File>XML/BalancedScoring_GameSetup.xml</File><br> </UpdateDatabase><br> <UpdateText id="UpdateGameText"><br> <Properties><br> <LoadOrder>100</LoadOrder><br> </Properties><br> <File>XML/BalancedScoring_Text.xml</File><br> </UpdateText><br> </FrontEndActions><br><br> <InGameActions><br> <AddGameplayScripts id="AddGameManager"><br> <File>Lua/BalancedScoring_GameManager.lua</File><br> </AddGameplayScripts><br> <AddUserInterfaces id="AddWorldRankingsUI"><br> <Properties><br> <Context>InGame</Context><br> </Properties><br> <File>UI/WorldRankings_Expansion2.xml</File><br> </AddUserInterfaces><br> <AddUserInterfaces id="AddUIHooks"><br> <Properties><br> <Context>InGame</Context><br> </Properties><br> <File>Lua/BalancedScoring_UI.lua</File><br> </AddUserInterfaces><br> <UpdateText id="UpdateGameText_InGame"><br> <Properties><br> <LoadOrder>100</LoadOrder><br> </Properties><br> <File>XML/BalancedScoring_Text.xml</File><br> </UpdateText><br> </InGameActions><br></Mod><br></span><br>
<span>XML/BalancedScoring_Text.xml</span>
<span><?xml version="1.0" encoding="utf-8"?><br><GameInfo><br> <LocalizedText><br> <!-- Add new text entries for the mod's options --><br> <Row Tag="LOC_BALANCED_SCORING_NAME" Language="en_US"><br> <Text>Enable Balanced Scoring</Text><br> </Row><br> <Row Tag="LOC_BALANCED_SCORING_DESC" Language="en_US"><br> <Text>Enables the Balanced Scoring mode.</Text><br> </Row><br> <Row Tag="LOC_SCORE_TEST" Language="en_US"><br> <Text>Per Turn Test</Text><br> </Row><br><br> <!-- Update existing game text --><br> <Update><br> <Where Tag="LOC_WORLD_RANKINGS_SCORE_VICTORY" Language="en_US"/><br> <Set><br> <Text>Balanced Scoring</Text><br> </Set><br> </Update><br> </LocalizedText><br></GameInfo><br></span><br>
<span>Lua/BalancedScoring_GameManager.lua</span>
<span>-- ===========================================================================<br>-- BalancedScoring_GameManager.lua (MINIMAL VIABLE TEST)<br>-- This script attempts to add 1 point to the human player's score every turn.<br>-- ===========================================================================<br><br>function AddOnePointPerTurn(iPlayer)<br> -- We only care about the human player (Player ID 0 in single player)<br> if iPlayer == 0 then<br> local pPlayer = Players[iPlayer];<br> <br> -- This is a critical safety check. If pPlayer is nil for any reason,<br> -- the script will stop here instead of crashing.<br> if pPlayer then<br> pPlayer:ChangeScore(1, "LOC_SCORE_TEST");<br> print("Minimal Test: Attempted to add 1 point to Player 0.");<br> else<br> print("Minimal Test Error: Player 0 object is nil.");<br> end<br> end<br>end<br><br>-- We are hooking into PlayerTurnStarted. This event fires reliably at the start of every player's turn.<br>GameEvents.PlayerTurnStarted.Add(AddOnePointPerTurn);<br><br>print("Balanced Scoring Minimal Test Loaded.");<br></span><br>
(The other files are just UI placeholders and the game setup toggle, which works fine, so I've omitted them for brevity but can post if needed).
<span>Modding.log</span>
<span>[2664641.232] Initializing Modding Framework.<br>[2664641.232] Connected to modding database!<br>[2664641.232] Modding database is up-to-date!<br>[2664641.232] Initializing Services...<br>[2664641.232] Mod Discovery Service initialized.<br>[2664641.232] Scanning for Mods...<br>[2664641.232] Discovered Mod: f5d7e9c8-a1b2-4f3c-8d5e-6a7b8c9d0e1f (Balanced Scoring V1 (Minimal Test))<br>...<br>[2664641.232] Modding Framework - Apply Components<br>[2664641.232] Loading Mod - /Users/AK/Library/Application Support/Sid Meier's Civilization VI/Sid Meier's Civilization VI/Mods/BalancedScoring_V1_Test/BalancedScoring_V1_Test.modinfo<br>[2664641.232] Applying Component - UpdateGameSetup (UpdateDatabase)<br>[2664641.232] Applying Component - UpdateGameText (UpdateText)<br>...<br>[2664641.232] Applying Component - AddGameManager (AddGameplayScripts)<br>[2664641.232] Applying Component - AddWorldRankingsUI (AddUserInterfaces)<br>[2664641.232] Applying Component - AddUIHooks (AddUserInterfaces)<br>[2664641.232] Applying Component - UpdateGameText_InGame (UpdateText)<br>...<br>[2664641.232] Modding Framework - Finished Apply Components<br>[2664641.232] Applied all components of enabled mods.<br></span><br>
<span>Database.log</span>
<span>[2664640.232] [Configuration]: Validating Foreign Key Constraints...<br>[2664640.232] [Configuration]: Passed Validation.<br>[2664641.232] [FullTextSearch]: Initializing FullTextSearch<br>[2664641.232] [Gameplay]: Validating Foreign Key Constraints...<br>[2664641.232] [Gameplay]: Passed Validation.<br>[2664641.232] [Localization] ERROR: UNIQUE constraint failed: LocalizedText.Language, LocalizedText.Tag<br>[2664641.232] [Localization]: While executing - 'insert into LocalizedText('Tag', 'Language', 'Text') values (?, ?, ?);'<br>[2664641.232] [Localization]: In XMLSerializer while inserting row into table insert into LocalizedText('Tag', 'Language', 'Text') with values (LOC_WORLD_RANKINGS_SCORE_VICTORY, en_US, Balanced Scoring, ).<br>[2664641.232] [Localization]: In XMLSerializer while updating table LocalizedText from file BalancedScoring_Text.xml.<br>[2664673.232] [Gameplay]: Validating Foreign Key Constraints...<br>[2664673.232] [Gameplay]: Passed Validation.<br></span><br>
(I've cleaned up the logs to show only the relevant parts)
Can anyone see what I'm missing? Why isn't this script running and changing the score? Any advice would be hugely appreciated.
My goal is a minimal test: a Lua script that adds 1 point to the score each turn. However, the script never runs, and the score stays at 0. After fixing some initial errors, my logs now consistently point to a <span>UNIQUE constraint failed</span> error in my text file, even though I believe I've corrected it.
Since I don't have a <span>lua.log</span> on Mac, the <span>Database.log</span> is my only clue, and it seems the game is halting the loading of my mod's components because of this text file error.
The Problem
My <span>Database.log</span> shows this error:<span>[Localization] ERROR: UNIQUE constraint failed: LocalizedText.Language, LocalizedText.Tag ... In XMLSerializer while updating table LocalizedText from file BalancedScoring_Text.xml.</span>This happens because I'm trying to change the text for <span>LOC_WORLD_RANKINGS_SCORE_VICTORY</span>. I've changed my XML to use <span><Update></span> instead of <span><Row></span>, but the error persists. I'm wondering if there's a subtle issue in my <span>.modinfo</span> or the XML file itself that's causing the game to misinterpret the action.
Could anyone please review my files below and see if you can spot the mistake? I've literally been banging my head against a wall and can't seem to even get off the starting line with this mod. Feel like an idiot.
The Mod Files
Here is the complete code for my test mod.<span>BalancedScoring_V1_Test.modinfo</span>
<span><?xml version="1.0" encoding="utf-8"?><br><Mod id="f5d7e9c8-a1b2-4f3c-8d5e-6a7b8c9d0e1f" version="1"><br> <Properties><br> <Name>Balanced Scoring V1 (Minimal Test)</Name><br> <Description>A new scoring system for Civilization VI.</Description><br> <Teaser>Balanced Scoring V1 Test</Teaser><br> <Authors>You</Authors><br> <CompatibleVersions>2.0</CompatibleVersions><br> </Properties><br><br> <Files><br> <File>Lua/BalancedScoring_GameManager.lua</File><br> <File>Lua/BalancedScoring_UI.lua</File><br> <File>UI/WorldRankings_Expansion2.xml</File><br> <File>XML/BalancedScoring_GameSetup.xml</File><br> <File>XML/BalancedScoring_Text.xml</File><br> </Files><br><br> <FrontEndActions><br> <UpdateDatabase id="UpdateGameSetup"><br> <File>XML/BalancedScoring_GameSetup.xml</File><br> </UpdateDatabase><br> <UpdateText id="UpdateGameText"><br> <Properties><br> <LoadOrder>100</LoadOrder><br> </Properties><br> <File>XML/BalancedScoring_Text.xml</File><br> </UpdateText><br> </FrontEndActions><br><br> <InGameActions><br> <AddGameplayScripts id="AddGameManager"><br> <File>Lua/BalancedScoring_GameManager.lua</File><br> </AddGameplayScripts><br> <AddUserInterfaces id="AddWorldRankingsUI"><br> <Properties><br> <Context>InGame</Context><br> </Properties><br> <File>UI/WorldRankings_Expansion2.xml</File><br> </AddUserInterfaces><br> <AddUserInterfaces id="AddUIHooks"><br> <Properties><br> <Context>InGame</Context><br> </Properties><br> <File>Lua/BalancedScoring_UI.lua</File><br> </AddUserInterfaces><br> <UpdateText id="UpdateGameText_InGame"><br> <Properties><br> <LoadOrder>100</LoadOrder><br> </Properties><br> <File>XML/BalancedScoring_Text.xml</File><br> </UpdateText><br> </InGameActions><br></Mod><br></span><br>
<span>XML/BalancedScoring_Text.xml</span>
<span><?xml version="1.0" encoding="utf-8"?><br><GameInfo><br> <LocalizedText><br> <!-- Add new text entries for the mod's options --><br> <Row Tag="LOC_BALANCED_SCORING_NAME" Language="en_US"><br> <Text>Enable Balanced Scoring</Text><br> </Row><br> <Row Tag="LOC_BALANCED_SCORING_DESC" Language="en_US"><br> <Text>Enables the Balanced Scoring mode.</Text><br> </Row><br> <Row Tag="LOC_SCORE_TEST" Language="en_US"><br> <Text>Per Turn Test</Text><br> </Row><br><br> <!-- Update existing game text --><br> <Update><br> <Where Tag="LOC_WORLD_RANKINGS_SCORE_VICTORY" Language="en_US"/><br> <Set><br> <Text>Balanced Scoring</Text><br> </Set><br> </Update><br> </LocalizedText><br></GameInfo><br></span><br>
<span>Lua/BalancedScoring_GameManager.lua</span>
<span>-- ===========================================================================<br>-- BalancedScoring_GameManager.lua (MINIMAL VIABLE TEST)<br>-- This script attempts to add 1 point to the human player's score every turn.<br>-- ===========================================================================<br><br>function AddOnePointPerTurn(iPlayer)<br> -- We only care about the human player (Player ID 0 in single player)<br> if iPlayer == 0 then<br> local pPlayer = Players[iPlayer];<br> <br> -- This is a critical safety check. If pPlayer is nil for any reason,<br> -- the script will stop here instead of crashing.<br> if pPlayer then<br> pPlayer:ChangeScore(1, "LOC_SCORE_TEST");<br> print("Minimal Test: Attempted to add 1 point to Player 0.");<br> else<br> print("Minimal Test Error: Player 0 object is nil.");<br> end<br> end<br>end<br><br>-- We are hooking into PlayerTurnStarted. This event fires reliably at the start of every player's turn.<br>GameEvents.PlayerTurnStarted.Add(AddOnePointPerTurn);<br><br>print("Balanced Scoring Minimal Test Loaded.");<br></span><br>
(The other files are just UI placeholders and the game setup toggle, which works fine, so I've omitted them for brevity but can post if needed).
Log Files
Here are my <span>Modding.log</span> and <span>Database.log</span> from the failed test.<span>Modding.log</span>
<span>[2664641.232] Initializing Modding Framework.<br>[2664641.232] Connected to modding database!<br>[2664641.232] Modding database is up-to-date!<br>[2664641.232] Initializing Services...<br>[2664641.232] Mod Discovery Service initialized.<br>[2664641.232] Scanning for Mods...<br>[2664641.232] Discovered Mod: f5d7e9c8-a1b2-4f3c-8d5e-6a7b8c9d0e1f (Balanced Scoring V1 (Minimal Test))<br>...<br>[2664641.232] Modding Framework - Apply Components<br>[2664641.232] Loading Mod - /Users/AK/Library/Application Support/Sid Meier's Civilization VI/Sid Meier's Civilization VI/Mods/BalancedScoring_V1_Test/BalancedScoring_V1_Test.modinfo<br>[2664641.232] Applying Component - UpdateGameSetup (UpdateDatabase)<br>[2664641.232] Applying Component - UpdateGameText (UpdateText)<br>...<br>[2664641.232] Applying Component - AddGameManager (AddGameplayScripts)<br>[2664641.232] Applying Component - AddWorldRankingsUI (AddUserInterfaces)<br>[2664641.232] Applying Component - AddUIHooks (AddUserInterfaces)<br>[2664641.232] Applying Component - UpdateGameText_InGame (UpdateText)<br>...<br>[2664641.232] Modding Framework - Finished Apply Components<br>[2664641.232] Applied all components of enabled mods.<br></span><br>
<span>Database.log</span>
<span>[2664640.232] [Configuration]: Validating Foreign Key Constraints...<br>[2664640.232] [Configuration]: Passed Validation.<br>[2664641.232] [FullTextSearch]: Initializing FullTextSearch<br>[2664641.232] [Gameplay]: Validating Foreign Key Constraints...<br>[2664641.232] [Gameplay]: Passed Validation.<br>[2664641.232] [Localization] ERROR: UNIQUE constraint failed: LocalizedText.Language, LocalizedText.Tag<br>[2664641.232] [Localization]: While executing - 'insert into LocalizedText('Tag', 'Language', 'Text') values (?, ?, ?);'<br>[2664641.232] [Localization]: In XMLSerializer while inserting row into table insert into LocalizedText('Tag', 'Language', 'Text') with values (LOC_WORLD_RANKINGS_SCORE_VICTORY, en_US, Balanced Scoring, ).<br>[2664641.232] [Localization]: In XMLSerializer while updating table LocalizedText from file BalancedScoring_Text.xml.<br>[2664673.232] [Gameplay]: Validating Foreign Key Constraints...<br>[2664673.232] [Gameplay]: Passed Validation.<br></span><br>
(I've cleaned up the logs to show only the relevant parts)
Can anyone see what I'm missing? Why isn't this script running and changing the score? Any advice would be hugely appreciated.