PDA

View Full Version : Changing the grid size for mapping?



PneumaPilot
November 7th, 2008, 14:08
Is there a scripted way to change the 5-foot square grid to 1-yard squares? Also, would the arrow pointed be automatically updated to provide new ranges?

PneumaPilot
November 7th, 2008, 15:33
Okay, I found the place to change the scale. The only thing the scale really matters for is the drawing of vectors or other area of effect zones. That can be changed in the imagewindow_image.lua file. Specifically, here are the places that need to be changed:


function onMeasureVector(token, vector)
if hasGrid() then
local diagonals = 0;
local straights = 0;
local gridsize = getGridSize();

for i = 1, #vector do
local gx = math.abs(math.floor(vector[i].x / gridsize));
local gy = math.abs(math.floor(vector[i].y / gridsize));

if gx > gy then
diagonals = diagonals + gy;
straights = straights + gx - gy;
else
diagonals = diagonals + gx;
straights = straights + gy - gx;
end
end

local squares = math.floor(diagonals * 1.5) + straights;
local feet = squares * 1;

return feet .. "\'";
else
return "";
end
end

function onMeasurePointer(length)
if hasGrid() then
return math.floor(length / getGridSize() * 1) .. "\'";
else
return "";
end
end

In each of these lines there is a 5 that needs to change to a 1. I have already changed them in the code above.

Foen
November 7th, 2008, 21:20
Hi

You might also want to take a peek at this thread (https://www.fantasygrounds.com/forums/showthread.php?t=8388).

Cheers

Stuart

PneumaPilot
November 8th, 2008, 03:38
Hey, cool, thanks. I'll have to look over this stuff. Is there something wrong with the way I did it?

Foen
November 8th, 2008, 06:53
I didn't check your code against the other version, but what you did seems fine. I guess the other code is possibly easier to maintain because the scale-specific items are set using parameters at the top of the code block rather than being embedded in each event handler.

Stuart

PneumaPilot
November 8th, 2008, 14:29
Ahh yes. Kind of like I was looking for something like that to be at the top of the block, and I found it hidden as a hard-coded number in the middle of the code. Good idea. Thanks again.