Dynamic Variables

Creating a dynamic variable


  • Start by getting the dynamic variable item in the Variables inventory.
    In order to access the Variables inventory, right click the Variables
    item. It is an iron ingot item placed at the 9th slot of your hotbar,
    as shown in the image below:
    Variables Item

  • Now, the Variables inventory should be open. Click the
    Dynamic Variable item shown in the images below:
    image

    image

  • You will be given the Dynamic Variable item in your inventory.

  • Now, you need to name the dynamic variable! You can name
    the dynamic variable by sending a message to the chat while
    holding the dynamic variable item. The message sent will be
    the name of the dynamic variable.

  • These are the rules of dynamic variable names:

    • It cannot start with “/”, unless minecraft modifications is used.
    • The length of the variable name can only be at most 256 characters
      long, unless minecraft modifications is used.
    • Unsupported symbols in minecraft will not show properly in
      dynamic variables.
  • Extra notes

    • You can use placeholders in the dynamic variable names.
      This can be used to create player-specific dynamic variables
      or entity-specific dynamic variables. Below is the list of
      some of the placeholders you can have in a dynamic variable name.

      • %player%
        • Main player’s name in the event
        • Main player refer to the player that triggered the event
        • Usable in most player events
      • %default%
        • Default/First player’s name in the event
        • Usable in most player events
      • %random%
        • Random player’s name
        • Only picks a random player that is
          online on the world
        • Usable in every player event, loops
          and functions
      • %killer%
        • Killer player’s name
        • Usable in player events categorized as “Combat”
      • %damager%
        • Damager player’s name
        • Usable in player events categorized as “Combat”
      • %shooter%
        • Shooter player’s name
        • Usable in player events categorized as “Combat”
    • If your dynamic variable contains at least one of these placeholders
      above, it will be converted into the appropriate name if applicable.

      For example,

      • AtomSeis is the player that triggered the event.
      • Thus, dynamic variable named “%player%_sui-chan”
        would be converted to “AtomSeis_sui-chan”
      • Narokbar killed AtomSeis, Narokbar is the player that
        triggered the event.
      • Therefore, dynamic variable named “%killer%_isBest”
        would be converted to “Narokbar_isBest”
    • Where in the variable name you place the placeholder does not
      matter! Furthermore, you can have multiple placeholders in the
      dynamic variable name. It will be replaced regardless.

      More examples:

      • AtomSeis killed Narokbar, AtomSeis is the player that
        triggered the event with Narokbar being the victim.
      • This would result in a dynamic variable named
        “common_%killer%%victim%” being converted to
        “common_AtomSeisNarokbar”
      • Narokbar shot AtomSeis using a bow, Narokbar is the
        player that triggered the event with AtomSeis being the
        victim.
      • Hence, a dynamic variable named
        “%shooter%_common%victim%” will be converted into
        "Narokbar_commonAtomSeis
    • Lastly, by sneaking and right click while holding the dynamic variable,
      will set it to ‘SAVED’ property, meaning it will be saved regardless
      if the player left the world, or the world closed down.
      Particularly useful if you wish to create a statistic variable


With that, you had made a dynamic variable, complete with the name!
Now, you can move onto modifying or setting the value of the dynamic variables.

Modifying and setting the value of dynamic variables


  • You can modify, or set the value of a dynamic variable in the set
    variable block, as shown in the image:
    image

  • Set Variable block has five categories:
    image

    • General

      image

      Methods in General category:

      image

      You can set the value of a dynamic variable using Set Variable (=)

      image

      Set Random Value will randomly select one of the values provided
      and set it as the dynamic variable value

      image

    • Numbers

      image

      Methods in Numbers category:

      image

      By using Set to Sum (+), you can set a dynamic variable value
      to a sum of two or more values, refer to the image below:

      image

      Set to Difference (-) allows you to set a dynamic variable value to a
      difference between two number variables values, dynamic variables
      values with number values or a combination of both. Better
      explained in the image given below:

      image

      Increment Variable (+=) allows you to increment a dynamic variable
      value that is a number by a specific amount you set.

      In another words, you can add a number to a dynamic variable by a
      specific amount you set. Since it’s an incrementation method, you
      can’t use a text variable value here and incrementing with a value
      after the decimal point. Number with a value before and after the
      decimal point will be rounded down before being added to the
      dynamic variable

      image

      Decrement Variable (-=) functions similarly to
      Increment Variable (+=). It allows you to decrement a
      dynamic variable by a specific amount you set.

      In another words, it allows you to subtract a specified number
      from a dynamic variable. Similar to Increment Variable (+=),
      text variable value cannot be used in this method and decrementing
      with a value after the decimal point. Number with a value before and
      after the decimal point will be rounded down before being subtracted
      from the dynamic variable

      image

    • Text

      image

      Methods in Text category:

      image

      Combine Texts is a better alternative to Set to Sum (+)
      if you want to set a combination of text variables values
      to a dynamic variable.

      It allows you to combine one or more text values and then
      set it as a dynamic variable value. You can also combine
      numbers and dynamic variables values together with text
      values.

      Number values provided will be converted to text and
      then combined with other values. It also remove decimal
      point if numbers after the decimal point is 0.

      image

      Parse Number, like the method name suggests, will set a
      dynamic variable value to a number variable, parsed from
      a text variable when possible. The description provides
      a good example:

      image

    • Location

      image

      Methods in Location category:

      image

      Get Value From Location can let you acquire a specific element
      from a location variable or a dynamic variable containing location
      value. You can acquire one of these elements:

      • X Coordinates
      • Y Coordinates
      • Z Coordinates
      • Yaw
      • Pitch

      The acquired value will then be saved to the dynamic variable placed.

      image

      Get The Distance Between Locations

      You can acquire the distance between two locations using this
      method. Be noted however, the distance include the first location
      but does not include the second location.

      image

      Set Location Values

      You can increment, or replace each element in location variable.
      If you want to subtract a number from an element, place in negative
      numbers. Leave empty if you don’t need to change an element
      number

      image

That should sum up some of the Set Variable block methods you can use to
modify or set a dynamic variable! You can find more methods in Set Variable
block however, try to explore these!


If you have made it this far, congratulations!

With dynamic variables, you can create games with better features. I hope this could help, best of luck to everyone trying! See you next time, have a good day!

6 Likes

WOW! Really good quality!

1 Like

Thank you so much!

Cool! It’s really cool!

1 Like

Amazing guide dead for over 12 months

cringe veddnt disgustinf WW pokeman

no why u dragging pokemon here :sob: what did they do to you

are you happy with the server you created?
i have heard rumors that u died?
RIP

Do you really think he gonna reply you lmao

if he’s not dead yet then yes