Play a oneshot in foundryVTT

So basically I’m wondering if anyone knows how to get a oneshot to play when an item/spell is used in founrdyVTT? I’m pretty sure this could be accomplished via a macro of somesort. I just don’t have much experience in that area and would love some help

Sooo…

Is there anything in Foundry that can open a webpage (without opening it).

On my StreamDeck I use the Link function (with do not open link checked).

e.g. this link for the Force Missile:
https://syrinscape.com/online/frontend-api/elements/9412/play/?auth_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Where xxxxxxxxxxxxxxxxxxxxxxxxxxxx is the auth token of the DM running the game.

These links can be found by either export a csv of all links (in the hamburger menu at the top right of the Master UI) OR by switching on Remote Control links in that same menu.

OR

Is there someone in the FoundryVTT community that has already done the work here. A number of other VTTs have got this working (eg Fantasy Grounds).

Let us know how you go! :slight_smile: :smiley:

Is there a technical term for opening a link without opening the link? Just so that when I start asking around for a macro on the foundryVTT discord they know what I’m asking for?

There seems to be significant demand for this on Foundry. The audio capabilities in Syrinscape seem to be a great fit for the VTT.

I’m not familiar with the Foundry macro system, and these things can go by many different names, but ideally you will be able to make a “Web Request” which should contact our API without opening any browser windows or anything like that.

Failing this, perhaps “Open Link” or so, and hopefully you can “Open in background” or “Open in a different tab” so it can make the request without disturbing your current workflow.

Hope you can work something out!

You’re likely going to need a decent Javascript coder for this.

Foundry modules run on the client. (You can save them per-world if you want.) You’d need a module that checks if the user is the GM (who would need to have authenticated with Syrinscape already), and then makes a XMLHttpRequest to the server like Ryan suggested.

Please see this post for help

have you ever figured out how to do it without opening up a webpage that I then need to close?

Did you try the method DrWiFi suggested? It looks like it works by using fetch in JavaScript, which I would not expect to open any webpages you need to close. Crossing fingers for you! :crossed_fingers:

I did the whole Icewind Dale by copying over the DDB book into journal entries and connecting the sound links from the soundbard to the apprpropriate portions of the text. It sounds great.
Made a document of player sounds for them to activate at their choosing.
PS Note, the opening crawl sounded mushmouth to my players. In specific, “he is eating his beard while talking” just read that part out loud.

I played with this some today, and it turns out that making a macro for an individual one-shot is easy.

Create a macro (double-click on an empty slot in the macro bar). Give it a name, and set its type to “script” (that’s very important). Set the contents to the following:

const link = "https://syrinscape.com/online/frontend-api/elements/358592/play/?auth_token=1234567890ABCDEF";

await fetch(link, {
      method: 'POST',
      mode: 'no-cors',
      cache: 'no-cache',
      credentials: 'omit',
      redirect: 'follow',
      referrerPolicy: 'no-referrer',
});

You’ll need to change the link on the first line for each one-shot; be sure to leave the "; at the end of the line, though! As @benjamin pointed out, you can get those by turning on “Show Remote Control Links” in the control panel (https://syrinscape.com/online/master/). Then, if you click the small “play” button on a one-shot, it will copy the correct link to the clipboard.

(Another way is to use the CSV you can download, but that doesn’t include auth tokens. If you get your links from the CSV, you’ll need to append ?auth_token= followed by the token you can get from https://syrinscape.com/online/cp/. That will make it look like the links you can get from the master interface.)

Due to a technical limitation, this mechanism can’t obviously warn you if there’s an error; you’ll need to look at the developer console in your web browser. (I’m going to ask Syrinscape about fixing that.)

2 Likes