Skip to content

Random System & How It Works

Claycorp edited this page Sep 2, 2014 · 1 revision

Want some more randomness in your rewards? Use this!

You can make 2 or more groups with the same amount. Pay2Spawn will pick one at random for you.

Many of the things that are capable of using randoms have radiobuttons in the configurator, but you can add them almost anywhere in your JSON file!

Example time!

Lets say you want to add a random about of XP levels between 5 and 20.

  1. Make a new Playermodification type
  2. Select all the right options: XP Levels and Add
  3. Enter the random tag in the amount field: $random(5, 20)
  4. Test!
  5. Save your reward.
  6. Done.

All of the random tags explained

**Important note1: ** BYTEs are used to represent true or false in NBT
**Important note1: ** <> are parameters that need to be filled with values!

Random true or false (1 or 0)

  • Can be used in: STRING, BYTE
  • Format: $random()

Random color(s)

Use this to make randomly colored fireworks or leather armor (or other things?).

  • Can be used in: INT[], INT, STRING
  • Format: $randomRGB() or $randomRGB(<amount of colors>)

If you are using leather, use $randomRGB().
If you are using fireworks, witch support multiple colors in the particles, use $randomRGB(<amount of colors>)

Random entity

  • Can be used in: STRING
  • Format: $randomEntity

Really only useful in the regular entity reward.

Random value from a list

  • Can be used in: BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, STRING
  • Format: $random[<list item 1>, <list item2>, <......>]

You can have as many list items as you'd like!

Random number (in a range)

  • Can be used in: BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, STRING
  • Format: $random(<start>, <limit>)

This will generate a random number starting from to

Using a random value in multiple places

You need random value to appear in more then 1 place? You can use this!

Format: $var(<name>, <random>)
!You need to put whatever your normal random expression was in the parameter, BUT WITHOUT THE "$"!

Example

You have a command that does /say @a Spawned a random mob!
and an entity reward that spawns $randomEntity

You can use $var(entity, randomEntity) instead of "a random mob" and "$randomEntity".
That would result in this: /say @a Spawned a $var(entity, randomEntity)!
and an entity reward that spawns $var(entity, randomEntity)

{
  "name": "Test for github wiki",
  "amount": "50",
  "message": "",
  "countdown": "",
  "rewards": [
    {
      "type": "entity",
      "data": {
        "SPAWNRADIUS": "INT:10",
        "name": "STRING:$var(entity, randomEntity)",
        "CustomName": "STRING:Your doom",
        "agro": "BYTE:0",
        "random": "BYTE:1",
        "RideThisMob": "BYTE:0",
        "throwTowardsPlayer": "BYTE:0"
      }
    },
    {
      "type": "command",
      "data": {
        "command": "STRING:say @a Spawned a $var(entity, randomEntity)!"
      }
    }
  ]
}