Code: Select all
function CheckVictory()
local currentPlayer = GetCurrentPlayer() -- Get the current player
if currentPlayer == 0 then -- Only check victory for allied player
local turn = GetCurrentTurn() -- Get the current turn number
if turn > 5 then -- Check if it's after turn 5
local hexesToCapture = { -- Specify the victory hexes to capture
{ x = 50, y = 32 },
{ x = 50, y = 24 },
{ x = 59, y = 12 }
}
local capturedHexes = 0
for i, hex in ipairs(hexesToCapture) do
if IsHexCaptured(hex.x, hex.y, currentPlayer) then
capturedHexes = capturedHexes + 1
end
end
if capturedHexes ~= #hexesToCapture then
SetPlayerLoss(currentPlayer) -- Set the player as defeated if not all victory hexes are captured
end
else
SetPlayerLoss(currentPlayer) -- Set the player as defeated if it's after turn 5
end
end
end
function IsHexCaptured(x, y, player)
local hex = GetHex(x, y) -- Get the hex at coordinates (x, y)
if hex then
local occupier = GetHexOccupier(hex)
if occupier and occupier:GetPlayer() == player then
return true -- Hex is captured by the player
end
end
return false -- Hex is not captured by the player
end
When I put function "IsHexCaptured" as the "Condition" I get error: "74: attempt to call a nil value (global 'GetHex')"
In the editor I have the "Actions" set to "StartTurnAction"
Any ideas how to get this working?