-
January 24th, 2024, 12:34 #1
- Join Date
- Apr 2010
- Location
- Australia
- Posts
- 898
How to activate multiple CT Sections when an actor becomes Active
I'm trying to activate/visible multiple CT_Sections when the combat tracker switches to the active CT Actor.
I know you can declare a button in your ct_host_entry.xml as <button_ct_section_active> and pair it with a <sub_ct_section> and this will work. My problem is I want to activate 2 sections on the Actors turn.
I've tried creating a DB.addHandler to my ct_entry.lua trigger:
Code:-- ct_entry.lua function onInit() super.onInit(); -- unrelated stuff deleted DB.addHandler(DB.getPath(getDatabaseNode(), "active"), "onUpdate", self.onUpdateActive); end function onUpdateActive(nodeField) local bState = (nodeField.getValue() == 1); sub_stats.setVisible(bState); sub_combat.setVisible(bState); end
Likewise with overriding onActiveChanged in my ct_entry.lua and trying each of the commented methods:
Code:-- ct_entry.lua function onActiveChanged() Debug.chat("ct_entry.lua -- onActiveChanged"); local bState = (DB.getValue(getDatabaseNode(), "active", 0) == 1); Debug.chat(bState); -- self.onSectionChanged("stats"); -- self.onSectionChanged("combat"); -- super.onSectionChanged("stats"); -- super.onSectionChanged("combat"); -- sub_stats.setVisible(bState); -- sub_combat.setVisible(bState); end
Last edited by ronnke; January 24th, 2024 at 12:37.
Timezone: Australian EST (GMT +10).
Systems/Rulesets: GURPS 4th Edition.
Campaigns (Ultimate License Holder)
GURPS Traveller - The Empty Peace
GURPS Shadowrun - Power Plays
GURPS Banestorm - Dark Clouds Rising
-
January 24th, 2024, 19:35 #2
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,607
You'll need to update ct_entry.lua to override a couple functions:
Code:function onActiveChanged() self.onSectionChanged("stats"); self.onSectionChanged("combat"); end function getSectionToggle(sKey) local bResult = false; local sButtonName = "button_section_" .. sKey; local cButton = self[sButtonName]; if cButton then bResult = (cButton.getValue() == 1); if ((sKey == "stats") or (sKey == "combat")) and self.isActive() and not self.isPC() then bResult = true; end end return bResult; end
JPG
-
January 24th, 2024, 20:57 #3
- Join Date
- Apr 2010
- Location
- Australia
- Posts
- 898
Thanks! That did it.
Timezone: Australian EST (GMT +10).
Systems/Rulesets: GURPS 4th Edition.
Campaigns (Ultimate License Holder)
GURPS Traveller - The Empty Peace
GURPS Shadowrun - Power Plays
GURPS Banestorm - Dark Clouds Rising
-
January 24th, 2024, 21:08 #4
- Join Date
- Apr 2010
- Location
- Australia
- Posts
- 898
For future proofing would there be a need to implement some consideration for the parent functions? ie super.onActiveChanged()
Timezone: Australian EST (GMT +10).
Systems/Rulesets: GURPS 4th Edition.
Campaigns (Ultimate License Holder)
GURPS Traveller - The Empty Peace
GURPS Shadowrun - Power Plays
GURPS Banestorm - Dark Clouds Rising
-
January 24th, 2024, 22:51 #5
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,607
Not in this case; because you want to override the default behavior completely.
JPG
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks