Hatsu
Chieftain
- Joined
- Oct 31, 2005
- Messages
- 8
Hi,
I wanted to use this mod to create a small list with a few helper functions for me. Menu creating works as intended, but my custom function fails on the above action. So that's why I'm posting here and not in the mod discussion thread.
This is my function:
Clicking on the button produces and in line 697 is pTreasury:ChangeGoldBalance(20);
Inserting print statements in the function show that player is not nil, treasury is not nil and printing GetGoldBalance prints the right amount of current gold in log.
So I guess there's something I miss. I read something about contexts but actually I have no idea how to change it in my mod.
My modinfo file is:
I wanted to use this mod to create a small list with a few helper functions for me. Menu creating works as intended, but my custom function fails on the above action. So that's why I'm posting here and not in the mod discussion thread.
This is my function:
Code:
function SetMyGold()
local player = Players[Game.GetLocalPlayer()];
if player:IsHuman() then
local pTreasury = player:GetTreasury();
local pGold = pTreasury:GetGoldBalance();
pTreasury:ChangeGoldBalance(20);
end
end
Clicking on the button produces and in line 697 is pTreasury:ChangeGoldBalance(20);
Code:
Runtime Error: C:\Users\myuser\Documents\My Games\Sid Meier's Civilization VI\Mods\ModularScreens\UI\LaunchBar.lua:697: function expected instead of nil
stack traceback:
C:\Users\myuser\Documents\My Games\Sid Meier's Civilization VI\Mods\ModularScreens\UI\LaunchBar.lua:697: in function 'SetMyGold'
C:\Users\myuser\Documents\My Games\Sid Meier's Civilization VI\Mods\ModularScreens\UI\LaunchBar.lua:208: in function '(anonymous)'
So I guess there's something I miss. I read something about contexts but actually I have no idea how to change it in my mod.
My modinfo file is:
Code:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="f596994b-30d8-4639-9175-1c2e965cbd20" version="1.0">
<Properties>
<Name>LOC_MODULAR_SCREENS_NAME</Name>
<Stability>LOC_MODULAR_SCREENS_STABILITY</Stability>
<Teaser>LOC_MODULAR_SCREENS_TEASER</Teaser>
<Description>LOC_MODULAR_SCREENS_DESCRIPTION</Description>
<Authors>LOC_MODULAR_SCREENS_AUTHORS</Authors>
<AffectsSavedGames>0</AffectsSavedGames>
<SupportsMultiplayer>0</SupportsMultiplayer>
<SupportsHotSeat>0</SupportsHotSeat>
</Properties>
<Components>
<ImportFiles id="MODULAR_SCREENS_IMPORT_FILES">
<Items>
<File>UI/launchbar.lua</File>
<File>UI/launchbar.xml</File>
</Items>
</ImportFiles>
</Components>
<LocalizedText>
<Text id="LOC_MODULAR_SCREENS_NAME">
<en_US>Modular Screens</en_US>
</Text>
<Text id="LOC_MODULAR_SCREENS_STABILITY">
<en_US>Alpha</en_US>
</Text>
<Text id="LOC_MODULAR_SCREENS_TEASER">
<en_US>Allows modders to safely add icons to launchbar, hookups and pulldown.</en_US>
</Text>
<Text id="LOC_MODULAR_SCREENS_DESCRIPTION">
<en_US>Allows modders to safely add icons to launchbar, hookups and pulldown.</en_US>
</Text>
<Text id="LOC_MODULAR_SCREENS_AUTHORS">
<en_US>astog</en_US>
</Text>
</LocalizedText>
<Files>
<File>UI/launchbar.lua</File>
<File>UI/launchbar.xml</File>
</Files>
</Mod>