PDA

View Full Version : Script modding and general help needed



Brianide
May 12th, 2013, 05:06
Where to begin... I'm trying to mod FG to provide measurements without a grid. I think I have the code rjght to make it work, but I don't think my code is actually being loaded into my ruleset. I've used the package manager to unpack a ruleset (M&M3e in this case). Then I've modded campaign_image.lua to handle measurements how I want. Then I've used the package manager to repackage those files under a new name, and I created a new campaign using this ruleset. Nothing behaves differently, and my print() statements don't show up in the debugger console. I must be missing a major step somewhere. Any ideas? Is there a better way to try this, perhaps on the 3.5 ruleset?

Trenloe
May 12th, 2013, 05:19
See post #6 in this thread (and other areas of the long thread for info on modifying a ruleset). Look at step 1 of "A few steps to do before getting started" - this tells you ho to modify a ruleset, there is no need to re-pak it after you have unzipped it to the \rulesets directory.

I'd recommend making the change to the ruleset you want to use the feature in! :)

Brianide
May 12th, 2013, 05:56
Many thanks. I'll see what I can do!

EDIT: Did you mean to include a link in your post? I couldn't find the thread you're talking about.

I didn't have a rulesets directory, so I've created one and copied d20_JPG in there. I modded imagewindow_image.lua to ignore the presence of a grid, but I'm still getting no altered behavior and no prints in the console. Maybe when I find the guide you're referring to, I'll find what I need.

Brianide
May 12th, 2013, 14:45
It seems that onMeasurePointer doesn't even get called unless the grid is active. Is there a way to bypass that and get it to call regardless of the grid state?

Trenloe
May 12th, 2013, 16:01
EDIT: Did you mean to include a link in your post? I couldn't find the thread you're talking about.
Yeah, sorry forgot to include the link. Here is is: https://www.fantasygrounds.com/forums/showthread.php?t=17909


I didn't have a rulesets directory, so I've created one and copied d20_JPG in there. I modded imagewindow_image.lua to ignore the presence of a grid, but I'm still getting no altered behavior and no prints in the console. Maybe when I find the guide you're referring to, I'll find what I need.
I'd recommend using the 3.5e ruleset as a baseline for modification if you're interested in a d20 ruleset. This is much more up-to-date than the d20_JPG ruleset.

Trenloe
May 12th, 2013, 16:04
It seems that onMeasurePointer doesn't even get called unless the grid is active. Is there a way to bypass that and get it to call regardless of the grid state?
I'm not sure how to bypass this. One concern would be how do you measure a distance without the grid to provide the scale? Currently the grid (by default) provides the scale with each square being 5 feet - remove that grid and you don't know how many pixels equal 5 feet.

Brianide
May 12th, 2013, 16:21
I'm just going to hard code the grid scale instead of looking it up. I could also add a scale field later. However, if the grid is disabled, it won't even get to that code. It's like there's a check elsewhere for grid activation to see if it'll even run onMeasurePointer() or whatever. If you know what gets executed before the image control script starts executing, that'd be really helpful.

Brianide
May 13th, 2013, 01:55
I seem to have gotten it working, at least for vectors (the movement vectors you get when tokens are locked).

(replace "_" with " ". I had to add them in to display the spacing properly)
In imagewindow_image.lua:

function onMeasureVector(token, vector)

____local gridsize = 40;
____local dist = 0;

____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));

________dist = dist + math.floor( math.sqrt( gx^2 + gy^2 ) );
____end

____return dist .. "in";

____end

All I've done is hard coded the grid size to 40 pixels. I also dropped the x5 distance that D&D has, and I changed it to inches, since I'll be using this for Iron Kingdoms. I still need to tweak the scaling, but the idea is sound.