PDA

View Full Version : Modifying D20_JPG



Stitched
August 22nd, 2010, 22:46
Hi,

I have a question about how the default abilities get set with a value of "10" in the D20_JPG ruleset. I thought it would be an OnInit() statement but I cannot find it anywhere in any of the files. Can someone point out where I can find this value setting or at least how to set the default numbers for this?

I should ask while I am thinking about it : all the "_template" files, are they used by the ruleset or are these copy and paste code "snippets" that can be re-used anywhere in the ruleset?

Moon Wizard
August 22nd, 2010, 22:55
Stitched,

It is actually in an onInit call within a template ("abilityscore"), that can be found in charsheet_templates.xml.

The templates can be reused anywhere in the ruleset, as long as they are included before you use them.

Cheers,
JPG

Stitched
August 22nd, 2010, 22:59
I was just going to type that I found where it's initialized.

I have another question about what I am doing. The ability scores, in the game that I am building a ruleset for, are really +/- modifiers. Since I am not basing them on any data (base number), how I would I link the ability modifier to a dice roll (drag or double click) ?

Moon Wizard
August 22nd, 2010, 23:28
You can look at the onDoubleClick and onDrag code for the character sheet fields to get an idea of how to create a roll. Ultimately, you are calling chatwindow.throwDice (for double-clicking), or settings the dragdata object fields (for dragging).

Try looking at the initmain template in charsheet_templates.xml.

Regards,
JPG

Stitched
August 23rd, 2010, 08:57
Was getting an error using "initmain"...(will post details when I get home).

Would <abilitybonus> be better to implement, instead?

Moon Wizard
August 23rd, 2010, 17:30
Actually, you'll probably want to define your own template, since your requirements for that field are simpler then both those templates. (which both are derived from other fields)

I was just pointing to "initmain" as an example of how you would implement drag/double-click support.

Regards,
JPG

Stitched
August 23rd, 2010, 17:57
I get this error:
Script Error: [string "charsheet_main:communication"]:1: attempt to index field 'description' (a nil value)

So I guess it's requiring a "description" entry but where would I find that information on what a template needs? It's not like a function that has attributes (x,y,z...)

But since I am using your ruleset as a "template", is it not possible to use one of the template controls, since <abilityscore> doesn't work?

The majority of dice rolls in the game are :

3d6 + Ability Score (which is represented from -2 to +4) + Ability Focus (if you have the specific focus you add +2).

Moon Wizard
August 23rd, 2010, 18:09
You just need to look at an example of the template in use. The fields using that template have a <description><text>blahblah</text><description> defined. This determines the text that is used to describe the roll in the chat window.

I originally wrote the d20_JPG as a fan-built community project, so it's not really built to be well documented and reusable. However, it shouldn't be too bad to use as a basis.

Cheers,
JPG

Stitched
August 23rd, 2010, 18:42
Ah, I see. Which ruleset do you recommend to build on, if not D20_JPG?

Moon Wizard
August 23rd, 2010, 19:12
It's a toss-up really. There are a few rulesets designed better to be built from scratch (Base, Generic), but they don't have as many examples and ideas.

I'd say for your first effort, you are best off using d20_JPG or 4E, since they have the most capabilities. You can just ignore the bits you don't need, then pare them out as you understand the system more. That's how I did it.

Cheers,
JPG

Stitched
August 24th, 2010, 23:42
OK. I made some nice progress now.

Have the Abilities formatted the way I want with a modifier number appearing (draggable and double-click dice) instead of a number; which gets added to the roll with the appropriate text.

What I wanted to know is if it is possible to set a min value / max value on the number in the statbox (an integer between -2 and +4). I couldn't see a command in the reference so I am guessing it would be somewhere in the LUA scripts?

Moon Wizard
August 25th, 2010, 08:05
You would have to capture the onValueChanged event, and then limit the range there. Make sure to use a trapping variable, if you are using setValue in the onValueChanged function.



function onValueChanged()
if not checkrange then
checkrange = true;

local nValue = getValue();
if (nValue < -2) then
setValue(-2);
elseif (nValue > 4) then
setValue(4);
end

checkrange = false;
end
end


Cheers,
JPG

Stitched
August 28th, 2010, 15:57
Trapping variable? You are speaking Greek. :)

Since this is template that is used for all the abilities, couldn't I just add this to the template handler for these boxes?

I tried changing getValue to read the local "abilities.(name).bonus" value but it wasn't working or limiting the value. Do you need to use the DataBaseNode().getChild() call if it's inside the template?



You would have to capture the onValueChanged event, and then limit the range there. Make sure to use a trapping variable, if you are using setValue in the onValueChanged function.



function onValueChanged()
if not checkrange then
checkrange = true;

local nValue = getValue();
if (nValue < -2) then
setValue(-2);
elseif (nValue > 4) then
setValue(4);
end

checkrange = false;
end
end


Cheers,
JPG

Moon Wizard
August 31st, 2010, 19:19
Trapping variable just means something that prevents the setValue and onValueChanged functions from being called in an endless loop.

Yes, you can add to the template. There is no reason you need to use anything other than getValue, unless you are trying to pull values from another field at the same time. Then, it would get more complicated.

You can post your template code, if you want me to take a look.

Cheers,
JPG

Stitched
August 31st, 2010, 19:43
Entering the code, verbatim, didn't work...


Script Error: [string "charsheet_main:communication"]:1: ')' expected near '<eof>'
Script Error: [string "charsheet_main:constitution"]:1: ')' expected near '<eof>'
Script Error: [string "charsheet_main:cunning"]:1: ')' expected near '<eof>'
Script Error: [string "charsheet_main:dexterity"]:1: ')' expected near '<eof>'
Script Error: [string "charsheet_main:magic"]:1: ')' expected near '<eof>'
Script Error: [string "charsheet_main:perception"]:1: ')' expected near '<eof>'
Script Error: [string "charsheetmini_basic:strengthbonus"]:1: ')' expected near '<eof>'
Script Error: [string "charsheetmini_basic:dexteritybonus"]:1: ')' expected near '<eof>'
Script Error: [string "charsheetmini_basic:constitutionbonus"]:1: ')' expected near '<eof>'
Script Error: [string "charsheetmini_basic:intelligencebonus"]:1: ')' expected near '<eof>'
Script Error: [string "charsheetmini_basic:wisdombonus"]:1: ')' expected near '<eof>'
Script Error: [string "charsheetmini_basic:charismabonus"]:1: ')' expected near '<eof>'
Script Error: [string "communication"]:1: ')' expected near '<eof>'
Script Error: [string "constitution"]:1: ')' expected near '<eof>'
Script Error: [string "cunning"]:1: ')' expected near '<eof>'
Script Error: [string "dexterity"]:1: ')' expected near '<eof>'
Script Error: [string "magic"]:1: ')' expected near '<eof>'
Script Error: [string "perception"]:1: ')' expected near '<eof>'


Removing the code, removes the errors.



<script>
function onValueChanged()
if not checkrange then
checkrange = true;

local nValue = window.getDatabaseNode().getValue();
if (nValue < -2) then
nValue.setValue(-2);
elseif (nValue > 4) then
nValue.setValue(4);
end

checkrange = false;
end
end
...



Trapping variable just means something that prevents the setValue and onValueChanged functions from being called in an endless loop.

Yes, you can add to the template. There is no reason you need to use anything other than getValue, unless you are trying to pull values from another field at the same time. Then, it would get more complicated.

You can post your template code, if you want me to take a look.

Cheers,
JPG

Stitched
August 31st, 2010, 20:34
It's strange. If I just use:


function onValueChanged()
if not checkrange then
checkrange = true;
local nValue = getValue();
print (nValue);
if nValue > 4 then
setValue(4);
...


It works fine. If I add the other bits:


else nValue < -2 then
setValue(-2);
end
checkrange = false;
end


It says there is problem with my </sheetbonus> tag and refuses to load FG2.

Moon Wizard
August 31st, 2010, 20:52
I didn't check the code to make sure it was working, just gave an example off the top of my head.

I think you just need to change "else" to "elseif".

Cheers,
JPG

Stitched
August 31st, 2010, 20:55
Tried that and it still throws errors. Can't figure it out.



<script>
function onValueChanged()
if not checkrange then
checkrange = true;

local nValue = getValue();
print (nValue);
if (nValue < -2) then
setValue(-2);
else (nValue > 4) then
setValue (4);
end
checkrange= false
end
end
...



Added to the <template name="abilitybonus"> entry under charsheet_template.xml if you want to test it.



I didn't check the code to make sure it was working, just gave an example off the top of my head.

I think you just need to change "else" to "elseif".

Cheers,
JPG

Moon Wizard
August 31st, 2010, 21:57
I didn't see the elseif replacement in the last code you posted. Also, it looks like you are including the script code in-line with the script, as opposed to a separate file. This means that XML special characters will need to be escaped.



function onValueChanged()
if not checkrange then
checkrange = true;

local nValue = getValue();
print (nValue);
if (nValue &lt; -2) then
setValue(-2);
elseif (nValue &gt; 4) then
setValue (4);
end
checkrange= false
end
end


Cheers,
JPG

Stitched
September 1st, 2010, 10:02
Ah, thanks. I was looking for the special characters for greater than / less than. Cheers for posting that. It explains why it was crying about properly closed tags...


I didn't see the elseif replacement in the last code you posted. Also, it looks like you are including the script code in-line with the script, as opposed to a separate file. This means that XML special characters will need to be escaped.



function onValueChanged()
if not checkrange then
checkrange = true;

local nValue = getValue();
print (nValue);
if (nValue &lt; -2) then
setValue(-2);
elseif (nValue &gt; 4) then
setValue (4);
end
checkrange= false
end
end


Cheers,
JPG

Callum
September 1st, 2010, 12:33
Trapping variable? You are speaking Greek. :)
No, he's speaking Geek. ;)

ludol
October 6th, 2010, 20:50
hi,

i'm adapting a Conan OGL rulleset with D20_JPG and i need some help to had a modifier when PC drop dice damage on a map NPC token.

I would like to use SQ value as DR (damage reduction) to this drop for damage count.

Any idea which script file i need to modify ?

Thx

ludol

bigdruid
November 21st, 2010, 17:44
Out curiosity, how much work is it to add the masking in the maps to this ruleset? It's the one thing I really miss.

bigdruid
November 21st, 2010, 18:04
Out curiosity, how much work is it to add the masking in the maps to this ruleset? It's the one thing I really miss.In my patch notes, I have the following two lines.

# Straight vertical and horizontal lines can now be drawn by depressing the shift key. This works for both drawing strokes and mask revealing.
# When unveiling a masked image, you can now hold down the control key when ending the mouse drag to remask areas of the drawing.

Now, I first thought they were for another ruleset but I CAN use the straight line drawing, so I'm wondering how I get the mask it mentions working? In another ruleset it was off of the drawing layers.

Sorcerer
November 21st, 2010, 18:23
right click on the image, select layers and then enable mask.

to be honest I think masking is controlled by FG and not the ruleset so it should be the same in every ruleset.

bigdruid
November 21st, 2010, 18:37
right click on the image, select layers and then enable mask.

to be honest I think masking is controlled by FG and not the ruleset so it should be the same in every ruleset.Actually, that's where I expected it but I don't have it. I have Enable Short Cuts, Change Grid Type and Disable Grid. Nothing else.

Sorcerer
November 21st, 2010, 18:46
That I would suggest is very strange...
but I can assure you I have just opened up FG with d20_JPG v3.0.5
and it is definitely there on my version.

bigdruid
November 21st, 2010, 18:56
That I would suggest is very strange...
but I can assure you I have just opened up FG with d20_JPG v3.0.5
and it is definitely there on my version.
OK. Where do I find my version? I may reinstall it for next session.

Sorcerer
November 21st, 2010, 19:00
its on the downloads section of this site


https://www.fantasygrounds.com/filelibrary/fg2_d20_jpg_v3_0_5.zip

bigdruid
November 27th, 2010, 13:37
So I'm seriously puzzled as to what I'm missing here. I've uninstalled the FG2 program (scrubbing registry and rebooting), renamed my folder in application data so it starts fresh with no campaigns and still, when I right-click in layers, I only have grid options and no mask options.

I'm using Win7x64, but don't think that is at issue here as everything else seems to be fine.

Any other suggestions? This is kind of a big thing for me as you probably guessed.

Leonal
November 27th, 2010, 14:32
@bigdruid: And this is on an image you've added to your newly created campaign?

Just checking in case you were trying to add a mask to a blank drawing (i.e. by clicking create image in the images & map box) as that won't work.

bigdruid
November 27th, 2010, 14:54
@bigdruid: And this is on an image you've added to your newly created campaign?

Just checking in case you were trying to add a mask to a blank drawing (i.e. by clicking create image in the images & map box) as that won't work.

Well, in this case, that was what I was doing. However, previously, I was trying to add a mask to drawings I'd sketched out which I thought I'd been able to do before, but on another ruleset/campaign almost a year ago.

What exactly is the process to do a mask; I'm certainly not ruling out user error here.

Leonal
November 27th, 2010, 23:30
Ah, I've never had need to add a mask to drawings created in FG so I've never missed it (I only use it for already created jpg/png maps), and wasn't aware it was possible in other rulesets.

I'm sure moon_wizard or some one else familiar with the coding behind masks can help out as its currently not supported in the d20_JPG ruleset (for manual drawings).

Moon Wizard
November 28th, 2010, 06:19
Masks are not supported over pure drawings. The mask layer only affects the image supplied by underlying files placed in the campaign images folder.

I actually tried to add this quickly in v2.7, but it ended up not looking good and running slow. Therefore, this request was pushed back on the wish list for my long-term map/token update.

Cheers,
JPG

bigdruid
November 28th, 2010, 18:59
Ok...I just loaded an actual jpg and I have the ability to use the mask as I remembered so either this ruleset has it working slightly diff than the last I used or my memory sux. I'd say option b has the slight edge.

Thanks everyone, sorry for the bother.