• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Lua trait issues

:thinking emoji:

Chieftain
Joined
Apr 4, 2018
Messages
4
I've been trying to give my custom civilization (the Selk'nam) a simple trait: Aesthetics is available from the Ancient era. To do this, I edited the trait from HoopThrower's Chile-Allende civilization (which makes all policy branches available from the ancient era) to just make Aesthetics available. However, despite fixing all the syntax errors, adding the file as a UIGameAddin and checking both the database.log and the lua.log, I can't seem to make it have any effect. Am I missing something, or is there something I need to fix?

Here's the code:

Code:
include("Strict.lua")
local iSelknamCiv = GameInfoTypes.CIVILIZATION_SELKNAM
local tPolicyBranchEraConditions = {
    [GameInfoTypes.POLICY_BRANCH_AESTHETICS] = { DefaultRequirement=GameInfoTypes.ERA_CLASSICAL, SelknamRequirement=GameInfoTypes.ERA_ANCIENT }
}
function SelknamPolicyBranchAffects(iPlayer, iPolicyBranch)
    if tPolicyBranchEraConditions[iPolicyBranch] then
        --print("SelknamPolicyBranchAffects fired for values iPlayer " .. iPlayer .. ", iPolicyBranch " .. iPolicyBranch)
        local pPlayer = Players[iPlayer]
        local iCurrentEra = pPlayer:GetCurrentEra()
        if pPlayer:GetCivilizationType() == iSelknamCiv then
            return (iCurrentEra >= tPolicyBranchEraConditions[iPolicyBranch]["SelknamRequirement"])
        else
           
            return (iCurrentEra >= tPolicyBranchEraConditions[iPolicyBranch]["DefaultRequirement"])
        end
    end
    return true
end
GameEvents.PlayerCanAdoptPolicyBranch.Add(SelknamPolicyBranchAffects)
print(" lua loaded to the end")

Build [/BUILD]

Any help would be much appreciated.
 
If you haven't altered the game rules in the database to allow selection of the policy branch during the ancient era, nothing you do in lua will have any effect.

This is what makes the lua code have an effect in the Allende mod:
Code:
	<PolicyBranchTypes>
		<Update>
			<Where PurchaseByLevel="false" />
			<Set EraPrereq="NULL"/>
		</Update>
	</PolicyBranchTypes>
It sets all policy branches that are not ideology branches to not have any era requirement in the database. Only then can the lua code have any effect.

And if you have the Allende mod running at the same time as your mod, the two will conflict with one another and your lua will likely have no effect because the Allende mod will tell the game "false" for your civ, which will override your code telling the game "true". Ie, one answer of "false" from any lua file in any mod will have the effect of over-riding 90000000000000 answers of "true". Your mod will also interfere with the Allende mod for the Aesthetics policy branch.
 
Back
Top Bottom