We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.

Current Status of Lua Modding

After running some tests and playing around with various methods, the following appears to be true:

[fixed by Winter 2016 patch]Lua scripts that are activated in the modinfo file as "GameplayScripts" only load into the game when a new game is started. When a reload of a saved game is conducted, the lua script is not loaded along with the saved game.
This concerns lua files that are set up in the modinfo file like as this:

Certain API methods (functions) only seem to work in certain context-types. So, for example, the API unit method "GetUnitType()" is not a valid function-name in a "GameplayScripts" context but appears to be valid in a UI context. Similarly, JFD tested and verified that "playerReligion:GetReligionTypeCreated()" is only recognized in a UI context, and when attempted from a "GameplayScripts" context simply causes a fatal syntax error to the lua file. This also explains why using

and similar methods for the ResourceBuilder and FeatureBuilder seem to work in a "GameplayScripts" context but appear not to work in a UI context.

The graphics issues on the main map for terrain alteration coming from a GameplayScript lua from Civ5 are alive and well in Civ6. You can alter the terrain, but in order to get the graphics to update, the player must save and then reload their game.

The good news is that while undocumented as yet there appears to be a pairing of a "set" and a "change" with most "get" methods.

So, playerReligion:GetFaithBalance() has a paired playerReligion:SetFaithBalance(iNewValue) and playerReligion:ChangeFaithBalance(iChangeAmount).

These two specific examples have been tested by me and verified to work.

It seems that only lua files that are replacements for existing basegame lua files can be Imported into the VFS system and included in another lua file. New lua files that are Imported and then Included seem not to work according to JFD.

Want to play a different Civilization game ?
Interested by Revolutions, Supply Lines, Front Lines, Resources stockpile and much more ?
Help me design and develop my most ambitious modding project so far.​

Moderator Action: I think whilst LeeS and others are formulating the state of lua modding, it would be good to sticky it in this forum for now, pending a more descriptive thread once more discoveries have been made about lua in Civ 6. I've done this (after speaking with LeeS about it). Please read the forum rules: http://forums.civfanatics.com/showthread.php?t=422889

Do custom UI screens not work yet? I thought I would experiment with one, tried loading as a UserInterface component and game would start to load, jump back to game setup, then I could hit play and game would load, but not custom file. I wasn't sure if there was some setting I was missing, or just doesn't work yet.
Sorry if this was already covered and I didn't see.

Edit: I think I may not be properly defining the context. How do I specify the context as ingame and a screen, currently I have name="ingame" in opening context line, and

Want to play a different Civilization game ?
Interested by Revolutions, Supply Lines, Front Lines, Resources stockpile and much more ?
Help me design and develop my most ambitious modding project so far.​

Want to play a different Civilization game ?
Interested by Revolutions, Supply Lines, Front Lines, Resources stockpile and much more ?
Help me design and develop my most ambitious modding project so far.​

After running some tests and playing around with various methods, the following appears to be true:

Lua scripts that are activated in the modinfo file as "GameplayScripts" only load into the game when a new game is started. When a reload of a saved game is conducted, the lua script is not loaded along with the saved game.
This concerns lua files that are set up in the modinfo file like as this:

Certain API methods (functions) only seem to work in certain context-types. So, for example, the API unit method "GetUnitType()" is not a valid function-name in a "GameplayScripts" context but appears to be valid in a UI context. Similarly, JFD tested and verified that "playerReligion:GetReligionTypeCreated()" is only recognized in a UI context, and when attempted from a "GameplayScripts" context simply causes a fatal syntax error to the lua file. This also explains why using

and similar methods for the ResourceBuilder and FeatureBuilder seem to work in a "GameplayScripts" context but appear not to work in a UI context.

Click to expand...

Anyone found a workaround ?

I'd really want to use functions available in a gameplay script context after reloading a game...

There is a "GameCore_Tuner" Lua state listed in the FireTuner which is a "gameplay script context", but can we hook on it ?

Want to play a different Civilization game ?
Interested by Revolutions, Supply Lines, Front Lines, Resources stockpile and much more ?
Help me design and develop my most ambitious modding project so far.​

Out of curiosity, anyone know how Tutorial.lua is loaded into game? It is listed in the tutorial modinfo as a file, but it's not loaded under components, and I can't find any reference to it. Was just wondering how it was attached, or if was just unused.

Lua scripts that are activated in the modinfo file as "GameplayScripts" only load into the game when a new game is started. When a reload of a saved game is conducted, the lua script is not loaded along with the saved game.

Click to expand...

Did i understand this correctly as "we can't have Lua scripts affecting gameplay apart from the intialization" or is it just one way of loading them that doesn't work?
What if i wanted a Lua script for a custom trait like many Civ5 custom civs? Or one that changes yields or adds a dummy building? Are those currently possible as they were in Civ5 or are we limited to UI mods as far as Lua is concerned currently?

Did i understand this correctly as "we can't have Lua scripts affecting gameplay apart from the intialization" or is it just one way of loading them that doesn't work?
What if i wanted a Lua script for a custom trait like many Civ5 custom civs? Or one that changes yields or adds a dummy building? Are those currently possible as they were in Civ5 or are we limited to UI mods as far as Lua is concerned currently?

Click to expand...

At the moment we are limited to UI. The other types of lua methods you are referring to require running from a Gameplay script because at the moment many lua commands are context-type dependant, and you need things like as an example a unit-captured event to run from a gameplay context rather than a UI context*. IE, some methods only work in a UI, and are not recognized in a gameplay script, and vice versa. Lots of stuff works in both types of context but it is pretty much hit or miss at the moment for the implementation of what works in which type of lua file.

* I tried to do that sort of thing as a work-around, but it locked the game because I needed to use a command that was only valid in a gameplay context, and it made the game lock up when it was attempted in a UI file.

just for adding a file to the mod (which I am not sure why you would want/need to in game, or do they actually add the file into the game?

Click to expand...

StoredProcedures looks like it is how the game finds and reads the files from the mod(s) and loads them into the game. The issue would appear to be in the game's exe file, since a AgentRansack search shows both the phrases "Modding_LoadMod" and "StoredProcedures" as being what would look like executable code within the game's exe file. Other than that it's all @, $ and # in the same chunk of the exe code.

Yes, I hope it's just because those changes would not be a problem if they are called multiple times, not a sign that gameplay script are designed to run once...

Want to play a different Civilization game ?
Interested by Revolutions, Supply Lines, Front Lines, Resources stockpile and much more ?
Help me design and develop my most ambitious modding project so far.​

The tutorial cheats, it has Lua files under base\assets that always run, as well as kludges in a number of other files, like Civ6Common.lua[712]:

Code:

function IsTutorialRunning()
local mods = Modding.GetActiveMods();
if mods ~= nil then
for i,v in ipairs(mods) do
if v.Id == TUTORIAL_UUID then
return true;
end
end
else
UI.DataError("Unable to obtain mods table to determine if tutorial is running.");
end
return false;
end