Skip to content

Get Item

Plugin: Data | Mode: Run

Creates a new or overwrites an existing reference to an item.

The item can then be used within the level under the new reference name.

A list of several items can also be referenced with Get Item.

Learn more about Item References.

Settings

reference ame

The name of the reference by which the item can then be addressed within the level.

Info

reference name cannot contain spaces.

Collection

The collection that contains the item that is to be referenced.

find query

Formulate a database search in the style of a MongoDB find query to load the item.

find query uses JSON syntax to determine which item to get.

Find the item named "Hans Hövel":

{name: "Hans Hövel"}

Find an item whose score variable is greater than 30:

{score: {$gt:30}}

Find an item whose score variable is greater than the value in the local variable minimum:

{score: {$gt:[[minimum]]}}

You can omit the outer curly brackets in find query if you want.

Note

You can omit the outer curly brackets in find query if you wish.

Alternatively, you can also specify the name property of the item you want to have.

Ada is therefore the same as {name: "Ada"}

If you specify an empty query for find query, meaning only the curly brackets {}, all items in the collection will be referenced.

multiple items

optional

If multiple items is selected, it is possible to reference more than 1 item.

All items that match the specified find query will then be referenced by the given name.

If multiple items is not selected, only 1 item will be loaded, even if the specified query matches several items.

For details, see the chapter Variables, Data, References.

sort

optional

Specify the order in which the items found with the specified find query are to be referenced.

If you only want to reference a single item (multiple items is deactivated), you can still use sort to specify precisely which of the items should be referenced. Only the upmost item is then used.

Under by, select the property by which the items are to be sorted.

Use direction to specify whether the items should be sorted in ascending (ascending) or descending (descending) order.

In this example, the locations items are sorted according to the size of the value specified for height:

Get Item

{
    "reference": "Location",
    "collection": "locations",
    "query": "{}",
    "multiple": true,
    "sort": [
        {
            "by": "height",
            "direction": 1
        }
    ]
}

Screenshot

Note

The sort option has the same function as the $sort key within a query. You can find out more about this in the chapter on Variables.

limit

optional

Restricts the number of items that are found via the find query. Fewer, but not more items than specified for limit will then be referenced.

For example, if you set limit to 3, a maximum of 3 items will be referenced.

limit has no effect if multiple items is deactivated.

Note

The limit option has the same function as the $limit key within a query. You can find out more about this in the chapter on Variables.

skip

optional

Skips the first n items found via the find query.

For example, if you set skip to 2, only the 3rd item and possibly all subsequent items will be referenced.

If the total number of items found is less than the skip value, no item will be referenced.

Note

The skip option has the same function as the $skip key within a query. You can find out more about this in the chapter on Variables.

example

Get an item from the "locations" collection and make it accessible as local item reference "Location".

locations collection Beispiel

Search criterion for the reference is that the name variable is "laboratory".

Get Item

{
    "reference": "Location",
    "collection": "locations",
    "query": "name: \"laboratory\"",
    "multiple": true
}

Loading an item into the level

You can then for example use the item inside the Switch action.

Switch

{
    "if": [
        {
        "value": "[[Location.condition]]",
        "equals": [
            "locked"
        ],
        "next": "NoEntry"
        }
    ]
}

Use the new reference inside the switch action

Da der condition Parameter im gefundenen Item unlocked ist wird die Switch Condition nicht zutreffen und es geht weiter im EnterLocation State.