playMaker

Author Topic: Adding Conditional Buttons?  (Read 2350 times)

traitorjoe

  • Playmaker Newbie
  • *
  • Posts: 10
Adding Conditional Buttons?
« on: June 29, 2014, 12:00:51 AM »
I've been searching for this and can't find a solution so I thought I'd post -

I've got a list of four GUI buttons I want on screen, but all four of them should appear or not appear based on a conditional integer value.

So if I try to add them all to one state, which seems like the correct thing to do, I'm not sure how to work the conditions in there (I'm using Int Compare).

I've been trying crazier things like a big tree where I add GUI buttons across multiple states. That works well as far as setting the conditions, but that doesn't seem to work right because GUI button 1 will disappear by the time I get to the state with GUI button 2.

So going back to the single state idea, is there a way to interject conditions in to GUI button creation process?

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: Adding Conditional Buttons?
« Reply #1 on: June 29, 2014, 07:30:29 AM »
I don't know much about GUI Buttons, but I use GUI Texture for my buttons - it works fine, and I've got an FSM on each one to check for conditions and enables/disables the button when needed.

Do you need to use GUI Buttons?

traitorjoe

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Adding Conditional Buttons?
« Reply #2 on: June 29, 2014, 11:48:06 AM »
GUI Texture would probably work for me fine. Are you setting all the conditions for the various buttons in the same state? I'd love to see an example or hear about how you're able to do that if so. Thanks for the response!

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Adding Conditional Buttons?
« Reply #3 on: June 29, 2014, 12:28:14 PM »
Each button would generally have its own FSM since each button has its own states (Idle, Pressed, Disabled, Hidden...) Trying to collapse all that information for multiple buttons into one FSM gets messy fast!

Quote
So if I try to add them all to one state, which seems like the correct thing to do, I'm not sure how to work the conditions in there (I'm using Int Compare).

The FSM can run multiple states in a single Update so there's no reason to draw all your buttons in one state. Think of the FSM as a flowchart describing which buttons to draw...

traitorjoe

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Adding Conditional Buttons?
« Reply #4 on: June 29, 2014, 04:45:17 PM »
OK cool. That's how I had tried it with attempt #2 but I was running in to an issue where if I had a GUI Button in FSM 1, it would disappear when I transitioned to FSM 2. So if I had four FSMs for the four buttons, I could only ever see one at a time. Is there a way around that problem?

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3987
  • Official Playmaker Support
    • LinkedIn
Re: Adding Conditional Buttons?
« Reply #5 on: June 29, 2014, 04:52:56 PM »
What do you mean by "when I transitioned to FSM 2"?
All the FSMs should be active...

traitorjoe

  • Playmaker Newbie
  • *
  • Posts: 10
Re: Adding Conditional Buttons?
« Reply #6 on: June 29, 2014, 06:25:17 PM »
Oh I was sloppy with my verbiage - what I meant was "when I transition to STATE 2". What I was trying was various states across the same FSM. Sounds like you're suggesting to literally make a separate FSM per button? I actually hadn't thought about that - I can give it a whirl.

Thanks for your patience with my noobiness. Any additional info along these lines you can offer is much appreciated!