Selectors
A selector selects specific objects that you created. The result of a selector can then for example be used as a parameter inside of a command. An example for a selector is: #type:location;limit:1;tag:test#
Building a selector
A selector always consists of two ## with parameters inside of it. These parameters are each split by ;. When evaluating a selector, the engine starts with a list of all objects and sorts all of the ones out that don't match the parameters. The possible parameters are:
uid- checks the objectUIDname- checks for the object nametype- checks the object type (see objects & types on getting started)tag- checks if object has a taglocation- checks if an NPC has a given locationsort-[first;last;random]determines the order the objects get sorted out for thelimitparameter (needs to be set beforelimit)limit- sets the maximum amount of objects to be selectedinventory- selects all items in a given inventoryexpr-[VALUE][==;>;<;>=;<=;!=][VALUE]checks if an expression is true (beta)
It can also simply contain a UID, like so: #702c14f1b34a45e5#
Selectors can be combined with variables to create dynamic selectors: #name:{characterName}#
Examples / Exercises
Now that you know how the selectors work, try creating selectors that select these objects:
- All NPCs
- 5 random colors
- All items inside of the player inventory that have the tag
food - All NPCs that have the name
Carland are at the same location as the player - All items that are in the inventory of the location the player is at
Here are the solutions:
#type:npc#type:color;sort:random;limit:5##type:item;inventory:{player|inventory};tag:food##type:npc;name:Carl;location:{player|location}##inventory:{selector|#uid:{player|location}#}.inventory()#