Starfinder Playlist
  1. #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
    I've messed around with all sorts of stuff, without success. I need some guidance here. Help!
    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

  2. #2
    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
    Regards,
    JPG

  3. #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

  4. #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

  5. #5
    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

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