#Self VS Public Roll Macro

1 messages · Page 1 of 1 (latest)

storm musk
#

Currently in process of setting something up to either post to chat privately for the person doing the macro or publicly for group to see.
Friend helped me finally get it in a mostly functional spot with one issue of formatting;

[h: abort(input(
    "DestroyCheck|0|Do you want others to see this chart?|CHECK"))]
    
[h: DestroyTable = 
"<tr>
    <td style = 'text-align:center'>
        5th Level
    </td>

    <td>
        Destroys Undead of CR 1/2 or lower
    </td>
</tr>

<tr>
    <td style = 'text-align:center'>
        8th Level
    </td>

    <td>
        Destroys Undead of CR 1 or lower
    </td>
</tr>

<tr>
    <td style = 'text-align:center'>
        11th Level
    </td>

    <td>
        Destroys Undead of CR 2 or lower
    </td>
</tr>

<tr>
    <td style = 'text-align:center'>
        14th Level
    </td>

    <td>
        Destroys Undead of CR 3 or lower
    </td>
</tr>

<tr>
    <td style = 'text-align:center'>
        17th Level
    </td>

    <td>
        Destroys Undead of CR 4 or lower
    </td>
</tr>"
]

    [h: thetable = '<div style="background-color: #b5b5b5; color: black; padding-top:2px; padding-bottom:5px; padding-left:8px; padding-right:8px;">
    <b>'+Name+'</b>
    <table border="1" cellspacing = "0" cellpadding = "3" style = "background-color: white; color: black;">
        <tr><td style = "width:60px; text-align:center; padding-left: 5px; padding-right: 5px;">Cleric Level</td><td style = "text-align:center">Undead CR</td></tr>'
        +DestroyTable+
    '</table>
</div>']


[IF(!DestroyCheck), CODE:{
    [s: thetable]
};{
    [r: thetable]

}]``` this is the code and the image is the 2 results....is there a way to have "thetable =" NOT show up for the 'self post'? Have it be hidden or not showing or something?

I presume the << >> above/below the post is also unavoidable or....?
mortal spear
#

Personally, I'd just do this [h: broadcast(thetable, "self")]

storm musk
#

i'll give that a go

#

ah wait broadcast requires the lock deal doesnt it, forgot that

mortal spear
#

lock?

storm musk
#

disallow player editing of macros

#

"dont have permission to call the broadcast function"

#

not a big deal

#

It works, looks similar to /self for a macro i did in the past

#

(i presume theres no way to stop it stretching all the way across chat like that?)

mortal spear
#

Set the size of the table in html.

storm musk
#

thought i already did that?

#

whats it missing in the HTML for size?

storm musk
mortal spear
#

Something like <table width = "300px" border="1" cellspacing = "0" cellpadding = "3" style = "background-color: white; color: black;">

mortal spear
storm musk
#

Really?

#

Doesnt it get irksome at times tho with everything having to use a trusted function?

mortal spear
#

Everything my players call comes through their character sheet (just a slew of macrolink images and text)... and everything called from the character sheet comes through a lib token, so it's always trusted.

#

My players have one macro on their tokens: "Character Sheet" 😉

storm musk
#

Ah. Yeah we dont do that as much. We minimize full automation in case of breakage or other stuff. But fair enough (not to say we dont have a FEW trusted things but we try to avoid it)

mortal spear
#

If you have code on tokens, then anytime one thing changes you have to propagate changes to every token. That's a huge problem. Better to have a single macro that they all call.

#

Plus, you're hamstringing yourself not having access to trusted functions.

#

Btw, if you're outputting things like charts, you might not want to send them to chat. You could output them to frame5() and then you can use html 5... which is a lot better that the html3.2 you're stuck with in the chat window. And then players can also snap tables they use a lot to tabs, or to the side of their screen, etc.

storm musk
#

That said, if my player wants it as a window, i can easily adjust it for that.

#

I have a giant list of cheat sheets i made with frame5's for the SWRPG framework im developing. I only did chat output for this one because its such a small amount of info and easily postable to chat

distant zodiac
#

@storm musk

is there a way to have "thetable =" NOT show up for the 'self post'? Have it be hidden or not showing or something?

    [s: thetable]
};{
    [r: thetable]
}]```
use `[r, s: thetable]` for the self-part. The `s` is just for filtering people (like `gm` is). The visual formatting is not changed though, which means you essentially post `[thetable]` to self which includes the whole variable display stuff.
storm musk
distant zodiac
#

if that is not enough try also using [r, if(... but I think the [r, s: should work

storm musk
#

At least with broadcast self it doesnt show the picture, and /self usually italicizes everything postd after it

distant zodiac
#

do you want an identifier just for testing now or in general for later?

#

maybe something like

    [r, s: "Hidden<br>"]
    [r, s: thetable]

in your code block?

storm musk
#

Not sure? End of the day, i just like visual feedback, so a way to actually indicate its working properl may be best.

#

I suppose I could <i></i> the entire table....

distant zodiac
#

For checking visibility you can run maptool twice. One instance opens a server, the other one connects to it. Then you can simulate GM/player situations.

storm musk
#

Thats true

distant zodiac
#

If you want confirmation for later, I'd put some text above the table

storm musk
#

okay so r, s does work. thanks for that multi client tricvk didnt even think on it.

storm musk
#

cause apparently [r, s: <i> thetable</i>] doesnt work lol

distant zodiac
#

I don't think you can easily modify the table afterwards. But you know the choice for DestroyCheck before you create the table, so you could include conditional formatting in the <table ... part.

storm musk
distant zodiac
#

I think in this part you can include an if() with a font-style: italic;

[h: thetable = '<div style="background-color: #b5b5b5; color: black; padding-top:2px; padding-bottom:5px; padding-left:8px; padding-right:8px;">
    <b>'+Name+'</b>
    <table border="1" cellspacing = "0" cellpadding = "3" style = "background-color: white; color: black;">
        <tr><td style = "width:60px; text-align:center; padding-left: 5px; padding-right: 5px;">Cleric Level</td><td style = "text-align:center">Undead CR</td></tr>'
        +DestroyTable+
    '</table>
</div>']

in this line:

<table border="1" cellspacing = "0" cellpadding = "3" style = "background-color: white; color: black;'+if(!DestroyCheck, 'font-style: italic;', '')+'">
#

By the way puzzling in the variables with 'text'+...+'text' becomes fairly hard to read if you need multiple insertions.
You can use strformat() for it.

storm musk
storm musk
distant zodiac
#

This function
if(!DestroyCheck, 'font-style: italic;', '')
checks for !DestroyCheck and either returns 'font-style: italic;' (a string) or '' (empty string). The string is inserted in the rest of the table definition.

#

This is with strformat

[h: thetable = strformat('<div style="background-color: #b5b5b5; color: black; padding-top:2px; padding-bottom:5px; padding-left:8px; padding-right:8px;">
    <b>%{Name}</b>
    <table border="1" cellspacing = "0" cellpadding = "3" style = "background-color: white; color: black; %s">
        <tr><td style = "width:60px; text-align:center; padding-left: 5px; padding-right: 5px;">Cleric Level</td><td style = "text-align:center">Undead CR</td></tr>
        %s
    </table>
</div>',
if(!DestroyCheck, 'font-style: italic;', ''),
DestroyTable)]
storm musk
distant zodiac
#

The basic idea is this:

[h: variable = "YAY!"]
[h: formatted_string = strformat("Some text string in quotes where you can put in a %{variable} or put in a placeholder %s which is referenced at the end", 1d20+5)]
#

You get a text like
Some text string in quotes where you can put in a YAY! or put in a placeholder 19 which is referenced at the end

storm musk
#

how does it know to put the 'destroytable' in at the %s tho?

distant zodiac
#

in order

#

There are two %s in the code and two things given to strformat to put in.

#

strformat("Some %s text %s with %s placeholders", 1, 2, 3)
makes
Some 1 text 2 with 3 placeholders

#

The %s is a format option and tells it to format it as a string. You can also do specific number formatting or padding etc.

storm musk
#

aaaah okay

#

yeah i didnt notice that first %s in the table string

#

just saw the one where destroy table was

#

so if im reading this right

#

IF destroycheck, then insert font style italic

#

OTHERWISE empty

#

then insert destroytable at second %s

#

is basically gist of it?

distant zodiac
#

yes

storm musk
#

gotcha.

#

so if i understand this right, this will italicize everything BUT the name output in the division?

#

or will it italicize the name as well?

distant zodiac
#

Oh, yeah. Only the table content.

storm musk
#

Just checking.

#

i'll see how it looks in a sec

#

not the worst

distant zodiac
#

In the table code I posted you could also do the %{Name} insert with %s and move the , Name to the end. For variables that are ready you have multiple options and I like to place them into the string so you don't have to look for %s and match them with the appended inserts.

I didn't do it for the italics because that's a function. You can't do %{if(!DestroyCheck, 'font-style: italic;', '')}. You could however prepare the result beforehand like [h: self_italic = if(!DestroyCheck, 'font-style: italic;', '')] and then do %{self_italic} in the table code.

I didn't do it for the long DestroyTable insert. Most likely %{DestroyTable} will also work, but I had issues with long strings at some point, and the %s version was more reliable then.

storm musk
distant zodiac
#

yeah that's my point exactly. I just wanted to explain why I used different methods and what there is to consider.

storm musk
#

Fair,.