Why this script crashes?

A forum to discuss custom scenarios, campaigns and modding in general.

Moderators: Slitherine Core, The Lordz

Post Reply
Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 137
Joined: Wed Nov 27, 2013 3:27 pm

Why this script crashes?

Post by Kossatx » Wed May 15, 2019 11:29 am

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

Robotron
Lieutenant Colonel - Panther D
Lieutenant Colonel - Panther D
Posts: 1236
Joined: Tue Nov 23, 2010 3:35 pm

Re: Why this script crashes?

Post by Robotron » Wed May 15, 2019 12:34 pm

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.
Slitherine's Commander the Great War on steroids: POTZBLITZ mod!
http://www.slitherine.com/forum/viewtopic.php?f=218&t=77884&p=662610#p662610

Kossatx
Administrative Corporal - SdKfz 251/1
Administrative Corporal - SdKfz  251/1
Posts: 137
Joined: Wed Nov 27, 2013 3:27 pm

Re: Why this script crashes?

Post by Kossatx » Thu May 16, 2019 10:20 pm

Thanks Robotron! :mrgreen:

Post Reply

Return to “Commander the Great War : Mods & Scenario Design”