Inventory Requirement Filter (Basic Mode)

PACKAGE: Inventory Requirement Filter

Search for and install Inventory Requirement Filter from the Community tab.

DESCRIPTION

Enables verifying a player has a partiular item in their inventory. It is also possible to specify how many that are required. By default, the items are consumed (removed from player inventory), but that can be turned off for re-usable items. If they have the item in their inventory a pass-event will be fired, and if they do not, a fail-event will be fired.

Note: This package requires the official Crayta package Inventory.

Note: This package can be used in basic mode.

USAGE

Use of this script requires that you already have a script that can perform an action on. Below follows an example for how to do this, but you can use the script for many other things, such as only opening a chest if the user has a key.

  1. Install the official Crayta package Inventory, and set it up. If you use for example the Adventure game template it is already set up for you.
  2. Install the Inventory Requirement Filter package.
  3. Install the official Crayta package Door.
  4. Drag a door Mesh into your environment.
  5. Edit the door Mesh, and add the doorScript to your door entity. doorscript-simple
  6. Add the inventoryRequirementFilterScript to your door entity.
  7. In the inventoryRequirementFilterScript, set inventoryTemplateRequirement to a particular item from your inventory.
  8. In the inventoryRequirementFilterScript, set onFilteredEventPass to invoke the doorScript of your door entity, and select doorScript in the Script field. And lastly, select SetOpen in the Event field.
  9. Edit the onInteract field of the entity itself and set Entity equal to your door, Script equal to the inventoryRequirementFilterScript, and Event to FilterEventForPlayer. filterscript-door-simple

This will enable your players to interact with your door. If they do not have the required item, nothing will happen, but if they do have it, the door will open.

SETTINGS

  • inventoryTemplateRequirement: Which item to look for in the player inventory.
  • count: How many of the specified item to require.
  • consumeItems: Whether to remove the items from the player inventory on success.
  • requireItemSelected: Whether it is required for the item to be selected for the filter to pass. If the player has enough of the specified item, but do not have it currently selected, the onFilteredEventFailNotSelected event will fire. If they do not have enough items overall, the onFilteredEventFail will fire. And if they do have enough, the onFilteredEventPass will fire. Only one of the events will be fired for each filter invocation. Selecting this option displays the new onFilteredEventFailNotSelected event:

METHODS

  • FilterEventForPlayer(player): Checks whether the given player has the item in their inventory or not. Fires onFilteredEventPass if they do, and onFilteredEventFail if they do not. If consumeItems is set, consumes the items on success.

EVENTS

  • onFilteredEventPass: Fired after invoking FilterEventForPlayer(player), and the player had enough of the specified item in their inventory.
  • onFilteredEventFail: Fired after invoking FilterEventForPlayer(player), and the player did not have enough of the specified item in their inventory.
  • onFilteredEventFailNotSelected: Fired after invoking FilterEventForPlayer(player), and the player has enough of the specified item in their inventory, but the item is not currently selected. This event is only fired if requireItemSelected is set to true.
5 Likes