edited August 2020 in ORK Support
Hello, I'm trying to check player inventory for a given item, but the item name shall be defined by given variable.

Use case:
To open the doors, player need to have relevant key in his inventory.

Solution #1 I'm trying to implement now:
Each "Doors" object have "key_name" variable in it's Object variables, defining the name of the Key needed to open the doors. Then in a Game Event, I'm using "Has In Inventory" node to check if an item of the given name is present in the inventory or not.

Issue:
I'm able to read the Object variable successfully, but "Has In Inventory" node is always returning "Failed", never "Success" (despite the item named "Rusty key" is present in the Player inventory).
image
https://drive.google.com/file/d/1s2sM5tNSeflJCJRFqgrJa_77eeHw2cV3/view?usp=sharing

To make it super-simple, I even tried to set the variable value manually - see the screenshot. Still no hit.
image
https://drive.google.com/file/d/1HRqM5WBHoffN6Z1zL2rMejXRe40vz-tx/view?usp=sharing

When I select the item manually (not using selected data) then it works, but in such case I would need dedicated Game Event for each Doors - absolutelly no way.


What I'm doing wrong?
Variable settings in "Has In Inventory" seems a bit odd...


Thank you in advance for your support!


Bonus: solution #2 (wanted):
Better, I would like to check the inventory items based on it's name and also Item Variables, so I could have many keys with the same name ("Key"), /but of different prefab = colour, shape, etc../ and use each Item Variables to link them to the relevant doors.
Post edited by Riffage on
  • Yeah .. that's now how it works :)
    You're checking for items that are stored in selected data.

    I think the best solution would be to check the variables in your event and check for the according item via the Has In Inventory node (i.e. selecting the item there).
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • Thank you for the hint, I'll check that out!
  • Hello,
    I tried, but with no success - seems I still do not understand how to use the "Selected data".

    If I understand propperly, than you recommended me to:
    1. put all the items in the inventory into the Selected data (using Select Item node)
    2. search for the item in the Selected data

    OR shall I :
    1. put the Game Object (Door) to the Selected data (using Select Game Object node)
    2. search for the item in the Player inventory using key name as stored in Selected data Object.

    ???

    I'm simply failing...

    Just to remind the use case:
    In the event, I do not know upfront which item I'm looking for, so I cannot "hard wire" it. The item name I'm looking for is dynamically set as a value in the Object variables. This differs from the case in the tutorial example Event, where there are branches for all 3 possible items (Weapon ATK+1, Weapon ATK+5, Weapon ATK+10). I cannot use such branching, having too many different items (doors and door keys in my case).

    Practical example of the use case:
    - I have 100 doors and I have also 100 unique keys (defined by name)
    - In Object variable "key_name" I define name of the key which matches the particular door
    - when trying to open the door, I execute Game Event which shall check if adequate key (as defined in "key_name" of the Event object) is present in the Player's inventory

    Could you please support?
    Might you need me to send you my Event file, or some screenshots, please let me know...
    TY!

    Side note: also, strange thing is that when I create new item, scene object etc in ORK framework, the name of the element is registerred in the secondary language, not in English. I'm afraid I messed up something when I was adding the second language... (?)
  • For this to work, you need to have the key name also available on the key items as an item variable.

    Use a Select Item node and use it's filter option to select an item with a matching key name (variable). You can only use global string variables for the value in those checks, though, so you first have to transfer the door's object variable to a global variable for the check using a Variable To Variable node.

    So, in short:
    - use a Variable To Variable node to store the door's object variable key_name into a global variable (e.g. same key key_name)
    - use a Select Item node to get all items that pass a filter check, checking for the key_name item variable using the previously stored value
    - use a Selected Data Count node to check if anything was added to the list in the previous node (e.g. checking greater than 0)
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
  • This way it sounds clear to me !
    I'll try it ... :-)

    Thank you!
Sign In or Register to comment.