Date: 2019/10/01 22:40:14 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
84
85
86
87
JoinTown:
type: item
material: dirt
display name: "Join Town"
lore:
- "Join this town"
- "Requires approval"
- "From X residents"
LeaveTown:
type: item
material: stone
display name: "Leave Town"
lore:
- "Leave your town"
Roster:
type: item
material: player_head
display name: "Roster"
lore:
- "View town members"
townElder_gui:
type: inventory
title: <player.flag[townElderInv]>
size: 9
slots:
- "[] [i@JoinTown] [] [] [i@LeaveTown] [] [] [i@Roster] []"
townElder_roster_gui:
type: inventory
title: <player.flag[townElderInv]>_Roster
procedural items:
- define list li@
- define town <town@>
- foreach <server.list_players_flagged[ResidentOf]>:
- if <[value].flag[ResidentOf]> == <player.flag[townElderInv]>:
- define item player_head[skull_skin=<[value].uuid>]
- define list <def[list].include[<def[item]>]>
- determine <def[list]>
townElder_assignment:
type: assignment
actions:
on assignment:
- trigger name:click state:true
- flag npc Town:<npc.location.town.after[@]>
interact scripts:
- 1 townElder
townElder:
type: interact
steps:
1:
click trigger:
script:
- flag player townElderInv:<npc.flag[Town]>
- flag player townObject:@<npc.flag[Town]>
- inventory open d:in@townElder_gui
townElder_gui_handler:
type: world
events:
on player closes townElder_gui|townElder_roster_gui:
- flag player townElderInv:!
- flag player townObject:!
on player clicks in townElder_gui:
- determine cancelled
on player drags in townElder_gui:
- determine cancelled
on player clicks JoinTown in townElder_gui priority:-1:
- if <player.has_town>:
- narrate "You are already part of a town."
- stop
- if !<player.has_flag[<player.flag[townElderInv]>_Approval]>:
- narrate "You have to gain approval from residents of this town first! Go ask around!"
- stop
- if <player.flag[<player.flag[townElderInv]>_Approval]> >= <player.flag[townObject].player_count.div_int[4].round_up>:
- narrate "You need 3 residents to approve you and you have <player.flag[<player.flag[townElderInv]>_Approval]> approvals."
- stop
- else:
- execute as_op "townyadmin town <player.flag[townElderInv]> add <player.name>"
- flag player ResidentOf:<player.flag[townElderInv]>
- narrate "You are now a resident of <player.flag[townElderInv]>!"
on player clicks LeaveTown in townElder_gui priority:-1:
- execute as_player "town leave"
- flag player ResidentOf:!
- flag player <player.flag[townElderInv]>_Support:!
- flag player <player.flag[townElderInv]>_Approval:!
on player clicks Roster in townElder_gui priority:-1:
- inventory open d:in@townElder_roster_gui