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

Add attributes to characters and assign a default value

1593630915

Edited 1593631169
Hi, I'm looking for a way to add attributes to characters (preferably only specific ones in a folder) and assign them a default value. Is this possible? For context I'm looking for a way to add pronoun attributes to characters (ie subjective, objective, possessiveA, and possessiveP) and assign them the default value of {it, it, its, and its} respectively so I can consolidate my macros that refer to a character's gender (ie "Yami ends her turn") into a single one like `/o &{template:desc} {{desc=@{selected|token_name} ends @{selected|PossessiveA} turn}}` It should look like that if at all possible.
1593636184
David M.
Pro
API Scripter
Check out the documentation for the API script ChatSetAttr in the drop down menu for 1-click API installs. I think it should be able to what you are looking for.
1593640992

Edited 1593641008
David M.  said: Check out the documentation for the API script ChatSetAttr in the drop down menu for 1-click API installs. I think it should be able to what you are looking for. After figuring out syntax (and the fact that I couldn't use multiple in one line) that worked great! Thanks!
1593705387

Edited 1593706403
I created a set of macros using the API to generate attributes for characters to refer to their pronouns for use in macros. I currently have it set up with 3 macros, each with 4 lines because I can't add multiple attributes with a single command. How can I use a macro to query which set (male, female, or neutral) of pronouns I want to use? I know I should be able to do something like  ?{Male, Female, or Neutral? | Male,#Pronouns_M | Female,#Pronouns_F | Neutral,#Pronouns_N} And that should work, but I'd rather have it where the  contents of those sub-macros are in the main one and delete the sub-macros. Problem is, each of the sub macros is 4 lines such as #Pronouns_F !setattr --sel --subjective|'she' !setattr --sel --objective|'her' !setattr --sel --PossessiveA|'her' !setattr --sel --PossessiveP|'hers' Is this a thing I can do or do I have to settle for the sub macros?
1593724699
GiGs
Pro
Sheet Author
API Scripter
Do those macros actually work? When run from a query, the pips ('|' symbols) will break the query because they are read as a row separator. ChatSetAttr supports an alternate separator for situations like this, which is IIRC an #. So the above should be !setattr --sel --subjective#'she' !setattr --sel --objective#'her' !setattr --sel --PossessiveA#'her' !setattr --sel --PossessiveP#'hers' Back to your actualy question. You can include multiple lines in a query. here's the example above inserted in your query: ?{Male,Female, or Neutral?|Male,#Pronouns_M|Female,!setattr --sel --subjective#'she' !setattr --sel --objective#'her' !setattr --sel --PossessiveA#'her' !setattr --sel --PossessiveP#'hers'|Neutral,#Pronouns_N} I removed unneccesary spaces. Note that spaces are not ignored in queries, so you need to be careful not to include spaces in places where things have unintended consequences.
1593734028

Edited 1593734181
GiGs said: Do those macros actually work? When run from a query, the pips ('|' symbols) will break the query because they are read as a row separator. ChatSetAttr supports an alternate separator for situations like this, which is IIRC an #. So the above should be !setattr --sel --subjective#'she' !setattr --sel --objective#'her' !setattr --sel --PossessiveA#'her' !setattr --sel --PossessiveP#'hers' Back to your actualy question. You can include multiple lines in a query. here's the example above inserted in your query: ?{Male,Female, or Neutral?|Male,#Pronouns_M|Female,!setattr --sel --subjective#'she' !setattr --sel --objective#'her' !setattr --sel --PossessiveA#'her' !setattr --sel --PossessiveP#'hers'|Neutral,#Pronouns_N} I removed unneccesary spaces. Note that spaces are not ignored in queries, so you need to be careful not to include spaces in places where things have unintended consequences. Funny that you mention that, I ran into the pipe issue myself. I finally got around to fixing it with some help from the rpg stackexchange site's chat. Turns out you can  in fact also put multiple attributes into a single command as well and I must've messed up when first doing it. In any case, this was the final version I came up with (but it needed to be saved as an ability due to HTML replacements for |) ?{Male, Female, Neutral, or Monster? | Male,!setattr --sel --subjective|'he' --objective|'him' --PossessiveA|'his' --PossessiveP|'his' | Female,!setattr --sel --subjective|'she' --objective|'her' --PossessiveA|'her' --PossessiveP|'hers' | Monster,!setattr --sel --subjective|'it' --objective|'it' --PossessiveA|'its' --PossessiveP|'its' | Neutral,!setattr --sel --subjective|'they' --objective|'them' --PossessiveA|'their' --PossessiveP|'theirs'} But it IS nice to know I can add multiple lines in there like that.
1593737529
GiGs
Pro
Sheet Author
API Scripter
I held off suggesting the html entities approach because its pretty clunky. Be aware if you save this in a macro, you cannot ever reopen that macro without it erasing all the html entities. Such macros are best saved on a Character Sheet in the Abilities section, where this problem doesnt occur.
1593739006

Edited 1593739030
GiGs
Pro
Sheet Author
API Scripter
Looking at the macro you are using, you should be able to get rid of all the  | entities. Just swap them with hashes # and not have to worry about html replacement: ?{Male, Female, Neutral, or Monster? | Male,!setattr --sel --subjective#'he' --objective#'him' --PossessiveA#'his' --PossessiveP#'his' | Female,!setattr --sel --subjective#'she' --objective#'her' --PossessiveA#'her' --PossessiveP#'hers' | Monster,!setattr --sel --subjective#'it' --objective#'it' --PossessiveA#'its' --PossessiveP#'its' | Neutral,!setattr --sel --subjective#'they' --objective#'them' --PossessiveA#'their' --PossessiveP#'theirs'} Also, how did you get the text to wrap over multiple lines in that code block without using linebreaks?
GiGs said: Also, how did you get the text to wrap over multiple lines in that code block without using linebreaks? I think that might've been a function from my having copied it from the rpg stackexchange
1594065913
GiGs
Pro
Sheet Author
API Scripter
That makes sense. Roll20 does keep tyhe formatting from places you copy. Shame, I hoped there was an easy way to force it within the roll20 editor.
GiGs said: That makes sense. Roll20 does keep tyhe formatting from places you copy. Shame, I hoped there was an easy way to force it within the roll20 editor. That'd be too easy though! Also, if you really want it, you can always type it up as a question (using full markdown/commonmark or HTML) on rpg se and it shows a preview you can copy from (and then discard the question if it's not something you actually need to ask). Not the ideal method but it works since Roll20's forums are this way. 
1594071959
GiGs
Pro
Sheet Author
API Scripter
Thanks for the suggestion. Its a bit convoluted, but I already have to do things like that for some posts so I may try it.
1594079114
Oosh
Sheet Author
API Scripter
Right, so putting this into an online HTML editor and pasting the output seems to work: <span style="white-space:pre-wrap">ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggblahblahblah</span> ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggblahblahblah I just used the w3schools editor, but I'm a numpty with HTML. Is there a simple Notepad style HTML editor that I could use instead?
1594079578
GiGs
Pro
Sheet Author
API Scripter
notepad style html editors usually dont apply any kind of formatting, because they are for programming, and smart formatting tends to mess up code. 
1594079942
GiGs
Pro
Sheet Author
API Scripter
The w3schools editor works even if you dont include the span and style, just the raw text, btw. This was pasted exactly as is in the left pane. bla bla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla blabla 
1594080704
GiGs
Pro
Sheet Author
API Scripter
I just posted this tip to the stupid tricks form, thanks Himitsu for the original idea and Oosh for the new site suggestion.
1594086266
Oosh
Sheet Author
API Scripter
Nice, even easier! I guess a CSS Stylus change should work, too, so it won't matter to me whether the person posting knows this trick or not. Horizontal scroll bars are to work of the devil.
1594086843
GiGs
Pro
Sheet Author
API Scripter
CSS Stylus only work for people who have it installed. I want to make the code blocks more accessible to everyone who reads the thread.
1594095815
Oosh
Sheet Author
API Scripter
Yep! I never claimed to care about other people! Really though, I was more thinking of the fact that people posting long lines of code may not read the Stupid Tricks thread, so a CSS style could still save my mouse from a horrible death when it tries to select the entire screen instead of the code box.
1594100006
GiGs
Pro
Sheet Author
API Scripter
hehe, fair enough.