Need help with a Lua error

Hulfgar

Emperor
Joined
Mar 31, 2008
Messages
1,798
Location
France
Hi all,

does somebody know what could cause this error message :

[62188.363] Runtime Error: Assets\DLC\Expansion2\UI\InGame\Popups\ProductionPopup.lua:378: attempt to perform arithmetic on local 'eraPriority' (a nil value)

The effect is that clicking on the production button either in the city view or from the world view will have no result.

I have modified and reorganized the tech tree but I kept all the vanilla Eras and it's working fine.
More troubling : I have 2 versions of the mod : the 1st does not have this bug, the 2nd is identical at 90% with some of the endgame techs disabled but has this bug and I don't see why.


Thanks for any help.
 
It's literally written that you are trying do some math on local variable called "eraPriority", while this variable is equal to nil (nothing).

Hints:
1. Go to 378 line.
2. Find where you declare eraPriority, if not: why it is used in line 378?
3. Think out why it is stated a nil.
4. Send us whole LUA code if you can't solve it.

Oh, you didn't change lua? Then ignore point 4.

Code:
	function GetUnitSortPriority(unitInfo)
		local eraPriority = 0;
		if(unitInfo.PrereqTech ~= nil) then
			[COLOR="Red"]eraPriority = erasByTech[unitInfo.PrereqTech];[/COLOR]
		end
	
		if(unitInfo.CivilianAttackPriority ~= nil) then
			if(unitInfo.Domain == "DOMAIN_LAND") then
				return eraPriority;
			else
				return eraPriority + 1000;
			end
		else
			if(unitInfo.Domain == "DOMAIN_LAND") then
				return eraPriority + 2000;
			else
				return eraPriority + 3000;
			end
		end	
	end
Here it must becomes nil. Now, you are interested in "erasByTech" table.

Code:
	for row in GameInfo.Technologies() do
		erasByTech[row.Type] =  (eraIDs[row.Era] + 10);
	end
I would risk a statement that your new technology/ies is not included in GameInfo.Technologies(). That's why there is no value for erasByTech[yourTechnology.Type].
 
I am not an expert, but if you disabled late game techs, I think there is a solution:

Disable units with prereq tech you disabled.

What happens:
On game start/loading (dunno), all technologies have declared erasByTech value.
Deleted techs obviously don't have it.
Then game checks every unit and finds a unit with prereq tech you deleted, aks for erasByTech value and recieve nil.
 
I will try this, it sounds logical when you state it, I didn't though that the game would check so much at start.

I don't have deleted the tchs but i disabled them which is perhaps the same for what you described.

Anyway : I'm going to disable the units see what happens and keep you informed.

Thanks :)
 
Disabling the units bound to disabled techs did it.

Thanks LastSword, you saved my day :)
 
Back
Top Bottom