Paste #5460: Untitled Paste

Date: 2014/06/19 20:23:13 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


walkNextPoint:
  type: task
  script:
  - inject %1%
  - walkto <npc> %destination%
-------------------------------------------------
    on complete navigation:
    - run walkNextPoint def:trainee1Closest
-------------------------------------------------
trainee1Closest:
# This is what you would run to start the process.
# Feel free to edit the name and the sortList definition.
  type: task
  script:
  - define sortList li@Trainee1.loc1|Trainee1.loc2|Trainee1.loc3|Trainee1.loc4|Trainee1.loc5|Trainee1.loc6|Trainee1.loc7|Trainee1.loc8|Trainee1.loc9|Trainee1.loc10|Trainee1.loc11|Trainee1.loc12|Trainee1.loc13|Trainee1.end
  - define cord z
  - define operator LESS
  - inject closestUtility
closestUtility:
# currentClosestNumber = distance to the current "best" point to be compared to in each foreach
# currentClosestName = the name of the server flag that has the current closest distance
# as well as being the closest the flag must also be the correct direction (x,y,z) as defined by %cord%
# and must be %operator% (MORE / LESS) than the npc/player's locaton.
# currently you can only use operator and cord to find distance on one axis so all points must be going forward
# on that axis.
  type: task
  script:
  - foreach <def[sortList]> {
    - define serverflag <server.flag[%value%].as_location>
    - if !<def[currentClosestNumber].exists> {
      - define currentClosestNumber <def[serverflag].distance[%location%]>
      - define currentClosestName %value%
      } else if <def[serverflag].distance[%location%].is[%operator%].than[<def[currentClosestNumber]>]> {
      - if !<def[location].%cord%.is[%operator%].than[<def[serverflag].%cord%>]> {
        - define currentClosestNumber <def[serverflag].distance[%location%]>
        - define currentClosestName %value%
        }
      }
    }
  - define destination <server.flag[%currentClosestName%]>