Paste #47932: Edit of P#47931 - plausibly a spinner, haven't tested it though

Date: 2018/06/20 21:02:49 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


rng_gui_task:
  type: task
  debug: false
  speed: 0
  prefix: '&ss0&ss4&ss8&ss5&ssr'
  script:
  # Build a starting list of random items!
  # Note: You might need to adjust how many times the list building loops. I might have counted
  # too little.
  - define disp_list li@
  - repeat 59 {
    - define rng '<util.random.decimal>'
    # The following is just an RNG example. You can implement your own random item logic here.
    # 10% chance
    - if <def[rng]> < 0.1 {
      - define disp_list '<def[disp_list].include[i@stone[display_name=&sseLucky Stone;lore=&ss6Whippity whoopity, you now have a suspic]]>'
    }
    # 25% chance
    else if <def[rng]> < 0.35 {
      - define disp_list '<def[disp_list].include[i@wood_sword[display_name=&ssbEarth Shatterer
        &ss7(&ss6****&ss7*);lore=&ss7This isn&sqt anything special&dot|&ss7Just has a cool name&dot]]>'
    }
    # 20% chance
    else if <def[rng]> < 0.55 {
      - define disp_list '<def[disp_list].include[i@diamond_chestplate[display_name=&ssaToy Chestplate;lore=&ss7It&sqs
        not fighting material&dot;nbt_attributes=generic.armor/chest/0/1]]>'
    }
    # 15% chance
    else if <def[rng]> < 0.7 {
      - define disp_list '<def[disp_list].include[i@dirt[display_name=&ssfsuspic&sqs scripting skills;lore=&ssaIt&sqs
        so bad it doesn&sqt deserve to be capitalized&dot]]>'
    }
    # 10% chance
    else if <def[rng]> < 0.8 {
      - define disp_list '<def[disp_list].include[i@beacon[display_name=&sscShiny Thing;lore=&ssfIt&sqs pretty &coo]]>'
    }
    # 5% chance
    else if <def[rng]> < 0.85 {
      - define disp_list '<def[disp_list].include[i@human_skull[skull_skin=f7069c8a-9283-4da8-aae2-fcdde5fd3d17;display_name=&ssfsuspic&sqs
        head;lore=&ss7Yes, this is my Minecraft account&sqs actual head skin&dot]]>'
    }
    # 15% chance
    else {
      - define disp_list '<def[disp_list].include[i@totem[display_name=&ssfCool Shiny Thing;lore=&ss7It&sqs not
        actually shiny&dot||&ssc&sslPRANKED]]>'
    }
  }
  # ...and then we spin!
  - repeat 50 {
    - inventory open 'd:in@generic[title=<script.yaml_key[prefix].unescaped><&6><&l>Lottery
      GUI;size=27;contents=li@i@air|i@air|i@air|i@air|i@air|i@air|i@air|i@air|i@air|i@air|i@air|i@air|i@air|<def[disp_list].get[<def[value]>].to[<def[value].add[8]>].separated_by[<&pipe>]>]'
    - wait <util.e.power[<def[value].mul[0.125].sub[3]>].round_up>t
  }
  - wait 1s
  - narrate '<&a>CONGRATULATIONS! You got a <&f><player.open_inventory.slot[14].display||<player.open_inventory.slot[14].formatted.to_titlecase>><&a>!
    Now go have fun and do something creative.'
  - give <player.open_inventory.slot[14]>
  - flag player can_close_inv
  - inventory close

rtd_gui_evts:
  type: world
  debug: false
  events:
    on player closes inventory:
    - if <context.inventory.title.escaped.starts_with[&ss0&ss4&ss8&ss5&ssr]> {
      - if !<player.has_flag[can_close_inv]> {
        - determine cancelled
      }
      - flag player can_close_inv:!
    }