-
September 24th, 2021, 01:55 #1
- Join Date
- Jun 2017
- Posts
- 61
Changing charsheet frame from charsheet_main
So I am trying to change the background frame of the main character sheet based on if they are playing a hero or a villain. I've been having trouble finding out how to get to the parent window object (not the DB object) but all attempts have failed. Anyone got a link to an example of how to affect a parent window settings like frame, font, etc.? Below is the code I currently have which does change the frame of the character_main sheet. The button is on character_main section. When I moved the button to charsheet, it works the way I want, but the buttons end up on all the other tabs so not ideal. I was looking through the API references, but wasn't able to find out how to get to where I'm trying to make the change programatically.
Code:function onButtonPress() local nVal = window.hero_chk.getValue(); if nVal == 0 then window.villain_chk.setValue(1); window.setFrame("char_sheet_background_villain"); elseif nVal == 1 then window.villain_chk.setValue(0); window.setFrame("char_sheet_background"); end end
-
September 24th, 2021, 02:22 #2
Instead of a button, you could put the script as an onInit function, see 3.5E record_char_main.xml for an idea on how to possibly write it.
-
September 24th, 2021, 04:19 #3
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,424
Random thoughts in no particular order:
* The item behaviors in 5E or 3.5E for the "item_main" window class and script might be a closer example.
* I wouldn't suggest putting multiple fields/controls for essentially the same check (i.e. hero_chk/villian_chk). You can always just pull one and calculate the other. Or go towards the NPC type option in 3.5E which allows switching between Creature/Vehicle/Trap.
* The "charsheet" window class is specifically for player-controlled characters, not as a repository for NPCs/villains. It's just going to complicate things to try to merge them. Just make the NPC sheet more complex for villians; and allow a Villian checkbox for the more complex characters (like wildcards in Savage Worlds) It will keep the combat tracker code simpler in the long run.
Regards,
JPG
-
September 24th, 2021, 05:05 #4
- Join Date
- Jun 2017
- Posts
- 61
Thanks for the feedback. The way I'm reading the ruleset it looks like the villains could be player controlled as they have a similar character sheet with npcs being a more traditional type of npc (at least in the pdf). Ill check out those examples.
-
September 24th, 2021, 17:39 #5
- Join Date
- Jun 2017
- Posts
- 61
Found what I needed. window.parentcontrol.window.setFrame() got me to the top level charsheet (putting this here for posterity).
Just for a little more background on how I'm interpreting the ruleset docs and why this function would exist. In theory, the DM and players have a good bit of latitude to make things up as you go. Having this piece allows a players character to turn from hero to villain and back based on a custom storyline (think Loki in the Marvel universe).
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks