Date: 2014/08/30 19:13:54 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
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# dBroadcasting system
# Allows for colorized broadcasts
# Users require op or dbroadcast.command permission
# Broadcasts are stored in dBroadcasts_saves.yml and is
# Editable and reloadable.
# Created by Talamar1/Mik/Mikayle1
Broadcast:
type: world
debug: true
events:
on server start:
- if <server.has_file[dbroadcast_saves.yml]> {
- announce "<red><&lb>dBroadcast<&rb> <green>Loading Broadcast Config File"
- yaml load:dbroadcast_saves.yml id:dbroadcast_saves
}
else {
- announce "<red><&lb>dBroadcast<&rb> <green>Creating Broadcast Config File"
- yaml create id:dbroadcast_saves
- yaml savefile:dbroadcast_saves.yml id:dbroadcast_saves
}
- run InitdBroadcast delay:10t
on dbc command:
- determine passively fulfilled
- if !<context.server> && !<player.has_permission[dbroadcast.command]||false> {
- narrate "<&6>You do not have permission to use the dbroadcast command."
- queue clear
}
- if <el@val[add].is[==].to[<context.args.get[1]>]> {
- inject dbroadcast_command_add
}
else if <context.args.get[1].matches[^(rem|remove|del|delete)$]> {
- inject dbroadcast_command_remove
}
else if <el@val[list].is[==].to[<context.args.get[1]>]> {
- inject dbroadcast_command_list
}
else if <el@val[reload].is[==].to[<context.args.get[1]>]> {
- inject dbroadcast_command_reload
}
else {
- narrate "<&6>/dBroadcast add <<>timer<>> <<>message<>>"
- narrate "<&6>/dBroadcast remove <<>dbid<>>"
- narrate "<&6>/dBroadcast list"
- narrate "<&6>/dBroadcast reload"
}
InitdBroadcast:
type: task
debug: false
script:
- if <yaml[dbroadcast_saves].list_keys[bclist].size.is[more].than[0]||null> == true {
- foreach <yaml[dbroadcast_saves].list_keys[bclist]> {
- if <util.date.time.minute.mod[<yaml[dbroadcast_saves].read[bclist.%value%.timer]>].is[==].to[0]> {
- define dBmsg <yaml[dbroadcast_saves].read[bclist.%value%.message]>
- announce "<def[dBmsg]>"
}
}
- run InitdBroadcast delay:60s
dbroadcast_command_add:
type: task
debug: false
script:
- if <context.args.get[3].is[==].to[null]||true> {
- narrate "<&6>/dBroadcast add <<>timer<>> <<>message<>>"
- narrate "<&6>Timer - Amount of time between rebroadcasts"
- narrate "<&6>Message - message you want broadcasts"
- queue clear
}
- if <context.args.get[2].as_int.is[LESS].than[5]||true> {
- narrate "<gold>dBroadcast Invalid time argument"
- narrate "<gold>Value must be greater than 5"
- queue clear
}
- define dBtimer <context.args.get[2].as_int>
- define dBmsg <context.args.get[3].to[<context.args.size>].as_string>
- define dBmsg <def[dBmsg].replace[&0].with[<&0>]>
- define dBmsg <def[dBmsg].replace[&1].with[<&1>]>
- define dBmsg <def[dBmsg].replace[&2].with[<&2>]>
- define dBmsg <def[dBmsg].replace[&3].with[<&3>]>
- define dBmsg <def[dBmsg].replace[&4].with[<&4>]>
- define dBmsg <def[dBmsg].replace[&5].with[<&5>]>
- define dBmsg <def[dBmsg].replace[&6].with[<&6>]>
- define dBmsg <def[dBmsg].replace[&7].with[<&7>]>
- define dBmsg <def[dBmsg].replace[&8].with[<&8>]>
- define dBmsg <def[dBmsg].replace[&9].with[<&9>]>
- define dBmsg <def[dBmsg].replace[&a].with[<&a>]>
- define dBmsg <def[dBmsg].replace[&b].with[<&b>]>
- define dBmsg <def[dBmsg].replace[&c].with[<&c>]>
- define dBmsg <def[dBmsg].replace[&d].with[<&d>]>
- define dBmsg <def[dBmsg].replace[&e].with[<&e>]>
- define dBmsg <def[dBmsg].replace[&f].with[<&f>]>
- define dBmsg <def[dBmsg].replace[&k].with[<&k>]>
- define dBmsg <def[dBmsg].replace[&l].with[<&l>]>
- define dBmsg <def[dBmsg].replace[&m].with[<&m>]>
- define dBmsg <def[dBmsg].replace[&n].with[<&n>]>
- define dBmsg <def[dBmsg].replace[&o].with[<&o>]>
- define dBmsg <def[dBmsg].replace[&r].with[<&r>]>
- narrate "Timer %dBtimer%"
- narrate "Message %dBmsg%"
- define bcount <yaml[dbroadcast_saves].list_keys[bclist].size||0>
- yaml set bclist.<def[bcount].add[1].as_int>.timer:%dBtimer% id:dBroadcast_saves
- yaml set bclist.<def[bcount].add[1].as_int>.message:%dBmsg% id:dBroadcast_saves
- yaml savefile:dbroadcast_saves.yml id:dbroadcast_saves
dbroadcast_command_list:
type: task
debug: false
script:
- foreach <yaml[dbroadcast_saves].list_keys[bclist]> {
- narrate "Key<&co> %value% <&co> <yaml[dbroadcast_saves].read[bclist.%value%.timer]> <&co> <yaml[dbroadcast_saves].read[bclist.%value%.message]> "
}
dbroadcast_command_reload:
type: task
debug: false
script:
- if <server.has_file[dbroadcast_saves.yml]> {
- narrate "<red><&lb>dBroadcast<&rb> <green>Loading Broadcast Config File"
- yaml load:dbroadcast_saves.yml id:dbroadcast_saves
}
else {
- narrate "<red><&lb>dBroadcast<&rb> <green>Creating Broadcast Config File"
- yaml create id:dbroadcast_saves
- yaml savefile:dbroadcast_saves.yml id:dbroadcast_saves
}
dbroadcast_command_remove:
type: task
debug: true
script:
- if <context.args.get[2].as_int.is[LESS].than[1]||false> || <yaml[dBroadcast_saves].read[bclist.<context.args.get[2].as_int>].is[==].to[null]> {
- narrate "<gold>dBroadcast Invalid broadcast id number"
- narrate "<gold>Check IDs with /bc info"
- queue clear
}
- yaml set bclist.<context.args.get[2].as_int>:! id:dBroadcast_saves
- yaml create id:temp_broadcast
- foreach <yaml[dBroadcast_saves].list_keys[bclist]> {
- yaml set bclist.%loop_index%.timer:<yaml[dBroadcast_saves].read[bclist.%value%.timer]> id:temp_broadcast
- yaml set bclist.%loop_index%.message:<yaml[dBroadcast_saves].read[bclist.%value%.message]> id:temp_broadcast
}
- yaml savefile:dbroadcast_saves.yml id:temp_broadcast
- yaml unload id:temp_broadcast
- inject dbroadcast_command_reload