5E Product Walkthrough Playlist
  1. #1
    GMBazUK's Avatar
    Join Date
    May 2006
    Location
    Gloucestershire, England
    Posts
    148

    Referencing a database node name

    I have been carefully dissecting the JPG D20 ruleset in my continued quest to understand how I might incorporate some of its functionality/ideas into my own rule set.

    I've managed to integrate the dice drag function from the Abilities (Statistics) Bonus frame, whereby the dice can be plucked from the character sheet field and dropped on the chat window, but I cant understand how to get the chat output to report (like it does in the JPG D20 rule set), Strength Bonus.... or Dexterity Bonus.

    I understand the problem. The D20 ruleset,has individual abilitybonus numberfields with "description" text describing the particular bonus; so Strengthbonus says <description> Strength Bonus</description> etc

    My ruleset on the other hand is derived from the Anatomy of a Ruleset example, and so uses scripting to generate the character sheet frames 9and database nodes) from a central template which is simply called Abilities bonus.

    Code:
    draginfo.setDescription(self.description[1].text[1]);
    					draginfo.setNumberData(getValue());
    					draginfo.setShortcutData("charsheet", window.getDatabaseNode().getNodeName());
    This is the bit of scripting I think I need to change. I also think I have to reference the characteristics parent node name? I'm guessing here.

    Thanks in advance.
    Baz.

  2. #2
    Ultimately, the draginfo object is just a holder for information while it is being dragged between one location and another.

    The initial control will receive onDrag and onDragEnd events. (Also, onDragStart if updated to v2.8 compatibility.) The target control will received an onDrop event.

    In the case of the chat window, it will automatically roll the dice and generate an onDiceLanded event. If the onDiceLanded event is not handled by the ruleset, then the default chat window handling is to display a chat message entry using the dragdata description field and displaying the dice plus modifier.

    If you just want to change the text shown for the roll, you need to make sure that you use draginfo.setDescription() to specify the text you want to see with the roll.

    In the example from the Anatomy article, it is getting this information from a subtag of the control. If you specify a tag similar to the one below with each control, you should see the same results.

    Code:
    <numberfield>
    	...
    	<description>
    		<text>Text to display with roll</text>
    	</description>
    	...
    </numberfield>
    In general, any XML within the control definition can be accessed through the LUA script. Each unique tag name will be available as a table, and any values will be strings within those tables.

    In this case,
    * description[1] is used to access the first "description" tag within the control XML. If there was more than one description tag, then you would use 2, 3, 4, etc. to access them.
    * description[1].text[1] is used to access the first "text" tag within the first "description" tag.

    Some other thoughts:
    * You can check for the existence of tags first, if you want to create a template that does not throw script errors when tags are missing. (i.e. if description[1] then ...)
    * You can use type(...) to check the LUA object type of any variable in LUA. (i.e. string, number, function, ...) There are FG specific data types as well. (i.e. databasenode, windowinstance, ...)

    Regards,
    JPG

  3. #3
    GMBazUK's Avatar
    Join Date
    May 2006
    Location
    Gloucestershire, England
    Posts
    148
    Wow! Once again thank you Moon Wizard for your more than comprehensive response.
    Such is my understanding I'll set, resolving this problem, as my task for the day.
    Thanks again
    Baz.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in