Created
September 28, 2018 23:17
-
-
Save Bastlifa/07aee200dd51f07d02341d13bdcf26b9 to your computer and use it in GitHub Desktop.
Familiar Sight Swap for Roll20 D&D 5E
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Familiar Sight Swap | |
// make a macro with body: | |
// !SwapSight PlayerTokenName FamiliarTokenName | |
on("ready", function() { | |
on("chat:message", function (msg) { | |
if (msg.type === "api" && msg.content.split(' ')[0] === "!SwapSight") { | |
SwapSight(msg); | |
} | |
}); | |
function SwapSight(msg) | |
{ | |
var campaign = findObjs({type: "campaign"})[0]; | |
var pageID = campaign.get("playerpageid"); | |
var playerToken = findObjs({type: 'graphic', _pageid: pageID, name: msg.content.split(' ')[1]})[0]; | |
var familiarToken = findObjs({type: 'graphic', _pageid: pageID, name: msg.content.split(' ')[2]})[0]; | |
if (!playerToken) | |
{ | |
sendChat("", "/w " + msg.who + " Player Token Not Found On Page"); | |
return; | |
} | |
if (!familiarToken) | |
{ | |
sendChat("", "/w " + msg.who + " Familiar Token Not Found On Page"); | |
return; | |
} | |
if(playerToken.get("light_hassight")) | |
{ | |
familiarToken.set("light_hassight", true); | |
playerToken.set("light_hassight", false); | |
} | |
else if (familiarToken.get("light_hassight")) | |
{ | |
familiarToken.set("light_hassight", false); | |
playerToken.set("light_hassight", true); | |
} | |
else | |
{ | |
playerToken.set("light_hassight", true); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment