PDA

View Full Version : Modify ruleset. Which to choose...?



Liktorn
May 19th, 2014, 07:25
Hi,

I want to modify a ruleset for a Swedish percentage based RPG. It contains seven attributes. Which ruleset is a good starting point? I have looked at the Anatomy_of_a_Ruleset.pdf and tried to use that to modify the CoreRPG. But I can't seem to show a list of attributes. Only the standard "make up our own list".

Any help would be helpful ;)

Valarian
May 19th, 2014, 08:24
How close is it to BRP? If a variation on that base system, I'd use that and the extension options available in that ruleset (see my BRP Star Trek extension for an example).

Liktorn
May 19th, 2014, 09:50
I'm not familiar with the BRP rules. Is it like: you have 55 in a skill, roll under with a D100 to succseed?
Is it easy to modify?
I don't really want to spend 28 USD on another system... unless I have to.
Also, I can't seem to find your Star Trek extension.

Valarian
May 19th, 2014, 10:37
It's under the Additional Extensions area of my community rulesets folder (link below in the signature).

There's a quickstart rules for BRP on drivethrurpg.https://rpg.drivethrustuff.com/product/82093/Basic-Roleplaying-Quickstart-Edition?filters=0_0_44826_0_0

The system is a roll under with a d100. It's the original Chaosium d100 system, updated and made generic. The example extension should let ypu know tge customisations available and whether it's worth you purchasing the BRP ruleset.

Arion
May 19th, 2014, 13:47
Even i have been able to create customised BRP-based rulesets! It is very straightforward.

Stollesson
May 19th, 2014, 14:24
Liktorn if you are looking for a "Drakar och Demoner" ruleset i have made one that is an extension for BRP.


Send me a PM if you are interested.

Liktorn
May 19th, 2014, 15:27
Liktorn if you are looking for a "Drakar och Demoner" ruleset i have made one that is an extension for BRP.


Send me a PM if you are interested.

Acctually it's not Drakar och Demoner. It's the remake of Mutant. Undergångens Arvtagare.
But I'm very intrested in your DoD also ;)

Liktorn
May 19th, 2014, 15:37
I am having trouble translating some of the strings. I have the charsheet_main where I am changing the static fields to Swedish. No problem, it shows up great. Then I try to make it an extension file instead. I'm copying the charsheet_main to my extension folder. But then I can't get it to work. The English names are back.
What am I doing wrong?

Valarian
May 19th, 2014, 15:53
Rather than trying to get the zipped .ext file straight away, create an extension folder under the extensions folder (e.g. Swedish Mutants). Then add the extensions.xml file calling the replacement charactersheet_main.xml file. You can then build it up step by step. When done, zip up the content of that extension sub-folder and rename to .ext.

Liktorn
May 19th, 2014, 16:25
That is how I am doing it. Like this in my extension.xml: <includefile source="charsheet.xml" /> (because that file has the charsheet_main in include).

Valarian
May 19th, 2014, 16:32
Are the modified files (charsheet.xml, charsheet_main.xml) also in your extension sub-folder?
Have you selected the extension when starting the campaign?

Liktorn
May 19th, 2014, 17:59
I have an extension sub folder simply called "Mutant". In that I have put the same charsheet.xml and charsheet_main.xml. With the only difference that I have done some minor name changes. All the changes are in the charsheet_main.xml fiile.
I have tried to call on, or both via the <includefile source="...">.
I'm not sure what I am doing wrong (or how the whole extension thing really works for that matter)

Trenloe
May 19th, 2014, 18:08
Please post here the contents of your extension.xml file.

As Valarian mentioned above - have you activated your extension on the "load campaign" screen before you start you campaign.

In addition, one thing to keep in mind is that when you make any changes to your extension you have to reload /reload in the chat window.

Liktorn
May 19th, 2014, 18:43
This is how my extension look like. I took it from BRP's own example "MyQuest" extension.
I do not know how to put the code in command.
Yes I have activated my extension and I use the /reload command. I'm not THAT stupid at least ;)


<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Copyright SmiteWorks USA, LLC., 2010 -->
<root version="2.0">
<properties>
<name>Mutant - UA</name>

<author>SmiteWorks USA, LLC., 2010</author>
<description>Sample campaign extension for the Basic Roleplaying ruleset.</description>
<!--
<exclusiongroup>BRPGameline</exclusiongroup>
-->
<ruleset>
<name>Mutant</name>
</ruleset>
</properties>



<base>
<includefile source="charsheet_main.xml" />

<!-- icons -->
<icon name="cs_logo" file="myq_logo.png" />

<!-- frames -->
<framedef name="myq_sheet">
<bitmap file="myq_sheet.png" />
<topleft rect="0,0,12,12" />
<top rect="12,0,322,12" />
<topright rect="334,0,12,12" />
<left rect="0,12,12,325" />
<middle rect="12,12,322,325" />
<right rect="334,12,12,325" />
<bottomleft rect="0,337,12,12" />
<bottom rect="12,337,322,12" />
<bottomright rect="334,337,12,12" />
</framedef>

<!-- window classes -->

<!-- tabcontrol template -->

<!-- charsheet templates -->

<!-- script file -->
<script name="MyQScript" file="scripts/myqscript.lua" />

</base>
</root>

Liktorn
May 19th, 2014, 18:57
Ok, I deleted my old charsheet file and replaced it with the original from the ruleset folder. Did the same changes again. And now it works :D

Lundgren
May 20th, 2014, 15:04
I haven't read Mutant: UA, so I'm not sure how much was changed from Mutant 2. But from what I have heard, I would count M: UA as a BRP derivate as well.

Stollesson, which version of DoD? I might be interested as well :)

Liktorn
May 20th, 2014, 15:31
I took a gamble and bought the system. So far it looks promising for the Mutant game. I do not have the old Mutant games, but I did play them ALOT 25(?) years ago. As far as I can remember, the spirit is the same.
I have not come far in my modification yet. Just changed some of the names to Swedish.
By the way, what do you Swedes play?

Stollesson
May 20th, 2014, 15:40
Lundgren It's a version of "Drakar och Demoner Expert"

Liktorn
May 20th, 2014, 16:09
Lundgren It's a version of "Drakar och Demoner Expert"

I'm still very interested :-D

Stollesson
May 20th, 2014, 18:58
Started a new thread on Game system BRP about "Drakar och Demoner".

Liktorn
May 20th, 2014, 21:24
Now I have a new problem. In BRP you can choose between different kind of weapon types in your character window. You can the click on a info button to get a new window, with some info of the weapons. Based on what type of weapon you clicked, some info is invisible (Melee weapons do not use ammo for instance). But other then that all the test is the same between the different kind of weapons. All this is controlled in adventure_weapons.xml
I have used this to hide some things (like parry for a gun and capacity (ammo) for a melee):
function recalc()
local typ = getDatabaseNode().createChild("weapontype","number").getValue();
if typ==1 then
caplabel.setVisible(true);
capacity.setVisible(true);
dblabel.setVisible(false);
dbflag.setVisible(false);
parrylabel.setVisible(false);
parry.setVisible(false);
else
capacity.setVisible(false);
caplabel.setVisible(false);
end
end
Can I some how use some kind of similar code to change what a static field is displaying? I have this code for instance:
<wpnfieldlabel name="attlabel">
<static>Rate of Fire</static>
</wpnfieldlabel>
<wpnstringfield name="attacks">
<anchored>
<to>attlabel</to>
</anchored>
<tabtarget>
<next>special</next>
<prev>damage</prev>
</tabtarget>
</wpnstringfield>
But I do not want my melee weapons to display "Rate of Fire". I would like it to display "Durability".

Anybody got some tips on how to do it?

Trenloe
May 20th, 2014, 21:40
Try: attlabel.setValue("Durability");

attlabel uses the wpnfieldlabel template, which is a stringcontrol: https://www.fantasygrounds.com/refdoc/stringcontrol.xcp

This inherits textbasecontrol which has the setValue command: https://www.fantasygrounds.com/refdoc/textbasecontrol.xcp#setValue

Liktorn
May 20th, 2014, 22:19
Try: attlabel.setValue("Durability");

attlabel uses the wpnfieldlabel template, which is a stringcontrol: https://www.fantasygrounds.com/refdoc/stringcontrol.xcp

This inherits textbasecontrol which has the setValue command: https://www.fantasygrounds.com/refdoc/textbasecontrol.xcp#setValue

I tried that now. Does not seem to work. Get this error: Script Error: [string "attlabel"]:1: attempt to index global 'attlabel' (a nil value)
Not sure that I use it correctly tho. Is it like this?:

<wpnfieldlabel name="attlabel">
<static>Rate of Fire</static>
<script>
function onInit()
attlabel.setValue("Durability");
end
</script>
</wpnfieldlabel>

even tried without function onInit(), and static text.

Liktorn
May 20th, 2014, 22:28
ok, I'm stupid! I got it to work!
I should not have used in the wpnfieldlabel code. I should have used it in the function recalc() code

Thank you for your help :)

Liktorn
May 22nd, 2014, 21:25
This is my next problem. I'm trying to change the Power Points to show HP pints instead. The numberfields I want to change is pp.current and pp.max (I believe) and is located in charsheet_main-xml. No problem changing them to a static value, like this for example: ppcur.setValue(666);
But I would like pp.max to show the value of strength and constitution (which I have renamed to "styrka" and "fysik").

I have searched for pp.max in the entire BRP folder, and can only find it in charactersheetlist.lua. If I try and change the value from there it wont work.

Any idea?

Trenloe
May 22nd, 2014, 22:29
I have searched for pp.max in the entire BRP folder, and can only find it in charactersheetlist.lua. If I try and change the value from there it wont work.
That code in charsheetlist.lua is part of the addNPC function that is called to create a new PC if an NPC link is dropped in the character list window.

You're best doing updates like this directly against the FG database - then all the GUI controls linked to that database field will be updated. Getting to know the database is a steep learning curve at first, but if you're going to be modifying rulesets you'll need to know it sooner rather than later. More info here: https://www.fantasygrounds.com/modguide/database.xcp

You can check the FG campaign database layout by opening the db.xml file in your campaign folder.

However, I'm confused that you're changing PP to show HP when HP is already in the BRP character sheet?

Is your version of HP different? How is it calculated?

There is some code in the BRP charsheet_main.xml file that auto calculates damage dice when abilities change - have a look at the code in <diefield name="damagedice"> - the onInit() function registers an event (onChildUpdate) for the abilities node in the database, which means that if any of the abilities change, this event will trigger and the "recalc" function will run. As a quick bit of coding you could add some code to this recalc function to also change the pp fields if any of the abilities change.

If you wanted to copy the value of strength to pp.max whenever the strength ability was changed, add the following code to the recalc() function (new code highlighted in red):

function recalc()
local strengthvalue = node.getChild("abilities.strength").getValue();
node.getChild("pp.max").setValue(strengthvalue);

local num = Global.Calc("STR+SIZ",node);
local gameline = LineManager.getLine();
local dice = gameline.DamageDice(num);

The "node" variable here is a databasenode object that points to the top level of this specific character sheet in the campaign database. Info on the database node object here: https://www.fantasygrounds.com/refdoc/databasenode.xcp

Here is a portion of the BRP character database:

<charsheet>
<id-00001>
<holder name="Player" owner="true" />
<abilities>
<holder name="Player" owner="true" />
<appearance type="number">10</appearance>
<constitution type="number">10</constitution>
<dexterity type="number">10</dexterity>
<education type="number">10</education>
<intelligence type="number">10</intelligence>
<power type="number">10</power>
<size type="number">10</size>
<strength type="number">10</strength>
</abilities>
<damagedice type="dice"></damagedice>
...
<pp>
<holder name="Player" owner="true" />
<current type="number">8</current>
<max type="number">10</max>
</pp>
"node" in the recalc() code essentially points to <id-00001>, using node.getChild("abilities.strength") returns the database node pointing to the <abilities><strength> entry - and then using getValue() gives the actual value of this databasenode entry.

Then you can do the same to get to pp.max: node.getChild("pp.max") to get the pp.max databasenode and then use the setValue() command to set the value.

Hope the above makes sense? It really is worth the while taking the time to get to know the BRP database structure and how to work with databasenodes within FG.

Liktorn
May 23rd, 2014, 06:47
That makes a lot of sense! Better yet, it works :D
The reason I want to change PP to HP is because in RPG I'm converting contains a lot of small secondary abilities that is calculated by the abilities. And I am having trouble fitting them all in. If I use the "real" HP fields I have can split them into two different fields due to them having big nice labels ;)

An other field I would like to change is the "Roll" fields from the abilities. I can't find them in the db.xml

By the way. I have changed all the characteristics to Swedish like this in brpscript.xml


Characteristics =
{ {Name="Styrka", Roll="Effort"},
{Name="Fysik", Roll="Stamina"},
{Name="Storlek"},
{Name="Intelligens", Roll="Idea"},
--{Name="Power", Roll="Luck"},
{Name="Smidighet", Roll="Agility"},
{Name="Vilja", Roll="Charisma"},
{Name="Personlighet", Roll="Know"}
}

How come it works when I use the following in charsheet_main.xml:

local num = Global.Calc("STY+STO",node);
I have not that I'm aware of changed STR to STY and SIZ to STO? Is that a function that have done that automatically? have it in that case done it for all the abilities I have changed

Trenloe
May 23rd, 2014, 07:39
How come it works when I use the following in charsheet_main.xml:

local num = Global.Calc("STY+STO",node);
I have not that I'm aware of changed STR to STY and SIZ to STO? Is that a function that have done that automatically? have it in that case done it for all the abilities I have changed
As part of the Global.Calc functionality, resolveName (in global.lua) takes the string and attempts to resolve it to an ability name - if the string is 3 characters long it will match to the first ability whose first 3 characters match the string. So, be sure that the 3 letter abbreviation used is the first 3 letters of the ability name.

Liktorn
May 23rd, 2014, 07:45
Does that mean I could have used this instead?

function recalc()
node.getChild("pp.max").setValue(STR);

Liktorn
May 23rd, 2014, 14:01
I'm trying to change the "Roll" values of strenght, constitution, education... The only thing I can find that seems to have anything to do with that is this:


<windowlist name="characteristics">
<anchored>
<top>
<parent>statframe</parent>
<anchor>top</anchor>
<offset>30</offset>
</top>
<left>
<parent>statframe</parent>
<anchor>left</anchor>
<offset>15</offset>
</left>
<right>
<parent>statframe</parent>
<anchor>right</anchor>
<offset>-15</offset>
</right>
</anchored>
<class>charsheet_characteristic</class>
<noscroll/>
<skipempty/>
<script>
function onInit()
local game = LineManager.getLine();
if game and game.Characteristics then
local charnode = window.getDatabaseNode();
if charnode then
local listnode = charnode.createChild("abilities");
if listnode then
for i,chr in ipairs(game.Characteristics) do
local name = string.lower(chr.Name);
local isnew = not listnode.getChild(name);
local node = listnode.createChild(name,"number");
local win = createWindow();
local roll = chr.Roll;
win.Initialise(node,chr.Name,roll,i,isnew);
end
end
end
end
end
</script>
</windowlist>

By default the Roll value is 5 times their corresponding ability. Can I change that in any way?

I'm doing great progress by the way. And have changed most of the things on the character sheet. All the skills are done. The powers will be easy cause I will not use any power points. Inventory will also be easy I guess. Just a matter of translating. Armor, easy. Notes, easy.
So whats left is the NPC, Encounter, Story, items, notes. Do not know how much work there is. NPC is the most I guess. With the creating PC from NPC. (but that is not a must have)
Thank you so much for the help so far. I can easily see me play this in the near future :D

Trenloe
May 23rd, 2014, 16:31
Does that mean I could have used this instead?

function recalc()
node.getChild("pp.max").setValue(STR);
You'd need to use:

node.getChild("pp.max").setValue(Global.resolveName("STR",node));

Trenloe
May 23rd, 2014, 16:37
I'm trying to change the "Roll" values of strenght, constitution, education... The only thing I can find that seems to have anything to do with that is this:


<windowlist name="characteristics">
<anchored>
<top>
<parent>statframe</parent>
<anchor>top</anchor>
<offset>30</offset>
</top>
<left>
<parent>statframe</parent>
<anchor>left</anchor>
<offset>15</offset>
</left>
<right>
<parent>statframe</parent>
<anchor>right</anchor>
<offset>-15</offset>
</right>
</anchored>
<class>charsheet_characteristic</class>
<noscroll/>
<skipempty/>
<script>
function onInit()
local game = LineManager.getLine();
if game and game.Characteristics then
local charnode = window.getDatabaseNode();
if charnode then
local listnode = charnode.createChild("abilities");
if listnode then
for i,chr in ipairs(game.Characteristics) do
local name = string.lower(chr.Name);
local isnew = not listnode.getChild(name);
local node = listnode.createChild(name,"number");
local win = createWindow();
local roll = chr.Roll;
win.Initialise(node,chr.Name,roll,i,isnew);
end
end
end
end
end
</script>
</windowlist>

By default the Roll value is 5 times their corresponding ability. Can I change that in any way?
The key piece of information in the above code is the <class>charsheet_characteristic</class> entry - this is the windowclass of each ability in the characteristics windowlist. This windowclass is defined in charsheet_listclasses.xml and has the following code that is used to set the rollvalue label control:

function setValue(newval)
if linknode then
if linknode.getValue()~=newval then
linknode.setValue(newval);
end
end
if value.getValue()~=newval then
value.setValue(newval);
end
rollvalue.setValue(5*newval);
end

Liktorn
May 27th, 2014, 19:11
In BRP, when I use the open the small weapon info window. I get an error in the console if I double click either the Base attack or the damage numbers.
Script Error: [string "damage"]:1: attempt to index field 'name' (a nil value)
Script Error: [string "attack"]:1: attempt to index field 'name' (a nil value)
Is there a way to fix that?

Trenloe
May 27th, 2014, 19:51
In BRP, when I use the open the small weapon info window. I get an error in the console if I double click either the Base attack or the damage numbers.
Script Error: [string "damage"]:1: attempt to index field 'name' (a nil value)
Script Error: [string "attack"]:1: attempt to index field 'name' (a nil value)
Is there a way to fix that?
In adventure_weapons.xml do a search for window.name and replace with window.parentcontrol.window.name - there should be 4 occurrences in the file that all need replacing.

Liktorn
July 1st, 2014, 14:15
I'm messing around with the Combat Tracker. For my game system I need the combat tracker to sort PC and NPC backwards, that is: I need the highest ranked PC/NPC to be at the top and the lowest to be the last to act. Any idea how I can accomplish this?

Trenloe
July 1st, 2014, 14:40
I'm messing around with the Combat Tracker. For my game system I need the combat tracker to sort PC and NPC backwards, that is: I need the highest ranked PC/NPC to be at the top and the lowest to be the last to act. Any idea how I can accomplish this?
If this is still referring to the BRP ruleset, then look at the onSortCompare function in \scripts\combattracker.lua

Liktorn
July 3rd, 2014, 08:41
If this is still referring to the BRP ruleset, then look at the onSortCompare function in \scripts\combattracker.lua

Thank you! That worked out great!

Liktorn
July 3rd, 2014, 08:51
It seems my problems never ends.
Now I'm trying to add a third weapon type (really an armor type) in the weaponframe in charsheet_main. I copied the Melee code and renamed all the fields. But when I try it out I get an dublicated melee list. That is, if I ad an item in the Melee list, the same item is shown as a dublicate in my newly created Armor list.
Here is my code:


<!------------------------------------------------------armor------------------------------------>
<stringcontrol name="armorlabel">
<anchored>
<left>
<parent>weaponframe</parent>
<anchor>left</anchor>
<offset>15</offset>
</left>
<top>
<parent>missileweapons</parent>
<anchor>bottom</anchor>
<offset>-50</offset>
</top>
</anchored>
<font>sheetlabel</font>
<static>Rustning/Sköld</static>
</stringcontrol>
<genericcontrol name="minilabel3">
<anchored>
<right>
<anchor>right</anchor>
<offset>-17</offset>
</right>
<top>
<parent>armorlabel</parent>
<anchor>top</anchor>
<offset>2</offset>
</top>
<size>
<width>10</width>
<height>10</height>
</size>
</anchored>
<icon>indicator_quicklist</icon>
<tooltip>
<text>Visa på miniformulär</text>
</tooltip>
</genericcontrol>
<stringcontrol name="infolabel3">
<anchored>
<to>minilabel3</to>
<position>lefthigh</position>
<offset>-1,0</offset>
<size>
<width>30</width>
</size>
</anchored>
<center />
<font>sheetlabelinline</font>
<static>Info</static>
</stringcontrol>
<!----------------------------------------tål----------------------------->
<stringcontrol name="tallabel">
<anchored>
<to>infolabel3</to>
<position>lefthigh</position>
<offset>0,0</offset>
<size>
<width>24</width>
</size>
</anchored>
<center />
<font>sheetlabelinline</font>
<static>Tål</static>
</stringcontrol>
<!----------------------------------------värde----------------------------->
<stringcontrol name="vardelabel">
<anchored>
<to>tallabel</to>
<position>lefthigh</position>
<offset>8,0</offset>
<size>
<width>30</width>
</size>
</anchored>
<center />
<font>sheetlabelinline</font>
<static>Värde</static>
</stringcontrol>
<!-----------------------------------------vikt----------------------------------->
<stringcontrol name="viktlabel">
<anchored>
<to>vardelabel</to>
<position>lefthigh</position>
<offset>0,0</offset>
<size>
<width>25</width>
</size>
</anchored>
<center/>
<font>sheetlabelinline</font>
<static>Vikt</static>
</stringcontrol>
<!-----------------------------------------BEG----------------------------------->
<stringcontrol name="beglabel">
<anchored>
<to>viktlabel</to>
<position>lefthigh</position>
<offset>5,0</offset>
<size>
<width>41</width>
</size>
</anchored>
<font>sheetlabelinline</font>
<static>BEG</static>
</stringcontrol>
<!-----------------------------------------ABS----------------------------------->
<stringcontrol name="abslabel">
<anchored>
<to>beglabel</to>
<position>lefthigh</position>
<offset>5,0</offset>
<size>
<width>55</width>
</size>
</anchored>
<font>sheetlabelinline</font>
<static>ABS</static>
</stringcontrol>

<windowlist name="armor">
<anchored>
<left>
<parent>weaponframe</parent>
<anchor>left</anchor>
<offset>15</offset>
</left>
<right>
<parent>weaponframe</parent>
<anchor>right</anchor>
<offset>-15</offset>
</right>
<top>
<parent>armorlabel</parent>
<anchor>bottom</anchor>
<offset>0</offset>
</top>
</anchored>
<datasource>.weaponlist</datasource>
<class>charsheet_weapon</class>
<maxdisplayrows>6</maxdisplayrows>
<rowheight>18</rowheight>
<Heavy/>
<acceptdrop>
<class>weapon</class>
<field>name</field>
<field>weapontype</field>
<field>attack</field>
<field>baseskill</field>
<field>damage</field>
<field>malfunction</field>
<field>range</field>
<field>attacks</field>
<field>hp</field>
<field>dbflag</field>
<field>capacity</field>
<field>notes</field>
<field>special</field>
<field>hands</field>
<field>parry</field>
<field>strdex</field>
<field>sr</field>
<field>value</field>
<field>encumbrance</field>
</acceptdrop>
<script file="scripts/charsheet_weaponlist.lua" />
</windowlist>
<scrollercontrol>
<anchored>
<to>armor</to>
<position>insidebottomright</position>
<offset>-5,-6</offset>
<size>
<width>45</width>
<height>27</height>
</size>
</anchored>
<target>armor</target>
<button>
<normal>button_scroller</normal>
<pressed>button_scroller_down</pressed>
</button>
</scrollercontrol>

Note: if I change the <melee/> part to anything else, then it's the missile list that gets duplicated.

Stollesson
July 4th, 2014, 07:34
Hi

I been stuck on that problem too, I think it's in the "charsheet_weaponlist.lua" you must change.
But my coding skills is too low too fix it.
I change the shields for my DoD project so they go under melee instead.

Moon Wizard
July 4th, 2014, 08:21
For windows that support multiple "types", there is usually a script file that determines the "type" and then turns fields on/off based on the "type" value. I'm not familiar with BRP, so not sure of the specifics; but something similar is used in 3.5E, 4E and 5E.

Regards,
JPG

Liktorn
July 6th, 2014, 11:13
Hi

I been stuck on that problem too, I think it's in the "charsheet_weaponlist.lua" you must change.
But my coding skills is too low too fix it.
I change the shields for my DoD project so they go under melee instead.
I figured as much, but every attempt I've made so far to the charsheet_weaponlist.lua has resulted in a lot of errors. Your solution is not a bad idea, but I would like to have it separated.



For windows that support multiple "types", there is usually a script file that determines the "type" and then turns fields on/off based on the "type" value. I'm not familiar with BRP, so not sure of the specifics; but something similar is used in 3.5E, 4E and 5E.

Regards,
JPG
There seem to be more then one type. But I can't figure out how to activate them. In brpscript.lua there is this:

WeaponTypes = {
["0"] = "Melee",
["1"] = "Missile",
["2"] = "Heavy",
["3"] = "Artillery",
["4"] = "Explosive"
},
But it seems that Melee is default, and if not melee, then it is missile.

Trenloe
July 6th, 2014, 13:36
There seem to be more then one type. But I can't figure out how to activate them. In brpscript.lua there is this:

WeaponTypes = {
["0"] = "Melee",
["1"] = "Missile",
["2"] = "Heavy",
["3"] = "Artillery",
["4"] = "Explosive"
},
But it seems that Melee is default, and if not melee, then it is missile.
In scripts\charsheet_weaponlist.lua the code that is executed when right-click -> New Weapon is selected is:

function onMenuSelection(item)
if item and item==5 then
local win = createWindow();
local node = win.getDatabaseNode();
if not ismelee then
node.createChild("weapontype","number").setValue(1);
end
return true;
end
end
The above highlighted code is where the weapontype is set to 1 (Missile) if the section where the right-click was initiated is not the melee section, otherwise the default of 0 (Melee) will be used.

You'll need to add your new weapon type to the WeaponTypes table you have listed above and then code in the onMenuSelection function to check where the New Weapon right-click menu was selected and set weapontype to the number relating to your new type in the WeaponTypes table.

ismelee is set in the onInit() function for each windowlist:

if melee then
ismelee = true;
end
Which gets set if <melee /> is present in the windowlist XML - which it is, of course, for only the meleeweapons windowlist.

The problem is that ismelee gets reset in the onFilter function - so there'll have to be some code to cater for that as well.

Not a simple solution as ismelee is always true if weapontype isn't 1. The code needs to be changed to make that the case for values of 1 and whatever you will use for your new weapon type - and you'll have to code for that new type too.

Liktorn
March 18th, 2015, 09:16
I'm back. Had a computer crash and didn't have the time nor the desire to do all the work again...
Just as well really, cause I changed to many different things at once, and had problem troubleshooting what was causing what errors...
But now I'm taking it on again. On a different route, that I think will work better. But as usual I'm stuck...

(this is still the BRP ruleset btw)

What I am trying to do is change the "Roll" attribute on characteristics. I want to use it as a modifier on the original attributes, so I have changed the name to Mod.

Characteristics =
{ {Name="Styrka", Mod=1},
{Name="Fysik", Mod=0},
{Name="Storlek", Mod=0},
{Name="Smidighet", Mod=0},
--{Name="Power", Roll="Luck"},
{Name="Intelligens", Mod=0},
{Name="Vilja", Mod=0},
{Name="Personlighet", Mod=0}
},
I have tried with "Mod="number" and or a value. Do not know what it should be.
But the real problem I am having is when I try to store this in the database. I figure that it is in charsheet_main.xml that the storing gets done. so I have tried this:

<class>charsheet_characteristic</class>
<noscroll/>
<skipempty/>
<script>
function onInit()
local game = LineManager.getLine();
if game and game.Characteristics then
local charnode = window.getDatabaseNode();

--[[local name = string.lower(game.Name);
charnode.createChild(name.mod, "number");]]

if charnode then
local listnode = charnode.createChild("abilities");
if listnode then
for i,chr in ipairs(game.Characteristics) do
local name = string.lower(chr.Name);
local isnew = not listnode.getChild(name);
local node = listnode.createChild(name,"number");
local mod = listnode.createChild(chr.Mod);
local win = createWindow();
--[[local mod = chr.Mod;]]
win.Initialise(node,chr.Name,mod,i,isnew);
end
end
end
end
end
</script>
But it is not working. I have tried a couple of different listnode.createChild(chr.Mod);types (chr.Mod,"number" , name.Mod,"number"...)
As it is, I am stuck. Would really appreciate some help

Trenloe
March 18th, 2015, 15:09
The createChild code just creates an empty databasenode, I don't see you setting any values in that database node using <dbnode>.setValue(XXX) where XXX is the value you want to set in the newly created child dbnode.

You might also want to add some Debug.console code to make sure your code is running OK. Output to the console <dbnode>.getNodeNAme to indicate where the dbnodes are being created: https://www.fantasygrounds.com/refdoc/databasenode.xcp#getNodeName

Liktorn
March 18th, 2015, 15:24
The createChild code just creates an empty databasenode, I don't see you setting any values in that database node using <dbnode>.setValue(XXX) where XXX is the value you want to set in the newly created child dbnode.

I don't think empty database nodes are saved to the database.
I tried that. Like:

local mod = listnode.createChild(chr.Mod).setValue(66);
(66 just as it should be easy searching for IF it enden up in the database;))
but what i ended up with in db.xml was empty snippets.

<abilities>
<_>
</_>
<fysik type="number">16</fysik>
<intelligens type="number">15</intelligens>
<personlighet type="number">12</personlighet>
<smidighet type="number">13</smidighet>
<storlek type="number">18</storlek>
<styrka type="number">34</styrka>
<vilja type="number">11</vilja>
</abilities>

Trenloe
March 18th, 2015, 15:36
They're not actually empty - the XML tag is being created with a name of _ (underscore) See my edit to post #44 above - I suggest you add some Debug.console code to see exactly what dbnode you're creating - and also write your chr.name and chr.mod info to the console as well so you'll see exactly what FG is working with.

Liktorn
March 18th, 2015, 15:53
They're not actually empty - the XML tag is being created with a name of _ (underscore) See my edit to post #44 above - I suggest you add some Debug.console code to see exactly what dbnode you're creating - and also write your chr.name and chr.mod info to the console as well so you'll see exactly what FG is working with.

Not sure how to use the Debug.console.

Trenloe
March 18th, 2015, 16:12
Not sure how to use the Debug.console.
Info here: https://www.fantasygrounds.com/refdoc/Debug.xcp#console

Simply contract a text string as the value to output. Open the console using /console in trenchant window.

An example would be: Debug.console("node = " .. node.getNodeName());

This would output the name of the DB node pointed to by the node database node object.

Using such debugging output will help you track down issues - I use it a lot, so should you! :-)

Liktorn
March 18th, 2015, 19:35
I will have to test that tomorrow.
You mean that I can type, for example:
Debug.console("node = " .. node.getNodeName());
directly into the console?
I can agree that this look terrible useful :)

Trenloe
March 18th, 2015, 20:05
You mean that I can type, for example:
Debug.console("node = " .. node.getNodeName());
directly into the console?
Nope, you put that code directly in your scripts - on a separate line for each Debug.console command. It allows you to write as much, or as little, info as you want to the console sequentially as it occurs.

Liktorn
March 18th, 2015, 21:16
Nope, you put that code directly in your scripts - on a separate line for each Debug.console command. It allows you to write as much, or as little, info as you want to the console sequentially as it occurs.

OK, and it will only show if I have used the /console command in chat?
I'm looking forward to test this :)

Liktorn
March 19th, 2015, 11:55
I cant seem to wrap my head around this. I have this code in myscript.lua:


Characteristics =
{ {Name="Styrka", Mod=222},
{Name="Fysik", Mod=333},
{Name="Storlek", Mod=444},
{Name="Smidighet", Mod=555},
--{Name="Power", Roll="Luck"},
{Name="Intelligens", Mod=666},
{Name="Vilja", Mod=777},
{Name="Personlighet", Mod=888}
},

I want to access, modify and store the "Mod" value of the different characteristics.
I had a code that stored it in db.xml, but i changed it, and now I can't figure out how the hell I did it. Anyway it was not correctly stored. It was like this:


<abilities>
<_>
<_/>
<_22>
<_22/>
...
<fysik type="number">15</fysik>
<intelligens type="number">14</intelligens>
<personlighet type="number">13</personlighet>
...
</abilities>

In charsheet_main.xml, in function onInit(), I have this:


if charnode then
local listnode = charnode.createChild("abilities");
if listnode then
for i,chr in ipairs(game.Characteristics) do
local name = string.lower(chr.Name);
local mod = chr.Mod;

local isnew = not listnode.getChild(name);

local node = listnode.createChild(name,"number");
local win = createWindow();

mod = node.createChild(chr.Mod);
Debug.console(node.createChild(chr.Mod));
--[[local mod = chr.Mod;]]
win.Initialise(node,chr.Name,chr.Mod,i,isnew);--[[isnew]]

some of the code is crap... but using the Debug.console(node.createChild(chr.Mod)); i get this in the console:

Runtime Notice: databasenode = { charsheet.id-00001.abilities.styrka._22 }
Runtime Notice: databasenode = { charsheet.id-00001.abilities.fysik._33 }
Runtime Notice: databasenode = { charsheet.id-00001.abilities.storlek._44 }
Runtime Notice: databasenode = { charsheet.id-00001.abilities.smidighet._55 }
Runtime Notice: databasenode = { charsheet.id-00001.abilities.intelligens._66 }
Runtime Notice: databasenode = { charsheet.id-00001.abilities.vilja._77 }
Runtime Notice: databasenode = { charsheet.id-00001.abilities.personlighet._88 }
What I do not understand is where the underscore comes from? And why the first number disappeared.
And what am I doing wrong, not being able to save it to the db.xml.



Puh... that was a long one...

Trenloe
March 19th, 2015, 14:15
As I mentioned in post #44 above, you're not setting any values in the database node you're creating. You need to use <db node>.setValue to put information into the node you create. using <dbnode>.createChild just creates another database node under the child - which is exactly what you're seeing. The underscore replaces the first number as XML tags can't begin with numbers. So 222 is being renamed to _22. Anyway, that is just a side effect, you don't need to use a second createChild method, you need to use setValue. See post #42 from the middle of last year - what you need is highlighted in red. I must have seen into the future! ;)

Liktorn
March 19th, 2015, 14:58
Ok, I finally did it!
What i tried to do was this:

local name = string.lower(chr.Name);
local mod = string.lower(chr.Mod);
local isnew = not listnode.getChild(name);
local node = listnode.createChild(name,"number");
node.createChild(mod,"number").setValue(69);
What worked was when I changed it to this:

listnode.createChild(mod,"number").setValue(69);

Now, the only thing is to actually DO something with that new value.
I guess I will be back soon... with more stupid questions.

But for now, you are my hero Trenloe!

Nylanfs
March 19th, 2015, 15:53
He's a hero to all of us. :)

Liktorn
March 24th, 2015, 09:54
I want to use the totalweight NumberField, under <sheetdata> in <windowclass name="charsheet_inventory">.
I have created a NumberField in charsheet_main.xml, where I want totalwight to show. How do I show a value from a different file and windowclass in charsheet_main.xml?

The alternative is that I load the value from db.xml using:

local bfweight = node.getChild("inventorylist.id-00001.weight").getValue();
I have two problems with that. There is some delay saving the weight from charsheet_inventory.xml to the database. Therefore the value will not show directly after adding items with weight.
Second, I need to ad the "id-00001" to the string. I do not know how to get the ID without getting the whole name, like with node.getNodeName()

If possible, I would like to acces the "totalwight" value in charsheet_inventory.xml prior to using the database.
Is there a simple solution?

Trenloe
March 24th, 2015, 15:04
In <windowclass name="charsheet_inventory">/B] change [B]<NumberControl name="totalweight"> to <NumberField name="totalweight"> then the total weight will be stored in the database in the totalweight field. If your NumberField in charsheet_main is called the same (totalweight) then they should be automatically linked as they will be sourced on the same database field.

Note: the inventory.id-XXXXX.weight database nodes you mention above are the weight for individual items, not the total weight for all items tagged as "Apply weight to Encumbrance".

Liktorn
March 24th, 2015, 18:32
In <windowclass name="charsheet_inventory">/B] change [B]<NumberControl name="totalweight"> to <NumberField name="totalweight"> then the total weight will be stored in the database in the totalweight field. If your NumberField in charsheet_main is called the same (totalweight) then they should be automatically linked as they will be sourced on the same database field.

Note: the inventory.id-XXXXX.weight database nodes you mention above are the weight for individual items, not the total weight for all items tagged as "Apply weight to Encumbrance".

Thank you Trenloe. That was exactly as I wanted it :D An easy and effective solution, and I learned something new today also ;)
Good thing I did not go any further with the inventory.id-XXXXX.weight thingy...

Thanks a lot!