Target a Visible NPC: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m (Target Visible NPCs moved to Target a Visible NPC: Ambiguous title) |
(No difference)
|
Revision as of 19:29, 7 December 2009
Note: This function can only be used in a Trusted Macro
This macro allows a player to pick-up a NPC among those he can currently see. Note that this is about the player's view and not the currently selected token's view. You may then store the target's name in the token's properties to ease further actions.
Basically, the macro gets the list of all NPCs available (with getNPCNames()) and the list of all visible tokens (with getVisibleTokenNames()). Then, the intersection will provide visible NPCs.
Macro
1.3b53+
/self
[h: lsVisibleNpc = json.intersection( getNPCNames("json"), getVisibleTokenNames("json") )]
// Abort if no target found (intersection returned an empty list)
[h: assert(json.length(lsVisibleNpc), "No visible NPC", 0)]
// UI: popup a list for selection
[h: input("index|"+json.toList(lsVisibleNpc)+"|My target is|LIST") ]
// Retrieve the first element, so we only get the name (and not ["name"])
[h: currentTgt = json.get(listGet(lsVisibleNpc, index),0) ]
// Display message to be sure of what has just been done
Current target : {currentTgt}