Sure, this is pretty straightforward, especially since you already have a chat menu set up. This is actually a much better solution than what I did above. At the bottom is an example for a 2-target range finder. You may notice that we removed the BuildAndAskTargets function completely, since each will be hardcoded. To edit for a different number of targets, just adjust the "numTargets" roll variable and add the appropriate number of "&target1", "&target2", etc. string variables. Look for this code block in the macro at the bottom: --:SET NUM TARGETS|
--=numTargets|2
--&target1|@{target|Target 1|token_id}
--&target2|@{target|Target 2|token_id} Also adjust the title, obviously. Of course, if you don't want the additional chat output with the icons, etc., just update the first line to --#hidecard|1 !script {{
--#hidecard|0
--#title|Hex (H) Range Example - 2 Target
--#emoteState|0
--#sourceToken|@{selected|token_id}
--#activepage| [*C:playerpageid]
--=snapIncr|[*P:snapping_increment]
--:SET NUM TARGETS|
--=numTargets|2
--&target1|@{target|Target 1|token_id}
--&target2|@{target|Target 2|token_id}
--:LOOP THROUGH THE TOKEN IDS AND CALC RANGE FOR EACH| then, display the token image, name, and range in chat
--=i|0
--:RangeLoop|
--=i|[$i]+1
--&thisID|[&target[$i.Raw]]
-->CalcRange|[*[&thisID]:t-left];[*[&thisID]:t-top];[$i.Raw]
--+[img width=30][*[&thisID]:t-imgsrc][/img]|[b]Target [$i.Raw]:[*[&thisID]:t-name], Range = [$tokDist][/b]
--?[$i] -lt [$numTargets]|RangeLoop
--X| End Macro
--:FUNCTIONS|
--:CalcRange| accepts 1-TargetX coord, 2-TargetY coord, 3-Target number
--:TRANSFORM COORDS WITH SELECTED AS ORIGIN| transform according to <a href="https://stackoverflow.com/questions/15919783/distance-between-2-hexagons-on-hexagon-grid" rel="nofollow">https://stackoverflow.com/questions/15919783/distance-between-2-hexagons-on-hexagon-grid</a>
--=Sx|0
--=Sy|0
--=Tx|[%1%] - [*S:t-left] / [$snapIncr] / 69.5851274903772 *10 {FLOOR} /10 {CEIL}
--=Ty|[%2%] - [*S:t-top] / [$snapIncr] / 79.6887899835037 *10 {FLOOR} /10 {CEIL}
--=u1|[$Sx]
--=v1|[$Sx] / 2 {FLOOR} + [$Sy]
--=u2|[$Tx]
--=v2|[$Tx] / 2 {FLOOR} + [$Ty]
--=du|[$u2] - [$u1]
--=dv|[$v2] - [$v1]
--:PERFORM DISTANCE CALCULATIONS|
-->CheckSign|[$du];[$dv]
--?[$SameSign] -eq 1|>DistSameSign;[$du];[$dv]|>DistOppositeSign;[$du];[$dv]
--:WRITE TO SHEET ATTRIBUTE(S)|
--@setattr|_charid @{Weapons|character_id} _rangetotarget[%3%]|[$tokDist]
--<|
--:AddSeparator|
--&TargetString|+||
--<|
--:CheckSign| du; dv
--=SameSign|0
--?[%1%] -lt 0 -and [%2%] -lt 0|=SameSign;1
--?[%1%] -ge 0 -and [%2%] -ge 0|=SameSign;1
--<|
--:DistSameSign| du; dv
--=duAbs|[%1%] {ABS}
--=dvAbs|[%2%] {ABS}
--~tokDist|math;max;[$duAbs];[$dvAbs]
--<|
--:DistOppositeSign| du; dv
--=duAbs|[%1%] {ABS}
--=dvAbs|[%2%] {ABS}
--=tokDist|[$duAbs]+[$dvAbs]
--<|
}} I know the syntax might be a bit overwhelming right now. Kind of throwing you into the Scriptcards deep end here with a bunch of techniques (loops, subprocedures, nested variable syntax, built-in functions, etc.). It is a very powerful api script, though. I like it because you can do things that would otherwise require writing and installing another script for one-off solutions. If you have specific questions about what any of it is doing, let me know. Here's a couple of explanations of things that might help your understanding: 1) nested variable syntax . The line below sets the "thisID" string variable within our loop to one of the other string variables that we defined when we set up the targets. The value [&target[$i.Raw]] resolves to "target1", "target2", etc., as we are incrementing the "i" roll variable counter. We use ".Raw" to get just the value of the roll variable without all the formatting that normally comes with it (e.g. the yellow background and tooltips). --&thisID|[&target[$i.Raw]] 2) token properties. Normally, token properties can be accessed with the syntax [*ID:attributeName]. The available properties are listed here . In the line below, we get the ID from the thisID string variable, and we are grabbing the token property "left", (the x-coordinate). [*[&thisID]:t-left] 3) subprocedures. The following line calls the "CalcRange" subprocedure and passes three parameters. The general procedure syntax is -->ProcedureName|param1;param2;... In the line below, we are passing the X & Y coordinates of the current token, along with the index of the loop counter. In the CalcRange function (found lower down in the macro), these three parameters are referenced as [%1%], [%2%], and [%3%]. Once the function is completed, the parser returns back to the point in the code that the function was called, then continues line by line. -->CalcRange|[*[&thisID]:t-left];[*[&thisID]:t-top];[$i.Raw] 4) If..then..else conditional . In the line below, we check if the SameSign roll variable is equal to 1. If so, we call the DistSameSign procedure and pass the roll variables du and dv. Else, we call the DistOppositeSign procedure and pass the same two roll variables du and dv. These procedures do the final distance calculation, and assign a value to the tokDist roll variable. --?[$SameSign] -eq 1|>DistSameSign;[$du];[$dv]|>DistOppositeSign;[$du];[$dv] 5) built-in functions. Speaking of those two procedures, you'll notice this line in the DistSameSign procedure --~tokDist|math;max;[$duAbs];[$dvAbs] This is described here in the wiki. Basically just returns the higher of the two variables duAbs and dvAbs, and assigns to the tokDist variable 6) in-line math functions. I don't have a jumplink for this one, but you can search the wiki for the text "Mathematical Functions in Roll Expressions". In the DistSameSign procedure again, you'll see this line: --=duAbs|[%1%] {ABS} Here we are taking the first parameter passed to the procedure and returning the absolute value. Then, that value is assigned to the duAbs roll variable. 7) i nline formatting . This line prints the Scriptcard output. Everything within [b]...[/b] is bolded. Everything within [img width=30]...[/img] is html formatted as an image. The wiki link describes these tags. You'll notice nested variable syntax in a couple spots for the content of these tags. --+[img width=30][*[&thisID]:t-imgsrc][/img]|[b]Target [$i.Raw]:[*[&thisID]:t-name], Range = [$tokDist][/b] Hope that helps!