Growlly's Totally Noob Questions about Macros

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

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Growlly's Totally Noob Questions about Macros

Post by aliasmask »

Are you trying to translate to or from s textarea? What is your input source, a form input? The form input for ; is a bit wonky as is a couple of other characters. The best way to see what it is actually passing is to dump the variable after it's passed. I don't recall, but I think it's something like &#59&#59. Also, when trying to replace the ; or reverse the process the order of operation is important so as to not mess up the other replace lines.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Growlly's Totally Noob Questions about Macros

Post by Full Bleed »

aliasmask wrote:Are you trying to translate to or from s textarea? What is your input source, a form input? The form input for ; is a bit wonky as is a couple of other characters. The best way to see what it is actually passing is to dump the variable after it's passed. I don't recall, but I think it's something like &#59&#59. Also, when trying to replace the ; or reverse the process the order of operation is important so as to not mess up the other replace lines.
It's basically your notes code. Anytime a semi-colon is used when entering notes, upon reopening it became: &#59

I checked the order of operations and that was it. The replace code had to be added first in the more completed code you provided later (you might want to add it to your post).

So, this works:

Code: Select all

[H, if(! json.isEmpty(notes)), code: {
   [h: notes = replace(notes,"&#59",";")]
   [H: notes = replace(notes,"&","&")]
   [H: notes = replace(notes,"\\\\","\")]
   [H: notes = replace(notes,"<","<")]
   [H: notes = replace(notes,"/","/")]
   [H: notes = replace(notes,"[\$]","$")]
};{}]
Not sure if that's going to cause any issues... but I don't see anything as of yet.

Thanks for the help.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Growlly's Totally Noob Questions about Macros

Post by aliasmask »

If you're using RPEdit this line will not translate correctly:

[h: notes = replace(notes,"&#59",";")]

The reason I write:

[h: notes = replace(notes,"&#"+"59",";")]

Is because the form input will translate the literal &#59 back to ; so it will read as

[h: notes = replace(notes,";",";")]

after you import/export the macro code.

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: Growlly's Totally Noob Questions about Macros

Post by Full Bleed »

aliasmask wrote:If you're using RPEdit this line will not translate correctly:

[h: notes = replace(notes,"&#59",";")]

The reason I write:

[h: notes = replace(notes,"&#"+"59",";")]

Is because the form input will translate the literal &#59 back to ; so it will read as

[h: notes = replace(notes,";",";")]

after you import/export the macro code.
Noted. I was using it in your notes code (which I quoted above). Both ways work in that use case... but I'll switch to the method you use with RPEdit for consistency.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Growlly's Totally Noob Questions about Macros

Post by aliasmask »

If you're not outputting to a textarea, then you don't need all those conversions. Also, I would only save the original input text however you get that. That little snippet of code is from my RPEdit drop-in where I save and load from a textarea box.

There is another lib token (Lib:msg_mngr) that I didn't write but I made some updates to. It's in need of some updates and afaik is not 100% functioning.

For my own in game notes I have lib token called lib:dialog. It's integrated with my framework so it's not a standalone drop-in but instead of a dialog it uses the input() function. That's because I choose which dialog to post to chat. Output to the input() function needs it's own set of conversions as well.

So, breaking it down there are 3 main ways to get input. First from a text box using the input() function, another from textarea using a <form> and lastly some like using a token's notes field. How are you entering your text? The token's notes field and textarea are very similar but have a couple of variations.

For output, you can output to chat, dialog or frame which are all essentially the same with the exception of using a style sheet which can't be done in chat. It's just standard 3.1 HTML. You can also output using the input() function. There are certain characters that need to be converted if to be displayed in HTML. For example, if inputting from textarea the CRLF need to be converted to <BR>. Also, the < symbol needs to be changed to an HTML entity <. That covers 99% of the conversion for HTML output. All those special characters I use for the textarea like changing & to & is to avoid mixed text from accidentally converting it to something else. Same is true for all the other characters converted. Things get tricky if you decide to mix plain text with html before converting.

Post Reply

Return to “Macros”