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

Pic in a Macro? Dynamic Reference? Possible?

March 10 (5 years ago)

Is there a way to dynamically draw the character sheet art into a macro?  I would not know where to draw the reference from, but what I mean to do is something like this:

[character image](@{selected|character_art})


Where character_art would be drawing on https://s3.amazonaws.com/files.d20.io/images/83649467/PNf1HWUrCq2RxqayDWyFvw/med.png?1560156344, for example, into the image tag and using the image method to draw it.

I would be looking at a way from existing Roll20 dynamic references, not from an API.  I know that APIs can do it, I've seen TheAaron do it with Message of the Day for Handouts - I know this can be done that way.  I'm trying to find a way with existing references though, to simplify it.

March 10 (5 years ago)

You can always have a web-based picture display in chat with the following command:

[Any text here](web_address_of_image_ending_in_valid_image_file_extension)


Any macro will allow that command to display the picture in the chat window, the text in the brackets does not show up.

March 11 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

The syntax in your particular case would be

[x](https://s3.amazonaws.com/files.d20.io/images/83649467/PNf1HWUrCq2RxqayDWyFvw/med.png)
March 11 (5 years ago)
Ziechael
Forum Champion
Sheet Author
API Scripter

The OP wants to do it dynamically using selected or target... as the image doesn't exist as an attribute I don't think that would be possible without the API :(

Sorry.

March 11 (5 years ago)

Edited March 11 (5 years ago)


Ziechael said:

The OP wants to do it dynamically using selected or target... as the image doesn't exist as an attribute I don't think that would be possible without the API :(

Sorry.


Yes - ty for acknowledging that, as no one was.  I am well aware of how image links work, the example was given that shows I knew that ... lol.

Sad its not a possible attribute though ...  I know you can link character sheets by linking the journal entry and using the @{selected|character_id} at the end.  I was hoping something like that was possible with the pic.  Honestly, it was just a flashy thing to do anyway.  I would have also liked to set the width and height of the pic, and pretty sure thats not possible without an API also.

March 11 (5 years ago)

Edited March 11 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Sorry, I misread the original post. I don't think there's an automatic non-API way to do this, either.



For anyone following this thread however, who wants to do this but doesn't have the same restrictions, there are a couple of ways to approach the problem. Without the API, you can use this  Stupid Trick by Kirsty with a little setup time.

For an API solution, there is an excellent script called CharPic that can do it. The Aaron posted this originally, but called it a "quick and dirty hack of someone's pic script":


on('ready', function() {
    on('chat:message', function(msg) {
       if (msg.type == "api" && msg.content.indexOf("!char-pic") !== -1) {
           var charid =msg.content.split(' ')[1];
           var c = getObj('character',charid);
           if(c) {
               var fPart = "<div style='box-shadow: 3px 3px 2px #888888; font-family: Verdana; text-shadow: 2px 2px #000; text-align: center; vertical-align: middle; padding: 1px 1px; margin-top: 0.1em; border: 1px solid #000; border-radius: 8px 8px 8px 8px; color: #FFFFFF;";
               var Pic = fPart + "background-color:#AAAAAA;'><img src='" + c.get('avatar') + "'></div>";
               sendChat('', "/direct " + Pic);
            }
       };
    });
});