Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script request] Mirror Tokens

So i have an idea for an scenario But it would need a bit of code to get it working so basically party awakes in a dungeon and fight for the exit and the last room there is a mirror that expands the entire length of the 1 wall where they can see them selves on the other side of the mirror but its not actually a mirror its a pane of glass and plot twist the party has been separated the entire time with mirror copies of the other party members filling in the gaps, so basically the dungeon is mirrored as well and half party starts on one side and the other half start on the other, so i want something like the twins script but it doesn't put the token in the exact location just copies their action and inverts movement on the x axis (so on one side when a token moves left on the other side the token moves right) up and down can still be the same i hope i explained it well but let me know if you need more explanation
1494846741
The Aaron
Pro
API Scripter
Take a copy of the twins script and change handleTwinChange online 104 to be this:     handleTwinChange = function(obj) {         _.find(state.Twins.twins,function(lhs,rhs){             var twin;             if(obj.id === lhs){                 twin = getObj('graphic',rhs);             } else if(obj.id === rhs) {                 twin = getObj('graphic',lhs);             }             if(twin) {                 twin.set(_.reduce(props,function(m,p){                     m[p]=obj.get(p);                     return m;                 },{}));                 // mirroring                 let page=getObj('page',twin.get('pageid'));                 if(page){                     let width=parseInt(page.get('width'),10)*70;                     twin.set({                         left: (width-twin.get('left'))                     });                 }                                  return true;             }             return false;         });     }, I bolded the addition for the mirroring.
Thanks Aaron, Works well! tho if there is a movement path set the other moves along the same path and then goes into its mirrored position but my players hardly use that feature.
1495020969

Edited 1495106249
The Aaron
Pro
API Scripter
Good point!  Revised:     handleTwinChange = function(obj) {         _.find(state.Twins.twins,function(lhs,rhs){             var twin;             if(obj.id === lhs){                 twin = getObj('graphic',rhs);             } else if(obj.id === rhs) {                 twin = getObj('graphic',lhs);             }             if(twin) {                 twin.set(_.reduce(props,function(m,p){                     m[p]=obj.get(p);                     return m;                 },{}));                 // mirroring                 let page=getObj('page',twin.get('pageid'));                 if(page){                     let width=parseInt(page.get('width'),10)*70;                     twin.set({                         left: (width-twin.get('left')),                         lastmove: _.map(                                 obj.get('lastmove').split(/,/),                                 (n,idx)=>(idx%2 ? n : width - parseInt(n,10) )                             ).join(',')                     });                 }                 return true;             }             return false;         });     }, That should make the path mirrored as well...
it does but in the wrong way, flips on the x axis not the Y axis, so its upside down beneath the original and then moves to the mirrored position, (so close) 
1495106321
The Aaron
Pro
API Scripter
Ha!  ok.  I fixed the above.  I had the odd/even check reversed.
Awesome Aaron works perfectly for your help now ive just gota design dungeon and mirror that and the remember never to say left or right when running it. Hope i didn't take up too much of your time :)  
1495151916
The Aaron
Pro
API Scripter
nah... I enjoy little challenges like this. =D  Happy Rolling!
1495187510
Ziechael
Forum Champion
Sheet Author
API Scripter
Gm said: Awesome Aaron works perfectly for your help now ive just gota design dungeon and mirror that and the remember never to say left or right when running it. Hope i didn't take up too much of your time :)   Was thinking of totally, and shamelessly, stealing this idea but wondered how you were planning to deal with the players in side A referring to a left/right direction when discussing combat/puzzles without players in side B getting confused/suspicious?
1495199927
The Aaron
Pro
API Scripter
Pings and measures might give you away too, but that can be chalked up to "Oh.. that's weird.. must be a bug..."    I do hope you post back afterwards and tell us how it went!
Pings and measurements are my real issue yea "just a bug" is going to be my plan too. Puzzles are going to have some kind of symmetry to them or least nothing where they will need left and right directions (mostly i do puzzles on a separate page kinda like a zoomed in version of the puzzle) combat i have no idea i hope the players just get really confused and think the other players cant tell direction. but i guess you could also do this not mirrored and just have a portal that leads to the final room. but all in all its about trusting your players to think the others players are idiots or not to meta think to much. the final combat i find the most interesting because what ever the pc does the mirror copy does too so to defeat the mirror copy you have to hurt an ally or hurt your self, or you could have at that point the mirror copies break free of mimicry and act independently or have a puzzle to solve that will banish them but for my purpose the party "killing" each other is exactly what i want, perfect way to introduce my main villain.