tutorials/Using Variables

Overview

Variables are one of the main features of LogiBlocks. They are mainly used by the user to signify what they want to target. Variables exist in Vanilla as @p, @a, and @r and are similar to the variables in LogiBlocks.

Knowing what variable to use and where

In the Command Reference you can see <entity>, <player>, <location>, etc. under "Usage". These denote which variables are appropriate for each argument. For instance, /c kill <entity/player> would expect some variation of /c kill @p or /c kill @e

Using variable arguments

Similarly to @p, variables also have arguments to help them determine what you want to use. Just like @p[c=3,r=5] finds the nearest three players within a 5 meter radius, @e[c=3,r=5] finds the nearest three entities in a 5 meter radius. Some variables, such as @e and @l, don't require any arguments and can just be used with the defaults, but others such as @i need arguments to work. Arguments differ from variable to variable, but a list of them can be found below.

List of variables

  • Entity - @e
    • Description: Used to find the nearest of any type of entity. Works similarly to @p.
    • Example: /c kill @e[t=skeleton,c=5,r=10] (kills the 5 nearest skeletons within a 10 meter range)
    • Arguments:
      • t:
        • Description: Sets what type of entity to search for
        • Type: Name
      • x:
        • Description: Sets the x coordinate of where to search from. Defaults to the block's x coordinate
        • Type: Number
      • y:
        • Description: Sets the y coordinate of where to search from. Defaults to the block's y coordinate
        • Type: Number
      • z:
        • Description: Sets the z coordinate of where to search from. Defaults to the block's z coordinate
        • Type: Number
      • loc:
        • Description: Sets all three coordinates. Formatted like x|y|z
        • Type: Number
      • r:
        • Description: The maximum radius of search.
        • Type: Number
      • rm:
        • Description: The minimum radius of search.
        • Type: Number
      • c:
        • Description: How many entities to find
        • Type: Number
      • rand:
        • Description: If true, entity(ies) will be selected at random (while still meeting search criteria) instead of by nearest.
        • Type: true/false
  • Item - @i
    • Description: Used to define an item in an inventory.
    • Example: /c equip @e[t=zombie] helmet @i[m=skull_item,d=4,e=protection_environment|5,e=thorns|5] (equips the nearest zombie with a creeper head with Protection V and Thorns V)
    • Arguments:
      • m:
        • Description: Sets the material(id) of the item
        • Aliases: mat, material, id
        • Type: Name
      • c:
        • Description: Sets the size of the stack
        • Aliases: count, amount
        • Type: Number
      • d:
        • Description: Sets the durability of the item
        • Aliases: data, damage, durability
        • Type: Number
      • n:
        • Description: Sets the name of the item
        • Aliases: name
        • Type: Name
      • l:
        • Description: Sets the "lore", or the description of the item. Underscores ("_") are turned into spaces and lines are separated with a pipe ("|")
        • Aliases: lore, description
        • Type: Name
      • e:
        • Description: Adds an enchantment. Enchantment name and level are separated with a pipe ("|"). Enchantment names can be found here
        • Aliases: enchant, enchantment
        • Type: Name/Number
      • o:
        • Description: Sets the owner of the item. Only applicable to player heads.
        • Aliases: owner
        • Type: Name
  • Location - @l
    • Description: Used to define a location for finding blocks, or teleporting things.
    • Example: /c inv @l[c=300|64|287] clear (Any inventory (chest, furnace, etc.) at 300,64,287 will be cleared of items)
    • Arguments:
      • w:
        • Description: Sets which world the location is in
        • Aliases: world
        • Type: Name
      • c:
        • Description: Sets the x,y,z coordinates, separated by a pipe ("|").
        • Aliases: coords, coordinates
        • Type: Number
      • x:
        • Description: Sets the x coordinate
        • Aliases: none
        • Type: Number
      • y:
        • Description: Sets the y coordinate
        • Aliases: none
        • Type: Number
      • z:
        • Description: Sets the z coordinate
        • Aliases: none
        • Type: Number
      • p:
        • Description: Sets the pitch (vertical angle). Only applicable to entities.
        • Aliases: pitch
        • Type: Number
      • y:
        • Description: Sets the yaw (horizontal angle). Only applicable to entities.
        • Aliases: yaw
        • Type: Number
      • r:
        • Description: The maximum radius of search.
        • Type: Number
      • rm:
        • Description: The minimum radius of search.
        • Type: Number
      • rand:
        • Description: If true, a location will be selected at random within the maximum radius, and outside the minimum. Warning: This value is truly random, and can cause you to fall from great heights or be stuck in the floor.
        • Type: true/false
  • Last Redstone - @lr
    • Description: Can be used in place of @e or @p. Returns the last entity/player to activate redstone.
    • Example: /c kill @lr (kills the last entity/player that activated redstone)
    • Arguments: none

Comments

Posts Quoted:
Reply
Clear All Quotes