5E Character Create Playlist
  1. #1

    Join Date
    Mar 2009
    Location
    Lidingö, Sweden, Europe
    Posts
    367

    Updating total wounds on click instead of on drop

    In the Basic Roleplaying ruleset you can choose to use hit locations in your campaign. The hit location record looks like this:
    hit_locations.png

    I would like to implement the functionality that works like this: if the user clicks on the field "Wounds" and updates the amount, then the node that holds the total amount of wounds (hpcur) will also be updated with the amount changed.

    So for example if I change the the value of the field wounds for the hit location "right leg" and sets the value to 2 then the total amount of wounds is updated to current value +2. And similarly if I reduce the value to 1 then the total amount should be reduced by (in this case) one.

    This is how I figured it so far:

    The trick I guess is to get hold of the current value of the field so that you know whether to add to or substract from (and how much) the total value.

    If I use onChange I will just get hold of the actual value of the field so I need to react before any change is done. I'm thinking that if I use onClick and save the value before the change I can use the difference between the saved value and the new value in the onChange function to update the total wounds value.

    Is this a good approach or are there better way of doing it? Do you know of any examples of similar functions that I could study?

    /Peter

  2. #2
    Well the hit location is enabled by the options you have selected. So you would have to also check to see when it's supposed to be used and when it's not. Then from there, I would basically set it up to where the wounds on the PC sheet 'listens' to the elements. This is handled through addHandler function. You can find many examples in the internal rulesets. Then when one of those fields change it collects all of the wound controls and then adds them all up.
    Dominic Morta
    Ruleset Developer
    Smiteworks

    How to zip up your campaign if the Developers ask for it-How to zip up your campaign if the Developers ask for it

    How to provide an Unity Connection issue?-Connection Issues and What to Provide

    Unity Updater issue?-Updater Issues

    Classic and Unity Port Forwarding?-Fantasy Grounds Connections Explained

    Comcast or Cox ISP User?-Comcast XFinity and Cox Users

    Have a suggestion?-Feature Request

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
  •  
DICE PACKS BUNDLE

Log in

Log in