How to use Lua in Civ 6 to disable a unit, building or project for a certain Civilization

flyinghorse301

Chieftain
Joined
Nov 26, 2011
Messages
24
Hi all,

In Civ 5, I used the below Lua to disable a unit or project for a particular Civ. But it no longer works in Civ 6. Does anyone know how to convert it to Civ 6?

Code:
--To disable a project
function Manhattan(playerID, projectTypeID)
    print("playerID", playerID);
    print("projectTypeID", projectTypeID);
    if GameInfo.Projects[projectTypeID].Type == "PROJECT_MANHATTAN_PROJECT" then
        print(GameInfo.Projects[projectTypeID].Type);
        if ( Players[playerID]:GetCivilizationType() == GameInfo.Civilizations["CIVILIZATION_YYYYY"].ID ) then
            print("false");
            return false;
        else
            print("true");
            return true;
        end
    else
        print("others");
        return true;
    end
end
GameEvents.PlayerCanCreate.Add( Manhattan );

--To disable a unit
function DisableUnitXXXXX(playerID, unitTypeID)
    if GameInfo.Units[unitTypeID].Type == "UNIT_XXXXX" then
        if ( Players[playerID]:GetCivilizationType() == GameInfo.Civilizations["CIVILIZATION_YYYYY"].ID ) then
            return false;
        else
            return true;
        end
    else
        return true;
    end
end
GameEvents.PlayerCanTrain.Add( DisableUnitXXXXX );
 
Back
Top Bottom