Paste #115766: 1123

Date: 2023/09/29 02:36:31 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


fnpc_format:
  type: format
  format: <&6><npc.name><&f><&co> <&a><[text]>

fnpc_assignment:
  type: assignment
  #list the ineract scripts
  interact scripts:
  - fnpc_interact
  actions:
    #enable relevant triggers when the assignment is set
    on assignment:
    - trigger name:click state:true
    - trigger name:chat state:true

fnpc_interact:
  type: interact
  steps:
    1:
      click trigger:
        script:
        - narrate "Hey <&c><player.name><&a>, would you like me to show you around?" format:fnpc_format
        - narrate "<&7>Respond: <&a>/Yes/ <&7>or <&c>/No/?"
      chat trigger:
        1:
          trigger: /yes/
          script:
          - narrate "Alright then, follow me!" format:fnpc_format

          #hide the main npc from the player
          - adjust <player> hide_entity:<npc>
          #create a "clone" of the npc that the player will follow
          - create player <npc.name> <npc.location> save:tour
          - define tour <entry[tour].created_npc>
          #hide the created clone from everyone but the player
          - adjust <server.online_players.exclude[<player>]> hide_entity:<[tour]>

          #loop through the original npc's anchors
          - foreach <npc.list_anchors> as:pos1:
            #walk to the current anchor in the loop
            - ~walk <[tour]> <npc.anchor[<[pos1]>]> auto_range
            #this is here instead of the "npc_trypause" task script that you had
            #check if the clone npc's distance is bigger than 5 from the players location
            - while <[tour].location.distance[<player.location>]> > 5:
              #if the tag above returns true, the commands below will run every 3 seconds
              - narrate "Try to keep up!" format:fnpc_format
              - wait 3s
            - narrate "This is the <&c><[pos1]> <&a>area." format:fnpc_format
            - wait 2s

          - foreach <npc.list_anchors> as:pos2:
            #walk to the current anchor in the loop
            - ~walk <[tour]> <npc.anchor[<[pos2]>]> auto_range
            #this is here instead of the "npc_trypause" task script that you had
            #check if the clone npc's distance is bigger than 5 from the players location
            - while <[tour].location.distance[<player.location>]> > 5:
              #if the tag above returns true, the commands below will run every 3 seconds
              - narrate "Try to keep up!" format:fnpc_format
              - wait 3s
            - narrate "This is the <&c><[pos2]> <&a>area." format:fnpc_format
            - wait 2s

          #this will narrate only when the tour npc has walked to the last anchor
          - narrate "<&a>That's it for the tour, I hope you enjoyed. Bye!" format:fnpc_format
          - wait 2s

          #this is just for the purpose of testing, once everything
          #is done I remove the clone and show the original npc to the player
          - remove <[tour]>
          - adjust <player> show_entity:<npc>

        2:
          trigger: /no/
          script:
          - narrate "Okay! Feel free to come back any time." format:fnpc_format