Lua errors not always generating error statements

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
Edit 12 Jan 2013: Problem identified (post #20) and workaround found (post # 23). Or see my Tutorial/Reference here:
How to restore Runtime Error reports for your Lua code



I've produced about 4 bugs in the last day. All of them very mundane stuff: trying to do arithmetic on a nil, accidentally calling pairs(nil), and so forth. They are not being reported in the Fire Tuner or Lua.log. The function just crashes silently. In all cases, I have tracked the error the hard way (print statements and commenting out blocks) and eventually found a common garden variety bug in my code.

I've seen this with either EnableLuaDebugLibrary = 1 or 0. Some bugs are reported. Others not. It's consistent in that the same "pairs(nil)" bug was unreported through the 2 hours I spent tracking it down. But then when I added the same error in a function and called it from Fire Tuner, the error was reported correctly. And errors I type in the command line cause an error statement. Am I going insane? Anyone else seen this or have any ideas?



Edit: No, I'm not insane. Just found another one (Player instead of Players and a missing text field):
Code:
		print("check3")
		--print messege to UI:
		local text = "Travelers tell of a faraway civilization called " .. Locale.ConvertTextKey(eaPlayer.tkEaCiv) .. "..."
		Player[Game.GetActivePlayer()]:AddNotification(NotificationTypes.NOTIFICATION_GENERIC, text, -1, -1)
		print(text)
Fire tuner just prints:
EaMain: check1
EaMain: check2
EaMain: check3
EaMain: -------- New turn for playerID 2 --------

No error statement printed after "check3".

But if I paste that line into the command line (with "test" for text), it reports a Runtime Error.
 
OK, two months on... I'm still seeing this problem. Not always. But often.

I just tracked down another very mundane error. I was calling "local myCity = player:GetCityByID(int)" where player was not defined. The function crashes each time it reaches this, but no error message is ever generated.

Am I the only one having this problem?

Edit: Another one. Had g_City:GetPopulation() when it should have been g_city:GetPopulation().
 
Well you're not alone, just get one, trying unit:GetOwner() with unit not defined...
 
Nice to know I'm not insane.

Lately, it seems like it might be limited to undefined vars calling methods. It may be that this is just the kind of error I'm making though.
 
Here's another silent crash: I was trying to do math on op2.r[g2] when op2.r was not defined.

I'm working under the hypothesis that these unreported errors result when you try to index something that doesn't exist. Method calls are just indexing a table, so unit:GetOwner() is really the same as op2.r[g2] if unit and op2.r don't exist.

Right now I'm keeping track to see if this situation exactly defines the problem. I.e., is this the only thing that causes an unreported error? Does this situation always cause an unreported error?

I'm almost positive this started with the pre-G&K patch. It doesn't seem to matter whether I have EnableLuaDebugLibrary enabled or not.
 
Really? Only two of us have noticed this problem?

I can't imagine that other Lua modders here wouldn't notice this problem after a while, unless all of you write bug-free code somehow. Should I take it that there is something specific in my (and Gedemon's) installation that is bugged?

I still haven't learned much. Just now I noticed that a particular function displays the error when called from one state (UnitPanel) but crashes silently when called from another state (EaMain, the state for all my non-UI Lua). Same exact args in both cases. Both called by LuaEvents (the function itself is in another UI state). I wonder if there is something buggered about my mod's Lua state?
 
I noticed it too, in my mod I use LUA code that limits the number of cities where certain buildings can be built to to a given percentage of all your cities (using a new column in the BuildingClasses table called EoM_MaxCityPercent):

Spoiler :
Code:
GameEvents.PlayerCanConstruct.Add (
function (iPlayer, buildingTypeID)
	-- get the player object
	local player = Players [iPlayer]
	-- get the building class ID
	local classID = GameInfo.BuildingClasses [GameInfo.Buildings [buildingTypeID].BuildingClass].ID;
	-- get the maximum cities percentage
	local percent = GameInfo.BuildingClasses [classID].EoM_MaxCityPercent
	-- check the number of buildings
	if percent > 0 and percent < 100 then
		local limit = math.floor (percent * player:GetNumCities () * 0.01) -- maximum number of buildings of this class
		local number = player:GetBuildingClassCountPlusMaking (classID) + 1 -- number of buildings of this class (existing and under construction), plus the one we're asking for
		if number > limit then
			return false -- too many
		else
			return true -- not too many, can build at least one more
		end
	else
		return true -- no limit defined (not between 0 and 100), so allow it
	end
end)

At first I made a mistake, and typed getBuildingClassCountPlusMaking instead of GetBuildingClassCountPlusMaking, and the code failed without any error messages in lua.log. I spent quite a lot of time trying to identify the source of the problem...
 
Has anyone had any progress on this issue as I am also going nuts trying to debug errors that are not being reported.

Right now I am using countless print statements to see what values are being used and which one is causing a nil error!
 
No solution from me.

I can't believe more modders aren't screaming bloody murder about this. I doubt that Firaxis is even aware of it. (I'm pretty sure it started with the pre-G&K patch.)

I don't even know how to report a bug to Firaxis...they don't look at the 2K bug thread as far as I can tell.
 
Aghhh...

I'm still seeing this, and it's still a giant time-sink. The only pattern I've observed is that (as far as I remember) I've never had this happen for a modded UI Lua file. This leads me to wonder if entrypoint matters. Maybe using InGameUIAddin somehow messes up state info for error logging?

Are modders using InGame.lua rather than InGameUIAddin seeing this problem? whoward69?
 
I feel your pain. The most stupid unreported bug that had me searching way too long was using "+" for string concatenation instead of ".."; old habits die hard.
 
If I'm having trouble with a block of code, I just put print statements between each line. Wherever it stops printing, that's where the trouble is. Every time I've had a silent crash like this, the rest of the function has not executed at all, so diagnosis via lots of print statements has worked.
 
If I'm having trouble with a block of code, I just put print statements between each line.

Yes but this gets rather cumbersome in a mod with >10000 lines of Lua code. It's hard to spot something that isn't there in 1000s of lines of print, especially if the error condition is rare.

It's also rather a drag for those of us modding before the pre-G&K patch when error reporting worked reliably (I'm 95% sure this problem never happened before then). One gets used to these things and then they are hard to live without...

I did write a Lua function called DebugFunctionExitTest to deal with this for new or commonly buggy functions. Works for simple stuff that is not called recursively:

Usage:
Code:
function MyBuggyFunction(iPlayer)
	DebugFunctionExitTest("MyBuggyFunction", true)

	if bSomeExitCondition then
		DebugFunctionExitTest("MyBuggyFunction", false)
		return
	end
	DebugFunctionExitTest("MyBuggyFunction", false)
end

Code:
Code:
local debugExitTest = {}
function DebugFunctionExitTest(functionName, bStart)
	if bStart then
		if debugExitTest[functionName] then
			for i = 1, 20 do
				print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
			end
			print("!!!! ERROR: Function  was not previously exited properly: ", functionName)
		end
		debugExitTest[functionName] = true
	else
		debugExitTest[functionName] = false
	end

end

Still, I'd much prefer to have reliable error reporting back. Or to know if there is something I can do that will give it back to me.
 
Not seeing a lot of these, but then I write and test as much Lua as possible outside of ModBuddy, and then test most functions direct from the FireTuner console before testing in game anyway.

Just wondering, is there a difference between error reporting in named and anonymous functions?

ie

Code:
function OnEvent()
  -- do something
end
LuaEvents.MyEvent.Add(OnEvent)

vs

Code:
LuaEvents.MyEvent.Add(function ()
  -- do something
end)

BTW the second one is inefficient and really should be avoided, despite the fact that Firaxis use it everywhere!
 
I'm definitely seeing errors in named functions, which were called by named functions called by named functions. Most of it ultimately leads back to this:

Code:
function OnEveryPlayerTurn(iPlayer)

end
GameEvents.PlayerDoTurn.Add(OnEveryPlayerTurn)

To the best of my memory, it is possible that all of the unreported errors trace back to that loop. In fact, I did observe one error that was reported when the buggy function was called by LuaEvent (from some UI state), but not when the call traced back to my OnEveryPlayerTurn loop above. And the errors always seem to be reported if I call the specific function from the Fire Tuner.

I also have many anonymous functions in my mod, mostly added to other GameEvents or Events. I don't think I've ever had a silent error in these, but I'm not 100% sure (well... I'm not sure that I ever made an error in these that needed reporting).


Off topic... but to follow up on your off topic comment above:

Is this:
Code:
GameEvents.PlayerCanConstruct.Add(function(iPlayer, buildingTypeID)
end)
less efficient than this
Code:
function ReqPlayerCanConstruct(iPlayer, buildingTypeID)
end
GameEvents.PlayerCanConstruct.Add(ReqPlayerCanConstruct)
???
 
Off topic... but to follow up on your off topic comment above:

Is this:
Code:
GameEvents.PlayerCanConstruct.Add(function(iPlayer, buildingTypeID)
end)
less efficient than this
Code:
function ReqPlayerCanConstruct(iPlayer, buildingTypeID)
end
GameEvents.PlayerCanConstruct.Add(ReqPlayerCanConstruct)
???

See test #8 of http://trac.caspring.org/wiki/LuaPerformance
 
Interesting. I'd seen that comparison, but I didn't recognize that this was an example of it. So a named function is localized to ... what? Not the file, since it can be called anywhere in the same state. I often localize functions in functions if it will be called repeatedly in a loop. But I didn't realize that an anonymous function was somehow less localized than a named function. Or am I missing the point entirely?
 
At a guess "Add(function () end)" is having to generate a closure every time, whereas "function this() end; Add(this)" is generating the named closure once when the file is first executed.

But a) its a very long time since I studied "Translators And Run-Time Systems" (aka the TARTS course) at Uni and b) I suspect things have moved on since then!
 
Have any C++/dll moders had any insight on this?

I keep thinking it has something to do with how the dll calls GameEvents or maybe GameEvents.PlayerDoTurn specifically. I say this based on the (slightly uncertain) observation that it only happens with functions that are ultimately called from a GameEvents.PlayerDoTurn function. I've had a few errors in utility functions that always print an error when called from somewhere else (for example, from another UI state via LuaEvents). But most of my mod runs from GameEvents.PlayerDoTurn and the majority of errors go unreported. (Perhaps even all errors. I know I've seen errors on per turn stuff but they may have been downstream of LueEvents calls.)

If you compile code in Lua it is possible to not have error reports if you do this:
Code:
local f = loadfile(filename)
instead of this
Code:
local f = assert(loadfile(filename))
I know that the dll isn't compiling Lua during runtime, but is there any kind of analogous situation (report vs not report) in the way the dll calls GameEvents?

(Edit: Or does the dll compile the Lua???)
 
OK, I decided to test this in a more systematic way. Here's my code:
Spoiler :
Code:
function OnLoadScreenClose()
	print("Calling BuggeredFunction from OnLoadScreenClose")
	BuggeredFunction()
end
Events.LoadScreenClose.Add(OnLoadScreenClose)

function OnSerialEventGameDataDirty()
	print("Calling BuggeredFunction from OnSerialEventGameDataDirty")
	BuggeredFunction()
end
Events.SerialEventGameDataDirty.Add(OnSerialEventGameDataDirty)

function OnSerialEventUnitInfoDirty()
	print("Calling BuggeredFunction from OnSerialEventUnitInfoDirty")
	BuggeredFunction()
end
Events.SerialEventUnitInfoDirty.Add(OnSerialEventUnitInfoDirty)

function OnPlayerCityFounded()
	print("Calling BuggeredFunction from OnPlayerCityFounded")
	BuggeredFunction()
end
GameEvents.PlayerCityFounded.Add(OnPlayerCityFounded)

function OnSetPopulation()
	print("Calling BuggeredFunction from OnSetPopulation")
	BuggeredFunction()
end
GameEvents.SetPopulation.Add(OnSetPopulation)

function OnTeamMeet()
	print("Calling BuggeredFunction from OnTeamMeet")
	BuggeredFunction()
end
GameEvents.TeamMeet.Add(OnTeamMeet)

function OnGetScenarioDiploModifier1()
	print("Calling BuggeredFunction from OnGetScenarioDiploModifier1")
	BuggeredFunction()
end
GameEvents.GetScenarioDiploModifier1.Add(OnGetScenarioDiploModifier1)

function OnPlayerDoTurn(iPlayer)
	if iPlayer % 2 == 0 then		--is even?
		print("Calling BuggeredFunction from OnPlayerDoTurn; game turn = ", Game.GetGameTurn())
		BuggeredFunction()
	else
		print("Calling BuggeredFunction via LuaEvents; game turn = ", Game.GetGameTurn())
		LuaEvents.BuggeredFunctionFromLuaEvent()
	end
end
GameEvents.PlayerDoTurn.Add(OnPlayerDoTurn)


--------------------------------------------------------------
--------------------------------------------------------------
function BuggeredFunction()
	print("Running BuggeredFunction. You should now see an error...")
	nonexistentObject:NonexistentMethod()
	print("This will never print")
end
LuaEvents.BuggeredFunctionFromLuaEvent.Add(BuggeredFunction)
--------------------------------------------------------------
--------------------------------------------------------------
And here's some sample output:
Spoiler :
Code:
 EaMain: Calling BuggeredFunction from OnLoadScreenClose
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 TechTree: REFRESHING TECH DISPLAY
 EaMain: Calling BuggeredFunction from OnSerialEventGameDataDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 TechTree: REFRESHING TECH DISPLAY
 EaMain: Calling BuggeredFunction from OnSerialEventGameDataDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventGameDataDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 TechPopup: stealingTechTargetPlayerID: -1
 TechPopup: iValue: 0
 TechTree: REFRESHING TECH DISPLAY
 EaMain: Calling BuggeredFunction from OnSerialEventGameDataDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 WorldView: WorldView InputHandler 	false
 WorldView: WorldView InputHandler 	false
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 WorldView: WorldView InputHandler 	false
 WorldView: WorldView InputHandler 	false
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 ActionInfoPanel: OnEndTurnClicked iPlayer=	0
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSetPopulation
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerCityFounded
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerDoTurn; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...


 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventGameDataDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 TurnProcessing: Hiding TurnProcessing
 WorldView: WorldView InputHandler 	false
 WorldView: WorldView InputHandler 	false
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 ActionInfoPanel: OnEndTurnClicked iPlayer=	0
 EaMain: Calling BuggeredFunction via LuaEvents; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerDoTurn; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction via LuaEvents; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerDoTurn; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction via LuaEvents; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerDoTurn; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction via LuaEvents; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerDoTurn; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction via LuaEvents; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerDoTurn; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction via LuaEvents; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction via LuaEvents; game turn = 	1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnPlayerDoTurn; game turn = 	2
 EaMain: Running BuggeredFunction. You should now see an error...


 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventGameDataDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 WorldView: WorldView InputHandler 	false
 WorldView: WorldView InputHandler 	false
 EaMain: Calling BuggeredFunction from OnGetScenarioDiploModifier1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnGetScenarioDiploModifier1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnTeamMeet
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 TurnProcessing: Hiding TurnProcessing
 EaMain: Calling BuggeredFunction from OnGetScenarioDiploModifier1
 EaMain: Running BuggeredFunction. You should now see an error...
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Calling BuggeredFunction from OnSerialEventUnitInfoDirty
 EaMain: Running BuggeredFunction. You should now see an error...
 Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
And from the Live Tuner panel:
Spoiler :
Code:
> BuggeredFunction()
Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Running BuggeredFunction. You should now see an error...
> LuaEvents.BuggeredFunctionFromLuaEvent()
Runtime Error: [string "C:\Users\Pazyryk\Documents\My Gam..."]:98: attempt to index global 'nonexistentObject' (a nil value)
 EaMain: Running BuggeredFunction. You should now see an error...

Result: Whether or not I get a Runtime Error report depends on what particular C++ is calling the Lua that has the error.

Ways that consistently do give me a Runtime Error report:
Live Tuner (direct call to bugged function or indirect via LuaEvents)
Events.LoadScreenClose
Events.SerialEventUnitInfoDirty
Events.SerialEventGameDataDirty

Ways that consistently don't give me a Runtime Error report:
GameEvents.SetPopulation
GameEvents.PlayerCityFounded
GameEvents.TeamMeet
GameEvents.GetScenarioDiploModifier1
GameEvents.PlayerDoTurn (direct call to bugged function or indirect via LuaEvents)

Tentative Conclusion:
All(?) GameEvents are bugged and fail to assert any errors from downstream Lua. I'd be much obliged if someone independently tests this theory to either support or disprove it. I'd be even much more obliged if someone makes a dll fix (sorry, I don't know C++ yet...). Perhaps we are "lucky" that the bug is in GameEvents and not Events, since we have access to the former.

Edit: I don't suppose anyone has the vanilla dll from before and after the "pre-G&K" patch. I'm 90% sure that's when the bug was introduced.
 
Back
Top Bottom