Hello again,
Pretty new to macros, but I understand how to write them and the basic functions.
I am looking for a tutorial or example that will help me construct a target selection macro that will bring up a table of tokens within a player's/token's sight radius for an attack macro. I would like to avoid having the players type out and declare a target each time they attack. Is this possible?
Second question: Can you send multiple macro.args variables to a library token and then send multiple macro.returns? How would you define those extra variables?
Thanks for your time.
Trying to Find Guide or Tutorial
Moderators: dorpond, trevor, Azhrei
Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior.
Re: Trying to Find Guide or Tutorial
thats yes allover and selection based targeting is also explained on this forum...but you have to search that one.
passing on multipe vars is done by gathering them first in a json array Wiki: json.append() and retrieving them afterwards Wiki: json.get()
you can also have a look at the first link in my sig.
passing on multipe vars is done by gathering them first in a json array Wiki: json.append() and retrieving them afterwards Wiki: json.get()
you can also have a look at the first link in my sig.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Trying to Find Guide or Tutorial
There are a lot of topics on targetting...Raebit wrote:I am looking for a tutorial or example that will help me construct a target selection macro that will bring up a table of tokens within a player's/token's sight radius for an attack macro. I would like to avoid having the players type out and declare a target each time they attack. Is this possible?
Here is one that might get you started about thinking what you can do: http://forums.rptools.net/viewtopic.php ... targetting
It's an old thread, but some good info in there. You can download some existing frameworks and see how other people are doing it these days, too.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
Re: Trying to Find Guide or Tutorial
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: Trying to Find Guide or Tutorial
I wrote this targeting macro awhile ago:
http://forums.rptools.net/viewtopic.php ... 9&#p203749
Here's my latest incarnation of finding targets:
keywords: amsave targeting
http://forums.rptools.net/viewtopic.php ... 9&#p203749
Here's my latest incarnation of finding targets:
||| getSeenTargets(options,source) |||
Code: Select all
<!-- getSeenTokens(options,source): json array or object
options (strprop or json object)
pc - 0 any token, 1 - PC only
npc - 0 any token, 1 - NPC only
range - upto this distance in grid units (ie feet, and not grid squares); 0 - any range
self - 0 do not include self, 1 include self
source = source token, defaults to currentToken
This function will get a list of tokenIds based on the current tokens vision
-->
[H, if(argCount()): options = lower(arg(0)); options = "{}"]
[H, if(argCount() >= 2): sourceToken = arg(1); sourceToken = currentToken()]
<!-- verify token is on current map -->
[H: sourceToken = findToken(sourceToken)]
[H: assert(! json.isEmpty(sourceToken),"<b>getSeenTokens(options,source):</b> Token not found on current map.",0)]
<!-- define options locally -->
[H: defaults = json.set("{}","pc",0,"npc",0,"range",0,"self",0)]
[H, if(json.type(options) == "UNKNOWN" && ! json.isEmpty(options)): options = json.fromStrProp(options)]
[H, if(json.isEmpty(options)): options = defaults; options = json.merge(defaults,options)]
[H: varsFromStrProp(json.toStrProp(options))]
<!-- get token ids -->
[H: conditions = "{}"]
[H, if(npc && ! pc): conditions = json.set(conditions,"npc",npc)]
[H, if(! npc && pc): conditions = json.set(conditions,"pc",pc)]
[H, if(range): conditions = json.set(conditions,"range",json.set("{}","token",sourceToken,"upto",range,"distancePerCell",1))]
[H, if(! json.isEmpty(conditions)): tokenIds = getTokens("json",conditions); tokenIds = getTokens("json")]
<!-- exclude self if set -->
[H, if(self), code: {
[H, if(! json.isEmpty(tokenIds)): tokenIds = json.union(tokenIds,json.append("",sourceToken)); tokenIds = json.append("",sourceToken)]
};{
[H, if(! json.isEmpty(tokenIds)): tokenIds = json.difference(tokenIds,json.append("",sourceToken)); tokenIds = "[]"]
}]
<!-- check each id for name and visible -->
[H: targets = "[]"]
[H: hasSight = hasSight()]
[H, if(! hasSight()): setHasSight(1)] <!-- this works for NPC tokens too -->
[H, foreach(tokenId,tokenIds), code: {
[H: canSee = ! json.isEmpty(canSeeToken(tokenId))]
[H, if(canSee): targets = json.append(targets,tokenId)]
}]
[H, if(hasSight != hasSight()): setHasSight(hasSight)]
[H: macro.return = targets]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: Trying to Find Guide or Tutorial
Wow, thank you Wolf, Full Bleed, and again, Alias! That should keep me busy for a while. Much option! (forgive my doge...)