
I saw a simple script floating around to make an NPC patrol an area but it was hard coded for 1 NPC and had no way to change settings except in the script itself. I wanted something better and more flexible but also something that didn't use a tokens name or bars so I could still use an NPCs nameplate and stats and have them stop patrolling and join in a battle.
SO - You set the settings of the patrolling NPC in GM Notes and use the green status marker to toggle patrolling on/off. There are 2 global settings. global_delay (how long to wait between each movement) and unit_size (how big one square on your map is)
The settings in GM Notes are "Direction", "Spaces to Move", "Speed (Percentile)"
So if I put this in GM Notes:
North,5,75
The NPC will move north 5 spaces at 75% speed (With a default unit_size of 70 that means they will move approximately 7 times to traverse 5 squares) then once they reach their destination they will turn rotation of the token to the south and walk back the way they came. This repeats until the green status marker is removed from the token. You can toggle it off in mid-patrol and when you turn it back on the NPC will patrol again exactly from where they left off. Good for instances where the party stops a patrolling city watchman to ask a question and he stops his patrol then resumes it when the party leaves.
Here is a gif (CLICK TO VIEW) of 3 seperate NPCs patrolling, one at 100% speed, one at 75% speed and one at 50% speed.

Here is the gist:
https://gist.github.com/kastion/78091c172d3f2e8ea781d3dd69c0a873
Version 0.4.19
Now saving current position on patrol path so that when the list is made again for new patrol tokens it doesn't restart a patrollers path from 0.
Version 0.4.18
Settings can be changed and updated live now. You no longer need to restart the API to start new NPCs patrols.
Version 0.3.18
Added commands for changing global delay and unit size.
Version 0.2.18
Introduced more error handling. Regardless of what value GM Notes is set to it will not crash API and use default patrol settings.
Version 0.2.17
Case insensitive functionality added when specifying direction in GM Notes (Takes "North" or "north" for example)
Version 0.2.16
Error handling for GM Notes added with default patrol settings specified if omitted.
Version 0.2.15
Updates to help menu for future command integration.
Version 0.2.14
Have the core functionality working as intended.
If anyone has any suggestions for new functionality or changes I should add to this let me know.As it stands right now new PatrolNPCs are only updated and added to the list of patrolling NPCs on API startup. Didn't think much of how I could have it update live but if anyone has any suggestions on how to do that let me know I'm all ears.
EDIT:
Patrol NPCs can now be updated and will take action as soon as the green status marker is toggled. Found a way to clear my interval and do a new setInterval.
SO - You set the settings of the patrolling NPC in GM Notes and use the green status marker to toggle patrolling on/off. There are 2 global settings. global_delay (how long to wait between each movement) and unit_size (how big one square on your map is)
The settings in GM Notes are "Direction", "Spaces to Move", "Speed (Percentile)"
So if I put this in GM Notes:
North,5,75
The NPC will move north 5 spaces at 75% speed (With a default unit_size of 70 that means they will move approximately 7 times to traverse 5 squares) then once they reach their destination they will turn rotation of the token to the south and walk back the way they came. This repeats until the green status marker is removed from the token. You can toggle it off in mid-patrol and when you turn it back on the NPC will patrol again exactly from where they left off. Good for instances where the party stops a patrolling city watchman to ask a question and he stops his patrol then resumes it when the party leaves.
Here is a gif (CLICK TO VIEW) of 3 seperate NPCs patrolling, one at 100% speed, one at 75% speed and one at 50% speed.

Here is the gist:
https://gist.github.com/kastion/78091c172d3f2e8ea781d3dd69c0a873
Version 0.4.19
Now saving current position on patrol path so that when the list is made again for new patrol tokens it doesn't restart a patrollers path from 0.
Version 0.4.18
Settings can be changed and updated live now. You no longer need to restart the API to start new NPCs patrols.
Version 0.3.18
Added commands for changing global delay and unit size.
Version 0.2.18
Introduced more error handling. Regardless of what value GM Notes is set to it will not crash API and use default patrol settings.
Version 0.2.17
Case insensitive functionality added when specifying direction in GM Notes (Takes "North" or "north" for example)
Version 0.2.16
Error handling for GM Notes added with default patrol settings specified if omitted.
Version 0.2.15
Updates to help menu for future command integration.
Version 0.2.14
Have the core functionality working as intended.
If anyone has any suggestions for new functionality or changes I should add to this let me know.
EDIT:
Patrol NPCs can now be updated and will take action as soon as the green status marker is toggled. Found a way to clear my interval and do a new setInterval.