Hidden Macro and CSS macro within non lib tokens.

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
bobifle
Giant
Posts: 219
Joined: Thu Oct 19, 2017 12:36 pm

Hidden Macro and CSS macro within non lib tokens.

Post by bobifle »

Hello everyone!

I would have 2 questions about macros:

1/ can you have hidden macros, callable from other macros but without any button ?

2/ can a token macro be a CSS macro ?
I tried to use CSS macros from tokens. I never managed to do it while embedding the CSS macro into the token. The only method that worked for me was using the "myCSS@Lib:Charactersheet" macro from the DnD 5e framework.

Code: Select all

  <link rel='stylesheet' type='text/css' href='myCSS@Lib:CharacterSheet'></link>
is working, but

Code: Select all

  <link rel='stylesheet' type='text/css' href='mySpell@[r: getMacroLocation()]'></link>
Does not work (before you asked, I created a CSS mySpell macro in the token with the same CSS code.

I was reading http://www.lmwcs.com/rptools/wiki/Intro ... and_Frames

Cheers,

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Hidden Macro and CSS macro within non lib tokens.

Post by aliasmask »

1) Yes, you can use Wiki: evalMacro() to execute a string as a macro. The source of the string can be from anywhere like a hidden property.

2)Not completely sure what you mean by CSS macro, but stylesheets can only be done within a frame or dialog, not the chat. There are some limits in the stylesheet having to do with the format when using {}'s. But I think your problem may be permission related. Make sure the macro has edit by players unchecked.

edit: A note about non-lib tokens, certain function don't work if not run from a lib token macro because of permissions. This prevents players from doing stuff not allowed by the GM.

bobifle
Giant
Posts: 219
Joined: Thu Oct 19, 2017 12:36 pm

Re: Hidden Macro and CSS macro within non lib tokens.

Post by bobifle »

Thank for the quick answer !

1/ this is great, exactly what I need

2/ A CSS macro is a macro that contain only CSS code and may be used within another macro html code as stylesheet. I'll check those permissions, could be that.

Edith: well I took a look at maptool src code, it seems that CSS macro are searched only in lib tokens. That's more or less enforced by the design.

Code: Select all

void handleLinkTag(MutableAttributeSet attributes) {
  Object href = attributes.getAttribute(HTML.Attribute.HREF);
  String[] vals = href.toString().split("@");
  String cssText = MapTool.getParser().getTokenLibMacro(vals[0], vals[1]);

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Hidden Macro and CSS macro within non lib tokens.

Post by aliasmask »

There's actually nothing special about the "css macro". You can put code in there as well, but when the stylesheet is read it expects the output to be valid, for example, your style sheet could be this:

Code: Select all

[r: "
   .col1 {text-align:right}
   .col2 {font-weight:bold}
   td {width:100px}
"]

User avatar
aliasmask
RPTools Team
Posts: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Hidden Macro and CSS macro within non lib tokens.

Post by aliasmask »

If you want to avoid that, you can just put the style tag in your output, but you need to do like I do here: http://forums.rptools.net/viewtopic.php ... et#p253059

bobifle
Giant
Posts: 219
Joined: Thu Oct 19, 2017 12:36 pm

Re: Hidden Macro and CSS macro within non lib tokens.

Post by bobifle »

I guess the [r: ] decoration is for escaping {}, that's rather ... unconventional.

Anyway this works great. Thanks a lot.

Post Reply

Return to “Macros”