[BNW] AddGameplayScript not working

clamlol

Chieftain
Joined
Feb 10, 2022
Messages
19
I have a very simple demonstration mod with three files. One of the files is a ReadMe, and the other two Simple Test Mod.modinfo:
XML:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="12345678-abcd-4321-abcd-1234567890ab" version="1">
  <Properties>
    <Name>Logger Test</Name>
    <Teaser>Logs a message on activation and during the first turn of the game.</Teaser>
    <Description>Logs a message on activation and during the first turn of the game.</Description>
    <Authors>Me</Authors>
    <HideSetupGame>0</HideSetupGame>
    <AffectsSavedGames>0</AffectsSavedGames>
    <SupportsSinglePlayer>1</SupportsSinglePlayer>
    <SupportsMultiplayer>1</SupportsMultiplayer>
    <SupportsHotSeat>1</SupportsHotSeat>
    <SupportsMac>1</SupportsMac>
    <ReloadAudioSystem>0</ReloadAudioSystem>
    <ReloadLandmarkSystem>0</ReloadLandmarkSystem>
    <ReloadStrategicViewSystem>0</ReloadStrategicViewSystem>
    <ReloadUnitSystem>0</ReloadUnitSystem>
  </Properties>
  <Files>
    <File md5="10AB29183716351BD291039187351002" import="1">LoggerTest.lua</File>
  </Files>
  <Actions>
    <OnModActivated>
      <File>LoggerTest.lua</File>
    </OnModActivated>
    <InGameActions>
      <!-- <ImportFiles>LoggerTest.lua</ImportFiles> -->
      <!-- <File>LoggerTest.lua</File> -->
      <AddGameplayScript>LoggerTest.lua</AddGameplayScript>
    </InGameActions>
  </Actions>
</Mod>
and LoggerTest.lua:
Code:
print("Hello from LoggerTest.lua!")

GameEvents.PlayerDoTurn.Add(function(iPlayer)
  print("LoggerTest function ran!")
  if iPlayer == 0 then
    print("Turn started for player 0")
  end
end)
When I load the mod (keeping all others disabled), set up a new game, play a couple turns and quit, nothing from LoggerTest.lua is printed to Lua.log. I cannot understand why this is not working. Throughout my troubleshooting with ChatGPT and Perplexity, <AddGameplayScript> has been a common refrain, yet it seems for all the world like <AddGameplayScript> just doesn't do anything. I can get things to print if I do <EntryPoint type="InGameUIAddin">, but I can't hook into GameEvents.TeamTechResearched with a UI addin, which is ultimately what I want to do. Can anyone please explain what I'm doing wrong?
 
Last edited:
I see multiple examples of scripts added as InGameUIAddin that feature GameEvents.TeamTechResearched and work.
Post the relevant function, maybe there's a syntax error.
 
Take a look at "My Changes" mod (link in sig) as it's setup correctly for XML, SQL, UI and Lua additions
 
After looking over the My Changes mod I've come to the conclusion that AddGameplayScript is just something AI made up and that, for a mod which neither does nor relies upon any modification to the vanilla DLL, <EntryPoint type="InGameUIAddin> is the one and only type of entry point for Lua scripts. And yeah, TechTeamResearched works just fine when I run it that way, I must have missed it initially because of how buggily Apple's Console app reads Lua.log while Civ is still writing to it. Thanks for your guys' help!
 
Back
Top Bottom