Project Zomboid

Project Zomboid

[B42] Cooler Backpack
Bug: Recharge TCM make the Battery stuck
When I tried to recharge TCM-upgraded container (900-ish TCM battery condition), the Battery remaining amount is decreased, then the Battery is stuck. I can't move nor drop the Battery from main inventory. Here is how to recreate the bug:

1. Have a TCM-upgraded container ready, in my case is Base.Cooler
2. Wait for TCM-upgraded container battery condition to decrease
3. Have a Battery in main inventory
4. Recharge TCM-upgraded container
5. The TCM battery replenished, the Battery remaining amount decreased
6. Battery cannot be removed from main inventory

The Battery will not stuck anymore after restarting the game. I haven't tried the case when the TCM battery is fully depleted.
-----

I don't know much about mod technical, but I think this error message can help. It's not directly error on Cooler Backpack mod, but other mod cannot detect the stuck Battery (apparently its become null item). I think there is a problem with "player:getInventory():Remove("Battery");" at line #64.


This mod message happens when I right click the stuck Battery.
Note: the Battery is still stuck when I disabled mods mentioned in message below.

`attempted index: isInCharacterInventory of non-table: null
function: AddContextPutItems -- file: takeAnyAmount.lua line # 156 | MOD: TakeAnyAmount
Callframe at: se.krka.kahlua.integration.expose.MultiLuaJavaInvoker@7e16e449
function: createMenu -- file: WeeezInventoryPaneContextCreateMenu.lua line # 1006 | MOD: Disable context craft
function: onRightMouseUp -- file: ISInventoryPane.lua line # 1459 | Vanilla
java.lang.RuntimeException: attempted index: isInCharacterInventory of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1667)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:624)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:173)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1963)
at se.krka.kahlua.vm.KahluaThread.pcallvoid(KahluaThread.java:1790)
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:72)
at zombie.Lua.LuaEventManager.triggerEvent(LuaEventManager.java:410)
at zombie.Lua.LuaEventManager.triggerEventGarbage(LuaEventManager.java:423)
at zombie.Lua.LuaManager$GlobalObject.triggerEvent(LuaManager.java:4248)
at jdk.internal.reflect.GeneratedMethodAccessor913.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at se.krka.kahlua.integration.expose.caller.MethodCaller.call(MethodCaller.java:62)
at se.krka.kahlua.integration.expose.LuaJavaInvoker.call(LuaJavaInvoker.java:211)
at se.krka.kahlua.integration.expose.MultiLuaJavaInvoker.call(MultiLuaJavaInvoker.java:60)
at se.krka.kahlua.vm.KahluaThread.callJava(KahluaThread.java:192)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:988)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:173)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1963)
at se.krka.kahlua.vm.KahluaThread.pcallBoolean(KahluaThread.java:1902)
at se.krka.kahlua.integration.LuaCaller.protectedCallBoolean(LuaCaller.java:104)
at zombie.ui.UIElement.onRightMouseUp(UIElement.java:1926)
at zombie.ui.UIElement.onRightMouseUp(UIElement.java:1884)
at zombie.ui.UIElement.onConsumeMouseButtonUp(UIElement.java:1698)
at zombie.ui.UIManager.updateMouseButtons(UIManager.java:869)
at zombie.ui.UIManager.update(UIManager.java:728)
at zombie.GameWindow.logic(GameWindow.java:332)
at zombie.GameWindow.frameStep(GameWindow.java:928)
at zombie.GameWindow.run_ez(GameWindow.java:821)
at zombie.GameWindow.mainThread(GameWindow.java:619)
at java.base/java.lang.Thread.run(Unknown Source)
`

-----
Another error message when I try to remove the stuck Battery using debug tool:

`attempted index: DoRemoveItem of non-table: null
function: removeItem -- file: ISRemoveItemTool.lua line # 339 | Vanilla
function: onMouseUp -- file: ISContextMenu.lua line # 90 | Vanilla
java.lang.RuntimeException: attempted index: DoRemoveItem of non-table: null
at se.krka.kahlua.vm.KahluaThread.tableget(KahluaThread.java:1667)
at se.krka.kahlua.vm.KahluaThread.luaMainloop(KahluaThread.java:624)
at se.krka.kahlua.vm.KahluaThread.call(KahluaThread.java:173)
at se.krka.kahlua.vm.KahluaThread.pcall(KahluaThread.java:1963)
at se.krka.kahlua.vm.KahluaThread.pcallBoolean(KahluaThread.java:1902)
at se.krka.kahlua.integration.LuaCaller.protectedCallBoolean(LuaCaller.java:104)
at zombie.ui.UIElement.onMouseUp(UIElement.java:1633)
at zombie.ui.UIElement.onConsumeMouseButtonUp(UIElement.java:1695)
at zombie.ui.UIManager.updateMouseButtons(UIManager.java:869)
at zombie.ui.UIManager.update(UIManager.java:728)
at zombie.GameWindow.logic(GameWindow.java:332)
at zombie.GameWindow.frameStep(GameWindow.java:928)
at zombie.GameWindow.run_ez(GameWindow.java:821)
at zombie.GameWindow.mainThread(GameWindow.java:619)
at java.base/java.lang.Thread.run(Unknown Source)
`
< >
Showing 1-5 of 5 comments
Also I want to ask - a bit curious about the TCM battery indicator. The number is keep ticking down per .01 amount. Will it affect the game performance because the text keep changing with that high frequency?
mikelin1979  [developer] 14 Mar @ 8:17pm 
@rakarukri
Currently this error seems to occur with the take Any Amount mod. I will use this mod to reproduce the error you encountered later and try to figure out which mod is causing it.

In addition, the power calculation method of the previous version was based on the calculation of the food shelf life before deducting the battery usage. This is calculated for each tick, but this method is low performance, and the more food in your TCM backpack, the faster the power consumption.

Last week, we separated the electricity calculation from the food calculation, and had its own independent list when loading the game. It was also changed to calculate every 10 ticks. The current performance is stable.
The battery still stuck even without Take Any Amount nor Disable context craft mod btw. It looks like the problem happens on "player:getInventory():Remove("Battery")" part when calling "TCM_Recharge(item,player)" function.
mikelin1979  [developer] 15 Mar @ 12:06am 
After using Take Any Amount, the Error you mentioned did not appear, but no error occurred.
However, I noticed that the battery was not removed, so there is still a bug.
Update bug info from me:

I tried to recharge the TCM-upgraded container when its battery fully depleted. The Battery used is not stuck, but its also not consumed. The TCM battery is still replenished to the full capacity.
< >
Showing 1-5 of 5 comments
Per page: 1530 50