EDIT: MODS! I HAVE REWRITTEN THE ENTIRE CODE FOR THE MOD I WAS MAKING SO THIS IS NO LONGER RELEVANT, PLEASE DELETE.
I can't understand what's wrong with this part of the code, maybe someone more experienced in modding and coding can give me a hand.
[spoiler][code]
local function checkTraits() --Line69
if not player:HasTrait("Cowardly") and not player:HasTrait("Agoraphobic") and not player:HasTrait("Claustophobic") and not player:HasTrait("Hemophobic") then --Line70
becomeDesensitized(); --Line71
return; --Line72
end --Line73
end --Line74
Events.EveryHours.Add(checkTraits);
[/code][/spoiler]
This is the ERROR log:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function: checkTraits -- file: NewFeatLostOverTimePlusDesensitized.lua line # 70
ERROR: General , 1658199009328> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: attempted index: HasTrait of non-table: null at KahluaThread.tableget line:1689.
ERROR: General , 1658199009328> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: attempted index: HasTrait of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1689)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:641)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:163)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1980)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1812)
at se.krka.kahlua.integration.LuaCaller.pcallvoid(LuaCaller.java:66)
at se.krka.kahlua.integration.LuaCaller.protectedCallVoid(LuaCaller.java:139)
at zombie.Lua.Event.trigger(Event.java:64)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:65)
at zombie.GameTime.update(GameTime.java:542)
at zombie.gameStates.IngameState.UpdateStuff(IngameState.java:564)
at zombie.gameStates.IngameState.updateInternal(IngameState.java:1659)
at zombie.gameStates.IngameState.update(IngameState.java:1369)
at zombie.gameStates.GameStateMachine.update(GameStateMachine.java:101)
at zombie.GameWindow.logic(GameWindow.java:297)
at zombie.core.profiling.AbstractPerformanceProfileProbe.invokeAndMeasure(AbstractPerformanceProfileProbe.java:71)
at zombie.GameWindow.frameStep(GameWindow.java:764)
at zombie.GameWindow.run_ez(GameWindow.java:666)
at zombie.GameWindow.mainThread(GameWindow.java:494)
at java.base/java.lang.Thread.run(Unknown Source)
LOG : General , 1658199009330> -----------------------------------------
STACK TRACE
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Initially I had 7 Traits on line 70, but reduced it to 4 thinking they were conflicting, which was not the case, I still get the error. Probably it's something simple and straight forward, but I've been staring and that few lines of code for so long I can't find it. Any help would be appreciated.
Events.EveryHours.Add(checkTraits); will be changed to Events.EveryDays.Add(checkTraits); - Hourly checks are just easier to test.