I have a macro dialog setup where it opens a dialog in which I can show a specific map to specific players via a checkbox. Everything seems to be working fine except, when I pass my userID info it doesn't seem to open on their end if they didn't launch the macro themselves.
For exemple. As a GM if I open a map for everyone to see (no ID specified), it works. If I open a map only for my own GM user ID it works. But If I only specify a specific player ID other than myself for exemple Player 2, it doesn't work. But when that Player 2 selects his own ID when launching the macro himself, it works for him.
I hope I'm clear enough!
Here is the whole code of my Macro if you want and a few screenshots so you can see the UI (of how it works) and also the fact that the console correctly registers the playerIDs.
var dialogButtons = {};
var playerIDs = [];
var usersMap = game.users;
usersMap.forEach(
(user) =>
(dialogContent += '<input type="checkbox" name="'+user.name+'"><label for="'+user.name+'">'+user.name+'</label></input>' )
);
function MapConstructor(url, name) {
dialogButtons["checkbox-"+name] = MapButtonConstructor(url, name);
}
function MapButtonConstructor(url, name) {
var button = {
label: name,
callback: (html) => {
playerIDs = [];
for(var user of usersMap) {
if(html.find("[name="+user.name+"]")) {
if(html.find("[name="+user.name+"]")[0]) {
if(html.find("[name="+user.name+"]")[0].checked===true) {
playerIDs.push(game.users.getName(user.name).id);
}
}
}
}
DisplayMapToPlayer(url, name, playerIDs);
}
};
return button;
}
function DisplayMapToPlayer(url, name, playerIDs) {
window.Ardittristan.InlineViewer.sendUrl(
url,
false,
1024,
1024,
name,
"",
playerIDs,
""
);
console.log(playerIDs);
}
MapConstructor("https://foundryvtt.com/api/User.html", "Test Map");
let dialogEditor = new Dialog({
title: `Show Map`,
content: dialogContent,
buttons: dialogButtons
});
dialogEditor.render(true);
Hi,
I have a macro dialog setup where it opens a dialog in which I can show a specific map to specific players via a checkbox. Everything seems to be working fine except, when I pass my userID info it doesn't seem to open on their end if they didn't launch the macro themselves.
For exemple. As a GM if I open a map for everyone to see (no ID specified), it works. If I open a map only for my own GM user ID it works. But If I only specify a specific player ID other than myself for exemple Player 2, it doesn't work. But when that Player 2 selects his own ID when launching the macro himself, it works for him.
I hope I'm clear enough!
Here is the whole code of my Macro if you want and a few screenshots so you can see the UI (of how it works) and also the fact that the console correctly registers the playerIDs.