Sync Lua and AC Inventories bug
Posted: Tue Jun 02, 2015 5:50 pm
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.
I simply replaced that line with the following to fix the problem.
The second instance of the bug is nearly identical and it occurs in UpdateAdventureCreatorItem.
Replace
With
The fix works fine for me. Hope it's a valid way to deal with this issue.
Jack
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);
Code: Select all
InvItem runtimeItem = runtimeInventory.GetItem(item.id);
Replace
Code: Select all
InvItem item = runtimeInventory.localItems.Find(x => x.id == itemID);
Code: Select all
InvItem item = runtimeInventory.GetItem(itemID);
Jack