Page 1 of 1

Read Scriptable Inventory

Posted: Tue Apr 21, 2020 6:07 pm
by Terraya
Hey there!

We are implementing your wonderfull asset very nice into our RPG,

we are going forward to Saving and Loading,

we got a "ScriptableObject - Inventory" which contains already at the Start an Item which is needet for a Quest setup in your Asset, how can i read the Inventory so your System knows what is already inside,

becouse, lets say we got a mission, bring the magical plate to an NPC and at the very Start of the Game, you got the Plate in your Inventory already, so no Gameplay happen yet, how can i tell the Dialogue System[Quest], that we got already the Plate?

Btw. we already released an Early Alpha with your Asset as Dialogue System / Quest System, we had tons of views, testers and so on, thank you alot for saving us so much time with that Asset! :)

Kind regards

Re: Read Scriptable Inventory

Posted: Tue Apr 21, 2020 6:39 pm
by Tony Li
Hi,

You can write a C# method to get the amount of an inventory item. In C#, you could use it similar to this:

Code: Select all

int numPlates = GetInventoryAmount("Magical Plate");
Then you can register it with Lua so you can use it in conversation nodes' Conditions and Script field. In the quest conversation, check if the player already has the plate. If so, follow a different branch of the conversation.

p.s. - If you'd like, please let me know the URL of your game. I'll add it to the Games Showcase page.

Re: Read Scriptable Inventory

Posted: Wed Apr 22, 2020 4:51 pm
by Terraya
Hey Tony!

Thanks alot for your help,

i will try it tomorrow if it work since i was today doing alot of stuff in our Interact System,

our Game is not yet realease ready, we have atm no website for it, just a discord and we
are inside an germany gothic forum where we got alot of feedback,

our discord is: https://discordapp.com/invite/sR6j5R9

there is an Section where you can download it (this friday we will Upload the new version since the Early Alpha was amazing with how much feedback we get , and many bugs were found so we fix them first before we release it, thanks alot :))

Re: Read Scriptable Inventory

Posted: Wed Apr 22, 2020 4:56 pm
by Tony Li
Thanks for the discord link! I'll keep an eye on your project. If you have any questions about the inventory stuff tomorrow, just let me know.

Re: Read Scriptable Inventory

Posted: Thu Apr 23, 2020 7:46 pm
by Terraya
Hey Tony!

So to Load the Data is no problem now thanks alot,

is there any nice and clean way to add the Items to the Quest whenever i pickup something from
a Chest? Also if i drop an Quest Item, do decrease it?

I have 2 Lists with items and i just trade them ,
so , instead of using the Component "Increment on Destroy" from your Tutorial, is there anything i could do in that?

Re: Read Scriptable Inventory

Posted: Thu Apr 23, 2020 8:04 pm
by Tony Li
The Increment On Destroy component increments a DS variable. For example, a quest to find 3 magic spoons could use Increment On Destroy to increment a DS variable named "numSpoons". And you could set a quest entry's text to something like:

Code: Select all

[var=numSpoons]/3 Magic Spoons
After incrementing the variable, Increment On Destroy also sends a message to the quest tracker to update its display.

Instead of using Increment On Destroy, you can use the Lua functions mentioned above. Set the quest entry text to something like:

Code: Select all

[lua(GetInventoryAmount("Magic Spoon")]/3 Magic Spoons
When you pick up or drop a magic spoon, call DialogueManager.SendUpdateTracker() to update the quest tracker's display.