Sync Lua and AC Inventories bug

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jackallplay
Posts: 1
Joined: Tue Jun 02, 2015 5:34 pm

Sync Lua and AC Inventories bug

Post 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
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Sync Lua and AC Inventories bug

Post 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!
Post Reply