Custom Inventory System & Quest System's Lua Environment
Posted: Thu Dec 01, 2022 3:39 pm
Hi Pixel Crushers.
I'm trying to do the Quest tutorial in my own project with my own assets, and I'm having a small problem. I have an inventory system that stores InventoryItem class objects in an array of InventorySlot structs in an Inventory monoBehaviour that's attached to the player. Now, I've set up a quest that asks for the player to pick up a certain number of objects (they exist solely in a distinct storage inventory).
Now I'm not sure how to reference them, how to check if the Inventory contains the Quest item. Since I can't pass to Lua the InventorySlot and also not the InventoryItem. The InventoryItems have a GUID field, I thought about the following method:
The problem is that then I need to Dialogue System to know about all the GUIDs, and I'm not sure how to do that. I do have a static dictionary<string, InventoryItem> that contains all the items and looks them up with a GUID but I don't know how to pass it not by hand to the Variable database or in general how to be able to reference it more easily in the Dialogue editor. What would you suggest? An alternative would be probably to look by name.
I'm trying to do the Quest tutorial in my own project with my own assets, and I'm having a small problem. I have an inventory system that stores InventoryItem class objects in an array of InventorySlot structs in an Inventory monoBehaviour that's attached to the player. Now, I've set up a quest that asks for the player to pick up a certain number of objects (they exist solely in a distinct storage inventory).
Now I'm not sure how to reference them, how to check if the Inventory contains the Quest item. Since I can't pass to Lua the InventorySlot and also not the InventoryItem. The InventoryItems have a GUID field, I thought about the following method:
Code: Select all
#region Methods For Dialogue System LUA Environment
public double HasAmountOfItem(string GUID) //return double for LUA
{
for (var i = 0; i < slots.Length; i++)
{
if (slots[i].item.GetItemID() == GUID)
{
return slots[i].number;
}
}
return 0;
}
// LUA Registration
#endregion
The problem is that then I need to Dialogue System to know about all the GUIDs, and I'm not sure how to do that. I do have a static dictionary<string, InventoryItem> that contains all the items and looks them up with a GUID but I don't know how to pass it not by hand to the Variable database or in general how to be able to reference it more easily in the Dialogue editor. What would you suggest? An alternative would be probably to look by name.