Last active
February 2, 2016 16:04
-
-
Save BaldarSilveraxe/4be1d7c1631d95fa7d9e to your computer and use it in GitHub Desktop.
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
/*global state, sendChat, filterObjs, getObj, on, createObj, setTimeout, _, findObjs, playerIsGM, sendPing, toFront, toBack */ | |
/*jslint white: true, bitwise: true, for: true, multivar: true, browser: true */ | |
var mapGrid = mapGrid || (function(){ | |
'use strict'; | |
var version = 0.1, | |
handleGraphicChange = function (obj) { | |
var html = '', | |
page=getObj('page',obj.get('pageid')), | |
snapping_increment = ~~page.get('snapping_increment'), | |
grid_type = page.get('grid_type'), | |
diagonaltype = page.get('diagonaltype'), | |
objlft = ~~obj.get('left'), | |
objtp = ~~obj.get('top'), | |
objwdth = ~~obj.get('width'), | |
objhght = ~~obj.get('height'), | |
objrttn = ~~obj.get('rotation')%360 + ((~~obj.get('rotation')) < 0 ? 360 : 0), | |
unitWidth = (grid_type === 'square') ? (70*snapping_increment) : (grid_type === 'hex') ? (75*snapping_increment) : (94*snapping_increment), | |
unitHeight = (grid_type === 'square') ? (70*snapping_increment) : (grid_type === 'hex') ? (88*snapping_increment) : (81*snapping_increment), | |
gridLeft = (grid_type==='square')?~~(objlft/unitWidth) + 1:(grid_type==='hex')?~~(objlft/(unitWidth/2) + 0.5):~~(objlft/(unitWidth*0.75)) + 1, | |
gridTop = (grid_type==='square')?~~(objtp/unitHeight) + 1:(grid_type==='hex')?~~(objtp/(unitHeight*0.75)) + 1:~~(objtp/(unitHeight/2) + 0.5); | |
page.set('gridlabels',true); | |
html += '/direct ' | |
+ '<br>Snapping Increment: ' + snapping_increment | |
+ '<br>Grid Type: ' + grid_type | |
+ '<br>Diagonal Type: ' + diagonaltype | |
+ '<br>Left: ' + objlft | |
+ '<br>Top: ' + objtp | |
+ '<br>Width: ' + objwdth | |
+ '<br>height: ' + objhght | |
+ '<br>rotation: ' + objrttn | |
+ '<br>Unit Width: ' + unitWidth | |
+ '<br>Unit Height: ' + unitHeight | |
+'<br>Grid Left: ' + gridLeft | |
+'<br>GridTop: ' + gridTop; | |
sendChat(Math.random().toString(36).substring(7),html); | |
}, | |
registerEventHandlers = function() { | |
on('change:graphic', handleGraphicChange); | |
}; | |
return { | |
RegisterEventHandlers: registerEventHandlers | |
}; | |
}()); | |
on('ready',function(){ | |
'use strict'; | |
mapGrid.RegisterEventHandlers(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment