Declare Random Sections en - Glomzzz/RandomItem GitHub Wiki

Strings

For example

quality:
  type: strings
  strings:
    Rough:
      weight: 45
      values:
        - 'STICK'
        - '&8Rough'
        - '&eQuality: &8Rough'
        - '&f_______&b<-&8Quality Attribute&b->&f_______'
        - ' &dDamage: &810 '
        - '0'
    Normal:
      weight: 35
      values:
        - 'WOOD_SWORD'
        - '&7Normal'
        - '&eQuality: &7Normal'
        - '&f_______&b<-&7Quality Attribute&b->&f_______'
        - ' &dDamage: &720 '
        - '0'
    Fine:
      weight: 10
      values:
        - 'STONE_SWORD'
        - '&3Fine'
        - '&eQuality: &eFine'
        - '&f_______&b<-&eQuality Attribute&b->&f_______'
        - ' &dDamage: &330 '
        - '0'
    Excellent:
      weight: 6
      values:
        - 'IRON_SWORD'
        - '&aExcellent'
        - '&eQuality: &aExcellent'
        - '&f_______&b<-&aQuality Attribute&b->&f_______'
        - ' &dDamage: &a50 '
        - '1'
    Epic:
      weight: 3
      values:
        - 'GOLD_SWORD'
        - '&5Epic'
        - '&eQuality: &5Epic'
        - '&f_______&b<-&5Quality Attribute&b->&f_______'
        - ' &dDamage: &570 '
        - '2'
    Legendary:
      weight: 1
      values:
        - 'DIAMOND_SWORD'
        - '&6Legendary'
        - '&eQuality: &6Legendary'
        - '&f_______&b<-&6Quality Attribute&b->&f_______'
        - ' &dDamage: &6100 '
        - '3'

As shown in the codes, this random section declared a strings section Its contents are as follows:

  • ID: quality
  • type: strings
  • Sub String Section:
    • Rough weight: 45
    • Normal weight: 35
    • Fine weight: 10
    • Excellent weight: 6
    • Epic weight: 3
    • Legendary weight: 1

Analysis

  • Sub String Section:
    • As the name suggests, it is a strings section 's sub string section
  • Calling strings will randomly return a sub string section's value based on the weight

Number

strength

strength:
  type: number
  start: '1'
  bound: '20'

As shown in the codes, this is a number section Its contents are as follows:

  • ID: strength
  • type: number
  • fixed.integer.max: -1 (default)
  • fixed.integer.min: 0 (default)
  • fixed.demical.max: 0 (default)
  • fixed.demical.min: 0 (default)
  • decimal: 0 (default)
  • start: 1
  • bound: 20

Example

Example:
  type: number
  start: '10'
  bound: '20'

As shown in the codes, this is a number section Its contents are as follows:

  • ID: Example
  • type: number
  • fixed.integer.max: -1 (default)
  • fixed.integer.min: 0 (default)
  • fixed.demical.max: 0 (default)
  • fixed.demical.min: 0 (default)
  • decimal: 0 (default)
  • start: 10
  • bound: 20

Analysis

  • Calling the number section returns a random number from the start number to the end number

Calculation

For example:

x:
  type: compute
  max: 233
  fixed:
    decimal:
      max: 2
  formula: '(1+(<quality.5>/2)) * <Example> * <strength> / 20'

As shown in the codes, this random section stated a compute section Its contents are as follows:

  • ID: x
  • type: compute
  • fixed.integer.max: -1 (default)
  • fixed.integer.min: 0 (default)
  • fixed.demical.max: 2 (default)
  • fixed.demical.min: 0
  • formula: '(1+(<quality.5>/2)) * * / 20'

Analysis

  • Calling this compute section returns the result of the calculation of its formula (support PAPI)

JavaScript

For example:

script:
  type: javascript
  script: |
    var id = "<quality.id>";
    switch(id){
     case "Rough":
     return 1;
     case "Normal":
     return 2;
     case "Fine":
     return 3;
     case "Excellent":
     return 4;
     case "Epic":
     return 5;
     case "Legendary":
     return 6;
     default:
     return 0;
     }

As shown in the codes, this random section stated a javascript section Its contents are as follows:

  • ID: script
  • type: javascript
  • script: ·······

Analysis

  • Calling this javascript section returns the result of its code

(if there is "function" in the script, you must write a main function and run it by yourself)

(if there is no "function" in the script, you can write the script directly without writing the main function or run it.)

Lore

For example:

prefix:
  type: lore
  values:
    - '&7Rough '
    - '&aFine '
    - '&5Epic '

As shown in the codes, this random section stated a lore section Its contents are as follows:

  • ID: prefix
  • type: lore
  • values:
    • &7Rough
    • &aFine
    • &5Epic

Analysis

  • Calling this loresection returns one of its values randomly
⚠️ **GitHub.com Fallback** ⚠️