Date: 2016/03/11 16:34:20 UTC-08: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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
LocalChat_Format:
type: format
format: <&2><&lb><player.name><&rb><&co> <&f><text>
GlobalChat_Format:
type: format
format: <&7><&lb>Global<&rb> <&8><player.name><&7><&co> <&a><text>
TradeChat_Format:
type: format
format: <&5><&lb>Trade - <player.location.cuboids.filter[contains[_town]].get[1].before[_town].after[cu@].replace[_].with[<&sp>].to_titlecase><&rb> <&d><player.name><&5><&co> <&b><text>
Chat_Channels:
type: world
Local_Radius:
- 20
Global_Chat_Limit:
- 10
Global_Chat_Period:
- 1h
help:
- narrate "<&3>====== <&b>Chat Help <&3>======"
- narrate ""
- narrate " - <&l>/local <&r>For speaking to everyone in a <script.yaml_key[Local_Radius]> block radius."
- narrate " - <&l>/global <&r><&a>Chat to everyone, limited to <script.yaml_key[Global_Chat_Limit]> per <script.yaml_key[Global_Chat_Period]>."
- narrate " - <&l>/trade <&r><&b>Arrange trades with others in the same city."
- narrate ""
events:
on player chats:
- determine passively cancelled
- choose <player.flag[chat_channel]>:
- case global:
- inject GlobalChat_Monitor instantly
- announce format:GlobalChat_Format <c.message>
- case local:
- narrate format:LocalChat_Format <c.message> targets:<pl.location.find.players.within[<script.yaml_key[Local_Radius]>]>
- case trade:
- if <pl.location.cuboids.filter[contains[_town]].size.is[LESS].than[1]> {
- narrate "<&4>You cannot use Trade Chat unless you are in a town."
} else {
- narrate format:TradeChat_Format <c.message> targets:<pl.location.cuboids.filter[contains[_town]].get[1].list_players>
}
on chat command:
- inject locally help
on global command:
- determine passively fulfilled
- define message <c.raw_args>
- if <c.raw_args.length.is[MORE].than[0]> {
- inject GlobalChat_Monitor instantly
- announce format:GlobalChat_Format <def[message]>
- queue clear
}
- if <player.flag[chat_channel].is[==].to[global]> {
- narrate "<&4>Your default channel is already Global Chat."
} else {
- narrate "<&3>Set your chat channel to <&8><&lb><&7>Global<&8><&rb>"
- flag player chat_channel:global
}
on trade command:
- determine passively fulfilled
- define message <c.raw_args>
- if <c.raw_args.length.is[MORE].than[0]> {
- if <pl.location.cuboids.filter[contains[_town]].size.is[LESS].than[1]> {
- narrate "<&4>You cannot use Trade Chat unless you are in a town."
} else {
- narrate format:TradeChat_Format <def[message]> targets:<pl.location.cuboids.filter[contains[_town]].get[1].list_players>
}
- queue clear
}
- if <player.flag[chat_channel].is[==].to[trade]> {
- narrate "<&4>Your default channel is already Trade Chat."
} else {
- narrate "<&3>Set your chat channel to <&8><&lb><&5>Trade<&8><&rb>"
- flag player chat_channel:trade
}
on local command:
- determine passively fulfilled
- define message <c.raw_args>
- if <c.raw_args.length.is[MORE].than[0]> {
- narrate format:LocalChat_Format <def[message]> targets:<pl.location.find.players.within[20]>
- queue clear
}
- if <player.flag[chat_channel].is[==].to[local]> {
- narrate "<&4>Your default channel is already Local."
} else {
- narrate "<&3>Set your chat channel to <&2><&lb>Local<&rb>"
- flag player chat_channel:local
}
on player joins:
- if <player.has_flag[chat_channel].not> {
- flag player chat_channel:local
}
GlobalChat_Monitor:
type: task
script:
- if <pl.flag[global_chat_count].is[MORE].than[<s@Chat_Channels.yaml_key[Global_Chat_Limit]>]> {
- narrate "<&4>You have reached your limit for Global Chat. Please try again later."
- queue clear
}
- if <pl.flag[global_chat_count].is[MORE].than[<s@Chat_Channels.yaml_key[Global_Chat_Limit].mul[0.8].round>]> {
- narrate "<&8>Warning<&co> You are nearing your limit of messages per <s@Chat_Channels.yaml_key[Global_Chat_Period]>."
}
- flag player global_chat_count:++
- run GlobalChat_Decay delay:<s@Chat_Channels.yaml_key[Global_Chat_Period]> def:<player>
GlobalChat_Decay:
type: task
script:
- if <def[1].as_player.flag[global_chat_count].is[MORE].than[0]> {
- flag <def[1].as_player> global_chat_count:--
}