Page 1 of 1

Sync Lua and AC Inventories bug

Posted: Tue Jun 02, 2015 5:50 pm
by jackallplay
I believe I found (and fixed) a bug in AdventureCreatorBridge.cs. Specifically in functions SyncInventoryToLua and UpdateAdventureCreatorItem.

In my scenario, I had 3 items in my inventory. Combining the 1st and 2nd item by dragging one onto another leaves the first two slots empty and places the newly created item in the 4th slot. I then make an action call to collapse the inventory menu with animation and wait for it to finish. Once finished, I attempt to display a piece of dialogue. The dialogue triggers a sync call between AC and Lua, which is where the problem occurs.

Since the first two slots are empty, the following line fails in SyncInventoryToLua. Calling Find on a List with null items appears to be the cause of this failure.

Code: Select all

InvItem runtimeItem = runtimeInventory.localItems.Find(x => x.id == item.id);
I simply replaced that line with the following to fix the problem.

Code: Select all

InvItem runtimeItem = runtimeInventory.GetItem(item.id);
The second instance of the bug is nearly identical and it occurs in UpdateAdventureCreatorItem.

Replace

Code: Select all

InvItem item = runtimeInventory.localItems.Find(x => x.id == itemID);
With

Code: Select all

InvItem item = runtimeInventory.GetItem(itemID);
The fix works fine for me. Hope it's a valid way to deal with this issue.

Jack

Re: Sync Lua and AC Inventories bug

Posted: Wed Jun 03, 2015 12:01 pm
by Tony Li
Hi,

Thanks for posting that. This is indeed a bug, and your fix appears to be spot on. I'll incorporate it into the next release!