-
December 31st, 2021, 23:05 #1
- Join Date
- Mar 2014
- Location
- Staffordshire, UK
- Posts
- 337
5E - Issue adding a 2nd Background to the character sheet.
Using the 5E ruleset I have managed to add a 2nd Background to the character sheet and can type into the text box. This is to allow for a Background as well as an Education Background.
The problem is with the drag/drop of backgrounds - only the first box is ever populated.
I can see the problem with code being:
Code:<windowclass name="charsheet_main"> <script> function onDrop(x, y, draginfo) if draginfo.isType("shortcut") then local sClass, sRecord = draginfo.getShortcutData(); if StringManager.contains({"reference_class", "reference_race", "reference_subrace", "reference_background"}, sClass) then CharManager.addInfoDB(getDatabaseNode(), sClass, sRecord); return true; end end end
What I would like the code to do is if it is a background:
(1) To check to see if the background field has a value - if it doesnt store the background in here as normal.
(2) If the background field has a value in it - move the contents of background field and replace whatever is in background2. Then add the background as per (1).
Not 100% sure on how to get the contents of the background field, check it and then to save the new field. I am sure its only about 3 or 4 lines of code.
Any tips on the commands to accomplish this?Ultimate License
UK Time Zone (GMT/BST)
DM'ing since 1977 (Basic D&D)
Currently Playing:
Empire of the Ghouls 5E Campaign
Tales from the Yawning Portal 5E Campaign
Rise of the Runelords Pathfinder 1e
Amazing Adventures 5E Campaign"Some are born to move the world, to live their fantasies
But most of us just dream about the things we'd like to be."
Rush - Losing It
Currently DM'ing
Princes of the Apocalypse 5E Campaign
Waterdeep: Mad Mage 5E Campaign
The Blight 5E Campaign
-
January 1st, 2022, 02:26 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,548
All of the code for the character manager assumes a single background text and link field; which is what is populated by the scripts on a drop action.
If you are adding a second background field; then you'll need to add a second background link; and intercept the drop on the second background text/link fields to handle yourself, instead of allowing the drop to fall through to the main character sheet handler. (And, when doing this, dropping anywhere but the second field will use the default handling.)
Regards,
JPG
-
January 1st, 2022, 15:42 #3
- Join Date
- Mar 2014
- Location
- Staffordshire, UK
- Posts
- 337
Managed to get it working by adding:
Code:if StringManager.contains({"reference_background"}, sClass) then backeducate.setValue( background.getValue()); backeducatelink.setValue( backgroundlink.getValue()); end
Code:<windowclass name="charsheet_main" merge="join"> <script> function onDrop(x, y, draginfo) if draginfo.isType("shortcut") then local sClass, sRecord = draginfo.getShortcutData(); if StringManager.contains({"reference_background"}, sClass) then backeducate.setValue( background.getValue()); backeducatelink.setValue( backgroundlink.getValue()); end if StringManager.contains({"reference_class", "reference_race", "reference_subrace", "reference_background"}, sClass) then CharManager.addInfoDB(getDatabaseNode(), sClass, sRecord); return true; end end end function onHealthChanged() local sColor = ActorManager5E.getPCSheetWoundColor(getDatabaseNode()); wounds.setColor(sColor); end </script>
Ultimate License
UK Time Zone (GMT/BST)
DM'ing since 1977 (Basic D&D)
Currently Playing:
Empire of the Ghouls 5E Campaign
Tales from the Yawning Portal 5E Campaign
Rise of the Runelords Pathfinder 1e
Amazing Adventures 5E Campaign"Some are born to move the world, to live their fantasies
But most of us just dream about the things we'd like to be."
Rush - Losing It
Currently DM'ing
Princes of the Apocalypse 5E Campaign
Waterdeep: Mad Mage 5E Campaign
The Blight 5E Campaign
-
January 1st, 2022, 23:27 #4
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks