You can create an NK Custom Panel and attach ogscript to the nkstatchange event.
The trick is to check the nkstatchange event to see if the changed destination/level are the ones you are interested in. I have included an example that contains an tag you can copy into your panel to get a function that will check this for you.
Once you know that your destination's source has changed, you can get the new source with nk.getStatus and set your other destination to the same source. In my example, I am looking at level 5 and setting destination 2 whenever destination 1 changes.
<meta>
<api immediate="true">function isEventValid(event, dest, levelNum)
{
var levelMask = (1 << (levelNum - 1)); //TRANSFORM THE LEVEL NUMBER INTO A LEVEL MASK SINCE THAT'S WHAT THE STATUS EVENT USES
return (levelMask & event.getChangedLevels()) != 0; //CHECK TO SEE IF THE EVENT LEVEL MASK CONTAINS THE LEVEL WE WANT
}
</api>
<ogscript handles="nkstatchange">var dstNum = 1; //DST TO TRACK (Starts at 1)
var secondDestination = 2; //SECOND DESTINATION TO TRACK (Starts at 1)
var levelNum = 5; //LEVEL TO TRACK (Starts at 1)
if (isEventValid(event, dstNum, levelNum)) //CALL FUNCTION IN OUR API BLOCK TO CHECK IF THE EVENT IS FOR THE DST WE CARE ABOUT
{
var newSrc = nk.getStatus(dstNum, levelNum); //GET THE NEW SRC
var oldMask = nk.getLevelMask(); //SAVE THE CURRENT LEVEL MASK (DOING THE SWITCH WILL CHANGE IT)
nk.doSwitchWithLabels(secondDestination, newSrc, levelNum) //DO THE SWITCH
nk.setLevelMask(oldMask); //RESTORE THE OLD LEVEL MASK
}</ogscript>
</meta>
#DashBoard