PDA

View Full Version : Create a link for recordname and send it via Comm package



Waylander322
January 27th, 2023, 18:24
Hey everyone,

I am trying to create a message via the Comm package (https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644567/Comm) that is supposed to have a link to a record from a module.

I am aware that I could drag an item/object inside Fantasy Grounds into the chat box for everyone or on a character portrait to share it individually.
However I specifically want to include the link in a message.

It can be assumed that I am the GM and that I own and have shared the module/data in question.

Up to this point I am able to send messages with the Comm package successfully. When trying to send a link it ends up as a string in the chat box but not as a link to the data.

When scrolling through modules and their xml files the most promising entry I have found yet would be:

<link class="template" recordname="reference.data.nameOrID@moduleName" public="true">
<b>Type of Template: </b>Full Written Name of Module</link>

Is there any chance or trick that I could add that reference/link in a chat message?

Trenloe
January 27th, 2023, 18:48
Sorry, this is super quick as I'm short on time.

The comm message structure has a "shortcuts" LUA table. Here's some code I have in development for the PFRPG2 ruleset:


local msg = ChatManager.createBaseMessage(ActorManager.resolve Actor(nodePower.getChild(".......")));
msg.text = "Activity used = " .. sactivitySymbolText .. " " .. getDescription();
msg.font = "reference-r";

-- Add a shortcut to the activity in chat.
msg.shortcuts = {};
table.insert(msg.shortcuts, { description = "", class = "reference_activity", recordname = nodePower.getPath() });
-- Make the node public so that non-owning players can click the shortcut in chat.
if Session.IsHost then
DB.setPublic(nodePower, true);
else
PCActivitiesManager.notifySetActivityPublic(nodePo wer);
end

Comm.deliverChatMessage(msg);

There's additional code in there to share the link record if it's not available to all players, but the main thing you want to look at is the table.insert(msg.shortcuts... code.

Waylander322
January 27th, 2023, 22:35
Hey Trenloe,

perfect answer and remarkable flawless for being short on time! :o

It literally was exactly what I needed!

Thank you so much! :)

MOD: Thread moved to Workshop :)

Trenloe
January 27th, 2023, 23:32
Hey Trenloe,

perfect answer and remarkable flawless for being short on time! :o

It literally was exactly what I needed!

Thank you so much! :)
Great! Glad it worked. :)

Mephisto
January 30th, 2023, 17:03
Could such a link be used to automate a roll, like a parry or evasion to an attack?

Trenloe
January 30th, 2023, 18:00
Could such a link be used to automate a roll, like a parry or evasion to an attack?
The link opens a window with a specific FG windowclass and a FG database record. In theory you could put code in a custom windowclass to carry out a FG action and then close the window. But this would have to be done in an extension, it's not like a drag/drop action in the hotkey bar.