LeeS
Imperator
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:Code:<GameplayScripts id="LUA_CODE"> <Properties> <Name>LUA_CODE_GAMEPLAY_CHANGES</Name> </Properties> <Items> <File>LUA_Code.lua</File> </Items> </GameplayScripts>
- 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
Code:
local iGrassMountains = GameInfo.Terrains["TERRAIN_GRASS_MOUNTAIN"].Index TerrainBuilder.SetTerrainType(pChosenPlot, iGrassMountains)
- 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.
Last edited: