Craig_Sutter
Deity
This is just a short bit of code to return money and withdraw faith for units designated religious. Line with error is colored red in the code.
This is using Machiavelli's unit created event code... I have used it numerous times and have not had any problems with it... but this instance is proving to be problematic.
Error in log (repeated many many times):
[1254763.855] Runtime Error: C:\Users\doms\Documents\My Games\Sid Meier's Civilization 5\MODS\The Viking Age for BNW (v 3)\LUA/Units.lua:116: attempt to index local 'city' (a nil value)
and code:
Thank-you in advance.
This is using Machiavelli's unit created event code... I have used it numerous times and have not had any problems with it... but this instance is proving to be problematic.
Error in log (repeated many many times):
Spoiler :
[1254763.855] Runtime Error: C:\Users\doms\Documents\My Games\Sid Meier's Civilization 5\MODS\The Viking Age for BNW (v 3)\LUA/Units.lua:116: attempt to index local 'city' (a nil value)
and code:
Code:
--converts gold cost of religious units to faith amount
function faithpurchase( iPlayer, iUnit )
local player = Players[iPlayer]
local unit = player:GetUnitByID( iUnit )
local plot = unit:GetPlot()
local city = plot:GetPlotCity()
[COLOR="Red"]local cost = city:GetUnitPurchaseCost(iUnit)[/COLOR]
local iBer_Warrior = GameInfoTypes.UNIT_BERSERKER_WARRIOR
local iBerserker = GameInfoTypes.UNIT_BERSERKER
if iUnit == iBer_Warrior or iUnit == iBerserker then
player:ChangeGold( cost )
player:ChangeFaith(-(2*cost))
end
end
LuaEvents.SerialEventUnitCreatedGood.Add( faithpurchase )
Thank-you in advance.