PDA

View Full Version : changing map scale to generic units



FryCook
September 21st, 2007, 12:43
i searched all the threads with as many variations of this theme i could think of, but all i found was a similar question no one answered. i hope that doesn't mean this is impossible.

basically, i just want the map to read in generic units when i lock tokens and a player drags out his movement way points. instead of reading 10', i would like for it to say 2. so one unit is equal to 5'. i'd rather not have players calculating the units in their heads because in the game system i use one unit is not equal to 5' and i create the maps accordingly.

thanks for any help on this.

~fry

joshuha
September 21st, 2007, 17:09
Well if you are comfortable with creating a quick custom ruleset this change is really easy to put in. If so, I will let you know which file you need to modify.

GoOrange
September 21st, 2007, 17:51
Well if you are comfortable with creating a quick custom ruleset this change is really easy to put in. If so, I will let you know which file you need to modify.

I would find that information very helpful if you don't mind sharing.

Oberoten
September 21st, 2007, 19:03
Got to admitt that so would I.
Ranges and the like in Metric would be very very nice.

- Obe

FryCook
September 21st, 2007, 19:44
joshuha,

like the rest of these guys, i'd be incredibly grateful to receive some of your top notch coding help.

i'm already running the custom ruleset "that cannot be named". so i can probably just tweak that one.

thanks,
~fry

joshuha
September 21st, 2007, 20:33
Ok the file we care about is scripts\imagewindow_image.lua.

In there are 2 function that are used to measure the vectors and the pointers.



function onMeasureVector(token, vector)
if hasGrid() then
local diagonals = 0;
local straights = 0;
8 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 * 5;

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

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


To turn it into base units of 1 just remove the *5 instances you see above. Note that when it reports things in feet using the ' symbol it preceeds it with a backslash since its a special character. But you could easily replace the concatenation with .. "m" or what not.

Now besides this you will obviously have to adjust your combat tracker reach/base size to reflect the base size for one square that you have.

Also in the combattracker_token.lua in the updateUnderlay function it has to do the reverse to get the amount of squarew to highlight so it divides by 5. So again you will need to change that number to whatever your base unit size is.



function updateUnderlay()
if ref then
ref.removeAllUnderlays();

local space = math.ceil(window.space.getValue() ) / 2;
local reach = math.ceil(window.reach.getValue() ) + space;

if window.getType() == "pc" then
ref.addUnderlay(reach, "4f000000", "hover");
else
ref.addUnderlay(reach, "4f000000", "hover,gmonly");
end

if window.getFoF() == "friend" then
ref.addUnderlay(space, "2f00ff00");
elseif window.getFoF() == "foe" then
ref.addUnderlay(space, "2fff0000");
elseif window.getFoF() == "neutral" then
ref.addUnderlay(space, "2fffff00");
end
end
end


So note here is you also didnt care about the reach overlay you could remove it off the combat tracker (although this involves modifying the LUA files that set the defaults too) as well as from the function above.


If any of that isn't clear let me know.

GoOrange
September 21st, 2007, 20:33
I think it may be in the script file imagewindow_image.lua



function onMeasureVector(token, vector)
* cut unnecessary code *
local squares = math.floor(diagonals * 1.5) + straights;
local feet = squares * 5;

function onMeasurePointer(length)
return math.floor(length / getGridSize() * 5) .. "\'";

I'll wager if you changed the number 5 to whatever unit you want your squares to represent, it will produce the desired effect. Haven't had a chance to test it out yet, but will soon. (The new Star Wars rules list ranges in squares rather than foot measurements, so I'll need to do this updating).

Edit: Beat to the punch by Joshua!

FryCook
September 21st, 2007, 22:20
joshua comes through again. can i nominate you for most valuable community member?

https://walomerson.com/images/map_units.jpg

thanks again!

~fry

also, thanks for the input as well, GoOrange.