json dump when calling macro

Talk about whatever topic you'd like, RPG related or not. (But please discuss things related to our software in the Tools section, below.)

Moderators: dorpond, trevor, Azhrei

Post Reply
Elyre_Elan
Kobold
Posts: 22
Joined: Tue Feb 14, 2017 5:33 pm

json dump when calling macro

Post by Elyre_Elan »

Hello Folks;

Running into a rather frustrating issue that I have not run into previously. Part of the difficulty will be attempting to explain...

Here goes:

I have created a weapons "database" that is a series of jsons. Example:

[H: noneData = json.set("{}",
"Weapon", "None",
"Damage Dice", 0,
"Damage Modifier", 0,
"Strength", 1,
"Type","Melee",
"HTH", "Y",
"Throw", "N",
"Hands", 0,
"DR", 0,
"DXMod", 0
)]

This is repeated for each weapon type (using fantasy trip melee rules)

At the end of the list of jsons, I finish with:

[H: weaponData=json.set("{}",
"None", noneData,
"Dagger", daggerData,
"Main-Gauche", maingaucheData,
"Rapier", rapierData,
"Club", clubData,
"Hammer", hammerData,
<etc>
)]

[H: return(0, weaponData)]

In various other macros, I call the macro thusly: [h: weaponData=tftWeaponsDB()]. Note it is a UDF.

This all works fine and I am able to use my homebrewed "database" except that each time I call the weaponsDB, it dumps the contents of the macro into the chat. This is annoying as heck. Everything is predicated with an "H" in the various roll options and the forms that are submitted work great. What am I doing wrong?

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

Re: json dump when calling macro

Post by Full Bleed »

Have you tried setting the ignoreOutput parameter when you defined the function?

https://wiki.rptools.info/index.php/defineFunction

That won't explain why it's happening (I'd have to see all of the code), but it might be a quick fix...
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: 9024
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: json dump when calling macro

Post by aliasmask »

I would need to see full code but you probably have something that breaks the code like ' in the wrong spot... perhaps a comment.

Elyre_Elan
Kobold
Posts: 22
Joined: Tue Feb 14, 2017 5:33 pm

Re: json dump when calling macro

Post by Elyre_Elan »

Thank-you, both, for the response. I actually got away from the issue by moving the logic that needs the json macro out of the presentation. That seemed to eliminate the problem for now.

However, I will triple-check my comments (I have a rather large amount of them to explain how the macro is used and a description of the various fields at the beginning of it). AND I will try the ignoreOutput parameter if I run into it again.

Appreciate the response and the options. :)

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

Re: json dump when calling macro

Post by Full Bleed »

Elyre_Elan wrote:
Mon Jun 07, 2021 6:28 pm
However, I will triple-check my comments (I have a rather large amount of them to explain how the macro is used and a description of the various fields at the beginning of it).
MT doesn't have a proper comment method.

Are you commenting with:

[h: " <!-- Comments here. -->"]

I think that's the safest.

And I suggest that you don't use any single or double quotes in them. So no contractions. ;)
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Post Reply

Return to “General Discussion”