Announcement

Collapse
No announcement yet.

Construction Script Bool Variables, possible to make them exclusive checked?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Construction Script Bool Variables, possible to make them exclusive checked?

    I'm very new to Blueprints and especially construction script stuff so I hope this makes sense.

    I have multiple bools that are editable in a construction script of a blueprint. Is there a way to say if one is checked, the others can not be checked? I've tried some stupidly elaborate While Loop and Branch setups, but I'm confusing myself with the failed logic and I'm sure there's an actual smart way to deal with it.

    The general setup for what I have is a simple platform BP that I can place and it can be set to different colors, how or if it moves and what type (if any) pickup it has on it. I have logic set up in the BP to randomize all of those things or me to set it specifically when placing it in the level. I want to ensure that in the editor, if the Randomize bool is set to True the other options are unchecked automatically so as not to override. Technically, I made that happen rather easy by branching and setting all other bools to False. However, I can't then check other things until I un-check Randomize.

    Essentially I want to know if it's possible to make an editable bool exclusive checked.

    Does that make any sense?

    Thanks,

    Gooner44
    Gooner44
    Cribbage Sample Project on MP

    #2
    If you prefer checking boxes to selecting from an Enum dropdown, yes it's possible:
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	310.7 KB
ID:	1052389

    This works like a bitfield. Each Bool is a bit (1, 2, 4, 8, 16, etc). When an option is checked, a new bitfield is generated by multiplying by the bit value per Bool and adding all the values. Subtract the new bitfield from the old bitfield (and ABS it) to figure out which option was turned on. Since one option must be enabled, if someone attempts to turn off the current option, ignore the turn-off and turn it on again. (the !=zero part). When a new option is detected, briefly turn off all options via Sequence. Then run a Switch On String using the bitfield value as the switch. Used a String Switch because - while we can define custom string switches - for some reason, we can't define our own integer switches.

    The key to making this work is that the bitfield integer variable must be set to editable. Otherwise, it'll return to the default value each time the script runs. I set the first Bool and the bitfield Int to default=1 while everything else is zero.

    Enums use a dropdown instead of checkboxes. Choose an option from the dropdown, then do Switch On Enum with the editable enum variable:
    Click image for larger version

Name:	Capture2.PNG
Views:	1
Size:	79.2 KB
ID:	1052395
    Last edited by DoteDote; 07-05-2014, 07:01 PM.

    Comment


      #3
      Ok, wow. I don't know if I actually understand what you are saying, but the pictures helped. I think I get the basic idea of what's happening, now just need to figure out how to tie it into my own situation. Thanks for the reply, I'll post what I went with if I get something working.
      Gooner44
      Cribbage Sample Project on MP

      Comment

      Working...
      X