
Attempting to modify the Facing script but this is my first time. I don't entirely understand the code because there are "pairs" which is something I haven't seen before. <a href="https://github.com/shdwjk/Roll20API/blob/master/Facing/Facing.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Facing/Facing.js</a> I want to get the original dimensions of the graphic I use for the facing marker. I don't know how to find it and add it as an attribute of the "slave" object. I also want to add a hidden attribute but having difficulty adding that. My comments in the code are what I'm trying to do. Trying to create the hidden attribute and dimensions of image: createRinged = function(id) { // get root obj var master = getObj('graphic',id), slave = getRinged(id), layer; if(!slave && master) { layer=( 'gmlayer' === master.get('layer') ? 'gmlayer' : 'map'); slave = createObj('graphic',{ imgsrc: state.Facing.config.image, layer: layer, pageid: master.get('pageid'), top: master.get('top'), left: master.get('left'), height: 300, //should be original height of image width: 300, //should be original width of image //hidden: false, doesn't work when just adding at creation of this object rotation: master.get('rotation'), }); ( findObjs({ type: 'attribute', name: state.Facing.config.attributeName, characterid: master.get('represents') })[0] || (master.get('represents') && createObj('attribute',{ name: state.Facing.config.attributeName, characterid: master.get('represents') })) || { set: function(){} }).set({ current: slave.get('rotation') }); ( createObj('attribute', { name: 'hidden', characterid: slave.id, current: false })); if('gmlayer' === layer) { toBack(slave); } else { toFront(slave); } state.Facing.ringed[master.id]=slave.id; } }, Trying to change size of image to 0 and back to previous value so I can hide it: hide = function(id) { var pair=getRingedPair(id); var height=pair.slave.get('height'); var width=pair.slave.get('width'); if(pair) { if(height === 0 && width === 0) { pair.slave.set({ width: 300, //would like prev.width height: 300, //would like prev.height hidden: false }) } else { pair.slave.set({ height: 0, width: 0, hidden: true }); } } }, Trying to use the hidden attribute later on: handleTokenChange = function(obj,prev) {
var pair = getRingedPair(obj.id),
layer,
rot, angle, hid;
if(pair) {
if(pair.master.id === obj.id) {
layer=( 'gmlayer' === pair.master.get('layer') ? 'gmlayer' : 'map');
rot=pair.master.get('rotation');
angle = rot - prev.rotation;
hid = pair.slave.get('hidden');
//hid = findObjs({ type: 'attribute', characterid: pair.slave.id, name: 'hidden' })[0];
//not able to get the hidden attribute either way for the If statement below
if(rot !== prev.rotation ) {
if(hid === false) {
pair.master.set({
rotation: prev.rotation,
});
pair.slave.set({
rotation: rot
});
} else {
pair.slave.set({
rotation: (pair.slave.get('rotation') + angle)
});
}
}
pair.slave.set({
layer: layer,
top: pair.master.get('top'),
left: pair.master.get('left'),
});
if('gmlayer' === layer) {
toBack(pair.slave);
} else {
toFront(pair.slave);
}
} else {
pair.slave.set({
width: prev.width,
height: prev.height,
top: prev.top,
left: prev.left,
layer: prev.layer,
flipv: prev.flipv,
fliph: prev.fliph
});
}
}
},