Read Scriptable Inventory

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Terraya
Posts: 19
Joined: Sat Feb 01, 2020 5:22 pm

Read Scriptable Inventory

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

Re: Read Scriptable Inventory

Post 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.
Terraya
Posts: 19
Joined: Sat Feb 01, 2020 5:22 pm

Re: Read Scriptable Inventory

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

Re: Read Scriptable Inventory

Post 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.
Terraya
Posts: 19
Joined: Sat Feb 01, 2020 5:22 pm

Re: Read Scriptable Inventory

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

Re: Read Scriptable Inventory

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