Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] Mark -- Places a numbered marker under each supplied token, clears on turn change/end of combat/page change.

August 02 (10 years ago)

Edited February 10 (9 years ago)
The Aaron
Roll20 Production Team
API Scripter
Update: v0.3.1 -- Removed dependency on isGM.
Update v0.22 -- Removed direct use of HTML entities to prevent the substitution bug.
Update: v0.21 -- Removed some debug logging. (Thanks Vince!)
Update: v0.2 -- Added a public function Reset(), which can be called from other scripts to clear the markers, such as my Turn Marker script.

Allows players to mark tokens to a facilitate their GM keeping track of what they are targeting.

Here's theoretical use:
!mark @{target|Target 1|token_id}
Hit? [[ {1d20+4}>@{target|Target 1|AC} ]]
!mark puts a marker on the target, then the next line of the macro uses that target as part of a calculation.

Markers are cleared out when the turn changes, when the turn order is closed, or when the player's page is changed. Supports players that are not on the same page. !mark-clear command for GMs to clear marks without affecting turn order.

Here's the full command help: (accessible via just the bare !mark command.)


Example of some marks:


Markers are scaled to the size of the token being marked. Support for up to 7 digits worth of marks:


Git: https://github.com/shdwjk/Roll20API/blob/master/Ma...
If you use my scripts, want to contribute, and have the spare bucks to do so, go right ahead. However, please don't feel like you must contribute just to use them! I'd much rather have happy Roll20 users armed with my scripts than people not using them out of some sense of shame. Use them and be happy, completely guilt-free!
Disclaimer: This Patreon campaign is not affiliated with Roll20; as such, contributions are voluntary and Roll20 cannot provide support or refunds for contributions.
Cool!
No way to show number of successes as well as the total rolled :/
Dang, script is blowing up:

For reference, the error message generated was: ReferenceError: msg is not defined at evalmachine.<anonymous>:865:17 at eval (
August 03 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Eh? Can you post your macro?
It's for all my campaigns with it, but even with just your 3, IsGM, IsTokenInitiative, and Mark turned on. You can see it in the one I still have you as co GM.
!mark @{target|Target 1|token_id} Hit? [[ {1d20+4}>@{target|Target 1|AC} ]]
Hit part works, the Mark part blows up my API session
August 03 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
You need a return before Hit? !mark only accepts token ids. I'll add better argument validation.

You our can add a return in chat without submitting by pressing shift-return. In macros, just press return.
August 03 (10 years ago)

Edited August 03 (10 years ago)
I added a return, still the same error :/

!mark @{target|Target 1|token_id}

August 03 (10 years ago)

Edited August 03 (10 years ago)
Ok, added it from chat here entering a Shift Enter, it seems to show the command
and the token ID, but doesn't add the graphic.

Still erroring sometimes. (hasn't created the image at all yet)
!mark -JSuar2BiQopIMQkxq0Q

That's what it is saying in chat, sometimes it just shows this, sometimes it blows up. (no images). Have IsGm, Has 1.17 TokenInitiative.
August 03 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Hmm. Guess I'll be jumping in that campaign to check...
August 03 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Solved. It wasn't actually in the Mark Script.

Somehow, a /* had been placed before bold line below (in the TurnMarker script), which caused all of the underlined to be treated as comments:
        on("change:graphic", function(obj,prev) {
           /* TurnMarker.CheckForTokenMove(obj);
        });
 
        on("chat:message", function (msg) {
            /* Exit if not an api command */
            if (msg.type != "api") return;
That caused the if (msg.type != api) return; line to be executed for the mark graphic being moved. It would actually have happened for any object being changed, you just happened to be hitting it in the mark script.

That /* isn't in the GIST of the TurnMarker, so it must have been accidentally inserted.

It's cleared up in your copy now. Enjoy!
Thank you, that is my fault. I forgot the */ after I had to comment it ago again after I updated to your latest version. You probably hate me. :/ Lol
August 03 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Hahahah, no worries.

Out of curiosity, do you comment it out because you don't want the TurnMarker to follow the person whose turn it is?

BTW, you can use // to comment out a line. In the editor, you can comment out a selection by hitting ⌘-/ (Probably ctrl-/ on Windows?)
Yeah, I commented out the line in the last version. I was in a rush when I did add the /*. I never tested it for this one, :(.

I might have run it briefly, but even running it now briefly before fixing it, it took a little bit for it to error.

Thanks again. Now I just have to tie it into my character sheet.

August 04 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Bryan K. Said:
I can't figure out in your Mark script where you are setting the red status marker. I'm looking to switch it to the bullseye marker.
The function on line 52 takes a number and converts it into a series of status dots with numbers on them:
	getStatusForCount = function(count) {
		var colorOrder=["red", "blue", "green", "brown", "purple", "pink", "yellow"];
		    return _.chain(count.toString().split(''))
			.reduce(function(memo,d){
				if(colorOrder.length) {
					 memo.push(colorOrder.shift()+'@'+d);
				} 
				return memo;
			}, [])
			.value()
			.reverse()
			.join(',');
	},

If you want the first status to be the bullseye, change the colorOrder on line 53 to this:
var colorOrder=["archery-target", "red", "blue", "green", "brown", "purple", "pink", "yellow"];
So what after you assign 9 of the first one, it moves on to the next?

I was actually wondering if it could take advantage of the multiple status numbers from the "fly" script which allows for multiple digits. It seems like if you target the same target multiple times, it keeps adding another image with another counter. It seems a bit messy/cluttered. Instead, although it may be confusing if it goes over 9, but I can't imagine that happening often.
August 04 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Markers are scaled to the size of the token being marked. Support for up to 7 digits worth of marks:


Above is the 1,234,567 mark applied for the current turn... Probably 9,999,999 is higher than anyone would go, but hey.. supported! (of course your version with the added status would support up to 99,999,999 marks, with the bullseye as the leading digit. =D )

The status marker digits are handled by the getStatusForCount() function. Here's a breakdown :
// Consider for count = 14
getStatusForCount = function(count) {

		// List of status names to use for digits
		var colorOrder=["red", "blue", "green", "brown", "purple", "pink", "yellow"];

		    // convert the number to a string, split on '', then chain on the resulting array
		    return _.chain(count.toString().split('')) // count == ['1','4']

// apply this function to each entry
// memo is [] initially, then whatever is returned on each iteration
// d will be '1' the first time, '4' the second time .reduce(function(memo,d){ // Make sure there are still statuses to use if(colorOrder.length) { // .shift() pulls the first entry out and returns it. // it will be 'red' the first time, then 'blue' memo.push(colorOrder.shift()+'@'+d); // memo will be ['red@1'] the first time, // then ['red@1','blue@4'] } return memo; }, []) // this is where the memo is initially set to [] // this removes the memo array from the underscore.js wrapper .value() // returns ['red@1','blue@4'] // this reverses the digits as statuses are stacked from right to left .reverse() // returns ['blue@4','red@1'] // turns the array in the a string for the status .join(','); // returns 'blue@4,red@1' },


August 04 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Additionally, it will only add another mark ring to the target if you mark it again on the same turn. I could probably prevent that, but it seems like there might be times when you would want to mark something with a second spell or attack and not confuse it with the first, though it is confusing to cover them I suppose...
Aaron: marking the target twice can be confusing, it caught me out the first few times. perhaps have it check the target square as it targets, and have it increase the marker tokens size and use a different color for the marker each instance that is run? a second way of doing it is to have it use red by default, then switch a second conditional is added at the end: for example a character that is harming a target AND healing a person
(it can happen after all, in several games. in my case its gurps, a vampiric attack that sucks life from one target and tranfers it to the next) in one turn could either run it twice and change the marker for the second attack without closing the first, or combine the two:

!tm @target|damage?|token_id}
!tm @target|heal?|token_id}:green
or
!tm @{target|damage?|token_id} @{target|heal?|token_id}:green
August 04 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Cool. I love feature requests. I'll see what I can do.

Anything else out there anyone wants to see in this script?
yup. but for your other scripts. i feel like such a user lol
August 04 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Well, feel free to post on those with feature requests. I'm working on an updated version of my turn marker script right now. (and I promised Jarret I'd work on the calendar one.. =D )
Any idea how I can get this to work well with other target macros, I am following the same format in the macros and it is asking for a target 1 then a target 0 even though I don't ever have a target 0.

Ideas?

\n!mark @{target|Target 1|token_id}\n/w gm Target's AC @{target|Target 1|AC} Acid - [[1d20>19]] On Fail - Loses 1 AC PERM [[ 1d20 + @{target|Target 1|dexterity_mod} ]]


Oh, it's because I am putting it in the [[ ]], isn't it. I think I ran into this issue before. I'll have to test it tonight.

August 11 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
What you've typed worked fine for me... Let me know if you have any other issues..
It worked, but it only asked for one target, not two?
Maybe because I am piecing it together in a macro with multiple drop downs?
August 11 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
If you use the same name in a @{target|...} selector, it will only ask once and reuse the existing target, "Target 1" in this case.
See that's what I thought too. I'm thinking somehow there is a bug with using [[ ]] and also using other attributes which carry that same Target 1.
August 11 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Can you paste the full macro that's having issues?
<select name="attr_focusenchant">
<option value="Acid - [[1d20>17]] On Fail - Loses 1 AC PERM [[ 1d20 + @{target|Target 1|dexterity_mod} ]]">Acid Level 2</option>

<select name="attr_savestat">
<option value="STR">STR</option>

name="attr_customsavedc" value="0"

<select name="attr_spellslotused">
<option value="">None/Cantrip</option> (empty string)

<select name="attr_targetsavestat">
<option value="/w gm Target's @{savestat} [[ 1d20 + @{target|Target 1|strength_mod} ]] | [[ 1d20 + @{target|Target 1|strength_mod} ]]">STR</option>

@{spellname} (can be test for testing purposes - any - doesn't matter)

/em uses @{spellname} to attack\n\nDC [[@{spellsavedc} + @{customsavedc}]] @{savestat} saving throw\nOn a successful save :\n@{savesuccess}\n@{spellslotused} \n!mark @{target|Target 1|token_id} \n@{targetsavestat}@{focusenchant}


Without the focus enchant part it was only asking for Target 1, Now it asks for Target 1 and Target 0 :/
August 11 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
hmm... character sheet macros are not something I've ever tinkered with. Might want to ask about that in Character Sheets. Try replacing !mark with Would Mark: and see if you still get asked for Target 0.
I apparently was missing a close select. I will test it tonight and let you know if there is still an issue.
August 11 (10 years ago)
The Aaron
Roll20 Production Team
API Scripter
Cool.
Yes, the list of features a character sheet being able to handle is infinite. :)

I added custom enchants to my d&d 5e world so players can gain more flavor for specific character concepts. :)

I just had to add multiple attack handling for necromancers having an army all attacking the same target for a number of successes.

Always more work to do. :)