Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting all the radiobuttons with the proper data-dtype #183

Open
quadur opened this issue Aug 26, 2022 · 2 comments
Open

Setting all the radiobuttons with the proper data-dtype #183

quadur opened this issue Aug 26, 2022 · 2 comments

Comments

@quadur
Copy link

quadur commented Aug 26, 2022

I'm hacking through with making a Brinkwood system based on this one and found that using radio buttons for numerical values saves them as strings of those numerals ("1" instead of 1) into the Actors data.
This makes all kinds of things problematic, i.e., it is impossible to use Active Effects for adding (not overriding) skill dots when choosing classes.

After some searching and a few questions on Discord I was pointed to a simple solution setting data-dtype="Number" on a radio button forces Foundry to interpret them as true numerals.

So, a simple fix for attributes would be to change this:
templates/parts/attributes.html:37

      <input type="radio" id="attributes-{{../../../actor._id}}-{{skill_name}}-{{this}}"
               name="data.attributes.{{attribute_name}}.skills.{{skill_name}}.value" value="{{this}}">

to this:

      <input type="radio" id="attributes-{{../../../actor._id}}-{{skill_name}}-{{this}}" 
               name="data.attributes.{{attribute_name}}.skills.{{skill_name}}.value" data-dtype="Number" value="{{this}}">

Edit after tests:

This requires and edit in the getAttributeDiceToThrow() in module/blades-actor.js:47 to simply load the value
from the workaround:

dice_amount[skill_name] = parseInt(this.data.data.attributes[attribute_name].skills[skill_name]['value'][0])

to this:

dice_amount[skill_name] = this.data.data.attributes[attribute_name].skills[skill_name]['value'];

since the value is a number already

@quadur quadur changed the title Setting all the radiobuttnos with the proper data-dtype Setting all the radiobuttons with the proper data-dtype Aug 26, 2022
@megastruktur
Copy link
Owner

Hello @quadur , thanks for pointing that out :) The system was written 2 years ago and I didn't have a clue about JS and Foundry itself as there was a lack of documentation :D
I wish I could just change that one to use the proper format, however I'm a bit concerned that it would affect the saved data for people, who already have the system installed. I'll need some time to take a look at this.

@quadur
Copy link
Author

quadur commented Aug 29, 2022

I wish I could just change that one to use the proper format, however I'm a bit concerned that it would affect the saved data for people, who already have the system installed. I'll need some time to take a look at this.

I've tested it, unfortunately, you're right I would require a migration update looping through existing actors and parseInt-ing all values (skills, exp, coins ...). If I'm done with the base Brinkwood update before you'll have a moment to address this I'll whip up a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants