- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register








The script repo is an archive of historical scripts. For modern scripts, or to post your own, please use the Scripts forum section.





Staff Pick: dTravelers


By mcmonkey
Created: 2015/01/10 14:20:06 UTC-08:00 (9 years and 115 days ago)
Edited: 2015/01/10 14:20:06 UTC-08:00 (9 years and 115 days ago)
Likes: 2

Staff pick as of: 2015/01/10 14:20:27 UTC-08:00 (9 years and 115 days ago)
Denizen Version: 0.9.3
Script Version: 1.0
Description:

# | dTravelers 2.1: NPCs to help you travel around the world!
#
# | WARNING: dTravelers 2 location save data is incompatible with original dTravelers save data!
# It is also incompatible with copies of the original dTravelers script!
# However, unlocked names will stay.
#
# | 2.1:
# ... make it actually work now! (Only ops could use 2.0 ! oops!)
# | 2:
# Updated, reworked, etc. Travel locations saved globally now, new commands, can link areas by permission rather than unlock, and so on.
# | 1:
# Original dTravelers
#
# | To create a dTraveler:
# /npc create [Name] ## [Name] is the name of the NPC
# /npc assign --set dtraveler_assign ## All literal
# /dtraveler name [NameOfTravelLocation] ## OPTIONAL. [NameOfTravelLocation] is the name of the location to link to this NPC.
#
# | To create a travel location:
# /dtraveler add [NameOfTravelLocation] ## [NameOfTravelLocation] is what you want to call this location
# ## Remember not to make two of the same name!
# ## Note: the location will be placed precisely where you are standing
#
# | To remove a travel location:
# /dtraveler remove [NameOfTravelLocation] ## [NameOfTravelLocation] is the name of the location you want to remove
#
# | To go to a travel location without using an NPC:
# /dtravel goto [NameOfTravelLocation] ## [NameOfTravelLocation] is the name of the location you want to go to
#
# | Player interaction:
# Click on a dTraveler to unlock it.
# You can speak the name of any travel location to a traveler to go there.
# You can also say 'list' to a traveler to see what locations you've unlocked.
#
# | Commands:
# /dtraveler add [NameOfTravelLocation] ## Adds a travel location
# /dtraveler remove [NameOfTravelLocation] ## Removes a travel location
# /dtravel goto [NameOfTravelLocation] ## Teleports you to a travel location
# /dtraveler name [NameOfTravelLocation] ## Links an NPC to a travel location
# /dtraveler unname ## Unlinks an NPC from its travel location
#
# | Permissions:
# denizen.scripts.dtravelers.add ## Use the 'add' and 'remove' commands
# denizen.scripts.dtravelers.goto ## Use the 'goto' command
# denizen.scripts.dtravelers.name ## Use the 'name' and 'unname' commands
# denizen.scripts.dtravelers.[NameOfLoc] ## Permits travel to a given travel location even if you haven't unlocked it



Download script | View raw 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
29300

# | dTravelers 2.1: NPCs to help you travel around the world!

# | WARNING: dTravelers 2 location save data is incompatible with original dTravelers save data!
#          It is also incompatible with copies of the original dTravelers script!
#          However, unlocked names will stay.

# | 2.1:
# ... make it actually work now! (Only ops could use 2.0 ! oops!)
# | 2:
# Updated, reworked, etc. Travel locations saved globally now, new commands, can link areas by permission rather than unlock, and so on.
# | 1:
# Original dTravelers

# | To create a dTraveler:
# /npc create [Name]                        ## [Name] is the name of the NPC
# /npc assign --set dtraveler_assign        ## All literal
# /dtraveler name [NameOfTravelLocation]    ## OPTIONAL. [NameOfTravelLocation] is the name of the location to link to this NPC.

# | To create a travel location:
# /dtraveler add [NameOfTravelLocation]     ## [NameOfTravelLocation] is what you want to call this location
#                                           ## Remember not to make two of the same name!
#                                           ## Note: the location will be placed precisely where you are standing

# | To remove a travel location:
# /dtraveler remove [NameOfTravelLocation]  ## [NameOfTravelLocation] is the name of the location you want to remove

# | To go to a travel location without using an NPC:
# /dtravel goto [NameOfTravelLocation]      ## [NameOfTravelLocation] is the name of the location you want to go to

# | Player interaction:
# Click on a dTraveler to unlock it.
# You can speak the name of any travel location to a traveler to go there.
# You can also say 'list' to a traveler to see what locations you've unlocked.

# | Commands:
# /dtraveler add [NameOfTravelLocation]     ## Adds a travel location
# /dtraveler remove [NameOfTravelLocation]  ## Removes a travel location
# /dtravel goto [NameOfTravelLocation]      ## Teleports you to a travel location
# /dtraveler name [NameOfTravelLocation]    ## Links an NPC to a travel location
# /dtraveler unname                         ## Unlinks an NPC from its travel location

# | Permissions:
# denizen.scripts.dtravelers.add            ## Use the 'add' and 'remove' commands
# denizen.scripts.dtravelers.goto           ## Use the 'goto' command
# denizen.scripts.dtravelers.name           ## Use the 'name' and 'unname' commands
# denizen.scripts.dtravelers.[NameOfLoc]    ## Permits travel to a given travel location even if you haven't unlocked it

dtraveler_world_commands:
    type: world
    events:
        on dtraveler command:
        - determine passively fulfilled
        - IF <player> == "null" {
          - announce to_console format:dtraveler_format_warning "<&4>Only players can use this command!"
          - queue clear
          }
        - if <player.has_permission[denizen.scripts.dtravelers.goto]> != "true" && <player.has_permission[denizen.scripts.dtravelers.add]> != "true" && <player.has_permission[denizen.scripts.dtravelers.name]> != "true" {
          - narrate format:dtraveler_format_warning "You do not have permission to use this command."
          - queue clear
          }
        - if <context.args.size> == 2 && <context.args.get[1]> == "add" {
          - run dtraveler_command_add instantly def:<context.args.get[2]>
          - queue clear
          }
        - if <context.args.size> == 2 && <context.args.get[1]> == "remove" {
          - run dtraveler_command_remove instantly def:<context.args.get[2]>
          - queue clear
          }
        - if <context.args.size> == 2 && <context.args.get[1]> == "goto" {
          - run dtraveler_command_goto instantly def:<context.args.get[2]>
          - queue clear
          }
        - if <context.args.size> == 2 && <context.args.get[1]> == "name" {
          - run dtraveler_command_name instantly def:<context.args.get[2]>
          - queue clear
          }
        - if <context.args.size> == 1 && <context.args.get[1]> == "unname" {
          - run dtraveler_command_unname instantly
          - queue clear
          }
        - narrate format:dtraveler_format_warning "Incorrect command arguments..."
        - narrate "<&c>/dtraveler add [NameOfTravelLocation]"
        - narrate "<&c>/dtraveler remove [NameOfTravelLocation]"
        - narrate "<&c>/dtraveler goto [NameOfTravelLocation]"

dtraveler_command_goto:
    type: task
    script:
    - if <player.has_permission[denizen.scripts.dtravelers.goto]> != "true" {
      - narrate format:dtraveler_format_warning "You do not have permission to use this command."
      - queue clear
      }
    - flag server dtraveler_cutoff:false
    - repeat <server.flag[dtraveler_location_names].size> {
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag server dtraveler_cutoff:true
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag player dtraveler_target:<server.flag[dtraveler_locations].get[%value%]>
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% run dtraveler_task_travel delay:1t
      }
    # Note: Repetition above is intentional for complex reasons.
    - if <server.flag[dtraveler_cutoff]> == "true" {
      - queue clear
      }
    - narrate format:dtraveler_format_warning "That travel location doesn't exist!"

dtraveler_command_name:
    type: task
    script:
    - if <player.has_permission[denizen.scripts.dtravelers.name]> != "true" {
      - narrate format:dtraveler_format_warning "You do not have permission to use this command."
      - queue clear
      }
    - if <player.selected_npc> == "null" {
      - narrate format:dtraveler_format_warning "You must have a selected NPC to use this command."
      - queue clear
      }
    - flag server dtraveler_cutoff:false
    - repeat <server.flag[dtraveler_location_names].size> {
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag server dtraveler_cutoff:true
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag <player.selected_npc> dtraveler_name:%1%
      }
    # Note: Repetition above is intentional for complex reasons.
    - if <server.flag[dtraveler_cutoff]> == "true" {
      - narrate format:dtraveler_format_valid "NPC successfully linked to travel location '<&b>%1%<&2>'."
      - queue clear
      }
    - narrate format:dtraveler_format_warning "That travel location doesn't exist!"

dtraveler_command_unname:
    type: task
    script:
    - if <player.has_permission[denizen.scripts.dtravelers.name]> != "true" {
      - narrate format:dtraveler_format_warning "You do not have permission to use this command."
      - queue clear
      }
    - if <player.selected_npc> == "null" {
      - narrate format:dtraveler_format_warning "You must have a selected NPC to use this command."
      - queue clear
      }
    - flag <player.selected_npc> dtraveler_name:null
    - narrate format:dtraveler_format_valid "NPC successfully unlinked from any travel locations."

dtraveler_command_add:
    type: task
    script:
    - if <player.has_permission[denizen.scripts.dtravelers.add]> != "true" {
      - narrate format:dtraveler_format_warning "You do not have permission to use this command."
      - queue clear
      }
    - flag server dtraveler_cutoff:false
    - repeat <server.flag[dtraveler_location_names].size> {
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag server dtraveler_cutoff:true
      }
    - if <server.flag[dtraveler_cutoff]> == "true" {
      - narrate format:dtraveler_format_warning "That travel location already exists!"
      - queue clear
      }
    - flag server dtraveler_location_names:->:%1%
    - flag server dtraveler_locations:->:<player.location>
    - narrate format:dtraveler_format_valid "Added travel location '<&b>%1%<&2>'!"

dtraveler_command_remove:
    type: task
    script:
    - if <player.has_permission[denizen.scripts.dtravelers.remove]> != "true" {
      - narrate format:dtraveler_format_warning "You do not have permission to use this command."
      - queue clear
      }
    - flag server dtraveler_cutoff:false
    - repeat <server.flag[dtraveler_location_names].size> {
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag server dtraveler_cutoff:true
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag server dtraveler_locations[%value%]:<-
      - if <server.flag[dtraveler_location_names].get[%value%]> == %1% flag server dtraveler_location_names[%value%]:<-
      }
    # Note: Repetition above is intentional for complex reasons.
    - if <server.flag[dtraveler_cutoff]> == "true" {
      - narrate format:dtraveler_format_valid "Travel location successfully removed."
      - queue clear
      }
    - narrate format:dtraveler_format_warning "That travel location doesn't exist!"

dtraveler_assign:
    type: assignment
    actions:
        on assignment:
        - TRIGGER name:click state:true
        - TRIGGER name:chat state:true
    interact scripts:
    - 10 dtraveler_interact_main

dtraveler_interact_main:
    type: interact
    steps:
        1:
            click trigger:
                script:
                - if <npc.flag[dtraveler_name]> != "null" && <player.flag[dtraveler_named_<npc.flag[dtraveler_name]>]> != "true" {
                  - flag player dtraveler_named_<npc.flag[dtraveler_name]>:true
                  - narrate format:dtraveler_format_valid "You've found a new travel location!"
                  - playsound <player.location> level_up
                  }
                - chat "<&2>Hello there, <player.name>!"
                - wait 1
                - if <npc.flag[dtraveler_name]> != "null" {
                  - chat "<&2>I'm <&b><npc.name.nickname><&2>, the official travel master of <&b><npc.flag[dtraveler_name]><&2>!"
                  }
                  else {
                  - chat "<&2>I'm <&b><npc.name.nickname><&2>, an official serverwide travel master!"
                  }
                - wait 2
                - chat "<&2>My job is to take you places you've been before. Simply name the place and I'll get you there."
                - ^flag player dtraveler_hasresponded:false
                - run dtraveler_task_hello delay:10s
            chat trigger:
                1:
                    trigger"I need to see a /list/ of what places I've unlocked..."
                    script:
                    - ^flag player dtraveler_hasresponded:true
                    - wait 1
                    - flag player dtraveler_temptext:<&2>
                    - foreach <server.flag[dtraveler_location_names].aslist> {
                      - flag player dtraveler_temp:%value%
                      - if <proc:dtraveler_proc_cantravel> flag player "dtraveler_temptext:<player.flag[dtraveler_temptext]>%value%, "
                      }
                    - if <player.flag[dtraveler_temptext].length> < 4 {
                      - chat "<&2>Well, I'm sorry. It seems you haven't unlocked any travel locations yet."
                      }
                      else {
                      - chat "<&2>If I've heard right, you've been to the following locations<&co>"
                      - narrate "<player.flag[dtraveler_temptext]>"
                      }
                    - wait 2
                    - if <player.flag[dtraveler_temptext].length> >= 4 chat "<&2>So... which one would you like to go to?"
                2:
                    trigger"/REGEX:.+/"
                    script:
                    - ^flag player dtraveler_hasresponded:true
                    - wait 1
                    - ^flag player dtravel_success:false
                    - ^repeat <server.flag[dtraveler_location_names].size> {
                      - flag player dtraveler_temp:<server.flag[dtraveler_location_names].get[%value%]>
                      - ^if <context.message> contains <server.flag[dtraveler_location_names].get[%value%]> && <proc:dtraveler_proc_cantravel> {
                        - ^chat "<&2>To <server.flag[dtraveler_location_names].get[%value%]>? Alright then..."
                        - ^flag player dtraveler_target:<server.flag[dtraveler_locations].get[%value%]>
                        - ^run dtraveler_task_travel delay:1t
                        - ^flag player dtravel_success:true
                        }
                      }
                    - ^if <player.flag[dtravel_success]> != "true" {
                      - ^chat "<&2>You haven't unlocked such a location."
                      }
                    - wait 1
                    - if <player.flag[dtravel_success]> != "true" {
                      - narrate format:dtraveler_format_valid "If you've forgotten where you've been, just say <&b>list<&2> to the travel master!"
                      }

dtraveler_proc_cantravel:
    type: procedure
    script:
    - if <player.flag[dtraveler_named_<player.flag[dtraveler_temp]>]> == "true" { - determine "true" }
      else if <player.has_permission[denizen.scripts.dtravelers.<player.flag[dtraveler_temp]>]> { - determine "true" } else { - determine "false" }

dtraveler_task_hello:
    type: task
    script:
    - if <player.flag[dtraveler_hasresponded]> == "true" {
      - queue clear
      }
    - if <player.location.distance[<npc.location>]> > 20 {
      - queue clear
      }
    - narrate format:dtraveler_format_valid "If you've forgotten where you've been, just say <&b>list<&2> to the travel master!"

dtraveler_task_travel:
    type: task
    script:
    - narrate format:dtraveler_format_valid "Traveling..."
    - ^playsound <player.location> portal_travel
    - ^playeffect <player.location> large_explode
    - ^cast blindness duration:5s
    - cast confusion duration:8s
    - wait 1
    - teleport <player> <player.flag[dtraveler_target]>
    - ^playsound <player.location> portal_travel
    - playeffect <player.location> large_explode

dtraveler_format_warning:
    type: format
    format"<&7>[<&2>dTravelers<&7>]<&c><text>"

dtraveler_format_valid:
    type: format
    format"<&7>[<&2>dTravelers<&7>]<&2><text>"





View History