Paste #115238: Night Market Thingy

Date: 2023/09/15 09:14:27 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#night market inventory
night_market:
  type: inventory
  inventory: chest
  size: 27
  #set gui to true so you don't have to listen to click events and cancel them manually
  gui: true
  #filler item
  definitions:
    filler: black_stained_glass_pane[display=<&r>]
  #procedural items for the unrevealed/revealed items
  ##can read more about them here https://meta.denizenscript.com/Docs/Languages/inventory%20script%20containers
  procedural items:
  #if the player has the night_market flag, determines the contents of the flag
  ##determine command ends the queue, meaning if the first one runs, the second won't
  - determine <player.flag[night_market]> if:<player.has_flag[night_market]>
  #https://meta.denizenscript.com/Docs/Tags/repeat_as#objecttag.repeat_as_list
  - determine <item[unrevealed_item].repeat_as_list[4]>
  slots:
  - [filler] [filler] [filler] [filler] [filler] [filler] [filler] [filler] [filler]
  - [filler] [] [filler] [] [filler] [] [filler] [] [filler]
  - [filler] [filler] [filler] [filler] [filler] [filler] [filler] [filler] [filler]

#item that appears if they haven't "revealed" the item in that slot yet (can modify to your likings)
unrevealed_item:
  type: item
  material: gold_nugget
  display name: <&a>Click to reveal...

night_market_handler:
  type: world
  events:

    after player clicks unrevealed_item in night_market:
    #a random item from a list as loot
    - define loot <list[iron_ingot|gold_ingot|diamond|netherite_ingot].random>
    - inventory set slot:<context.slot> d:<context.inventory> o:<[loot]>
    #these are the items (revealed and unrevealed) that you determine as procedural items above
    #the slot numbers are the slots in which there are items to reveal/revealed already
    #there are multiple ways of doing this (matchers and what not), I think this works for an example
    - define contents <context.inventory.slot[11|13|15|17]>
    - flag <player> night_market:<[contents]>

    #this is where you reset every players night market
    #in this example, this will only run at 12pm every Sunday
    after system time 12:00:
    #check if day is Sunday
    - if <util.time_now.day_of_week_name> != sunday:
      - stop
    - announce "<&a>Night Market <&7>has been reset!"
    #remove the night_market flag from every player that has it
    #https://meta.denizenscript.com/Docs/Tags/server.players_flagged#server.players_flagged
    - flag <server.players_flagged[night_market]> night_market:!