Date: 2023/09/15 12:38:33 UTC-07:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#reformatted the flag to use a flag map instead, can read more about that here: https://guide.denizenscript.com/guides/basics/flags.html#advanced-note-maps-and-sub-maps
#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:
#define the contents
#https://meta.denizenscript.com/Docs/Tags/repeat_as#objecttag.repeat_as_list
- define contents <player.flag[night_market.contents].if_null[<item[unrevealed_item].repeat_as_list[4]>]>
#define the reroll item depending if they've rerolled or not
- if <player.has_flag[night_market.rerolled]>:
- define reroll "barrier[display=<&c>You've already rerolled...]"
- else:
- define reroll reroll_item
#determine the defined contents + the reroll
- determine <[contents].include[<[reroll]>]>
slots:
- [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...
#rerolling item
reroll_item:
type: item
material: ender_eye
display name: <&a>Click to re-roll...
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:<[contents]>
after player clicks reroll_item in night_market:
#define the already rolled items
- define rolls <player.flag[night_market.contents].if_null[<list>]>
#check if they've rolled all items before they reroll
#https://meta.denizenscript.com/Docs/Tags/contains_mat#listtag.contains_match
#https://meta.denizenscript.com/Docs/Search/fallbacks#tag%20fallbacks
##this is optional, I just thought it'd make sense to have a check for it
- if <[rolls].contains_match[unrevealed_item]> || !<[rolls].is_truthy>:
- narrate "<&c>Roll every item first!"
- stop
#remove the previously saved contents
- flag <player> night_market.contents:!
#flag the player to track if they've rerolled or not
- flag <player> night_market.rerolled
#reopen the inventory
- inventory open d:night_market
#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:!