Page 1 of 1

Why this script crashes?

Posted: Wed May 15, 2019 11:29 am
by Kossatx
The part for austria in this script crashes and I don't know why, anyone can help me to fix it?

Code: Select all

local germany = game:GetFactionById(2)
local austria = game:GetFactionById(3)

local berlin = GetHex(101, 22)
local budapest = GetHex(108, 33)

if GetEvent("FortressGarrisons") == 0 then

	if berlin.alliance.id == 0
	and germany.alliance.id == 0
	and berlin.unit == nil  then
	SpawnUnit(0, germany, 101, 22, 0, 100)
	germany:ConsumeManpower(10)
	end

	if austria.alliance.id == 2
	and budapest.alliance.id == 2 then
		local hexes = game.map:GetHexesInRange(budapest, 4)
		for _, hex in pairs(hexes) do
		if hex.unit ~= nil 
		and hex.unit.faction.alliance.id == 1
		and hex.unit.type == Unit.LAND then
		SpawnUnit(0, austria, 108, 33, 0, 100)
		austria:ConsumeManpower(10)
		end
	end
end

Re: Why this script crashes?

Posted: Wed May 15, 2019 12:34 pm
by Robotron
The script is not properly closed!

An "end" is missing at the end. :wink:

Use notepad++ to edit scripts, it will show you whether functions/loops/statements etc. are properly closed.

Re: Why this script crashes?

Posted: Thu May 16, 2019 10:20 pm
by Kossatx
Thanks Robotron! :mrgreen: