Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Settings that affect other Settings

I'm using Twine 2.1 with SugarCube 2.12.0.

I'm looking to see if there's a way to use the Settings UI to make a Setting that affect other Settings, so for instance:
Setting.addToggle("showdesc", {
  label: Show Description,
  default: true
}

Setting.addList("describe", {
  label: Describe,
  list: ["None", "Nature", "People", "All"],
  default: "All"
}

Now, I want it so that if showdesc is set to false, describe is disabled and/or automatically set to None as well. In this example, it would be pointless to set what to describe if the descriptions aren't going to be shown.

I'm thinking, a callback to .removeList("describe") in onInit/onChange for showdesc, but I'm pretty sure removeList() is just my imagination and it's not available in the Settings UI.

Is there a way to simulate that?

Comments

  • First. Your definition objects are incorrect. In the following two lines, you're attempting to assign string values to the label properties, however, you forgot the quotes:
    → ERRONEOUS
      label: Show Description,
    
      label: Describe,
    
    → CORRECT
      label: "Show Description",
    
      label: "Describe",
    


    And now a question. Why have the showdesc toggle setting at all if you can set the describe setting to "None"? It just seems redundant.
  • For the first one, yeah, I figured that one out quickly enough, although after I had posted the question.

    For the question, I'd like to make it automatic. So, if the showDesc is set to False, I'd like describe to automatically change to None. However, if showDesc is not None, I'd like the user to be able to set the describe level to their preferences.

    I can probably just check for settings.showDesc && settings.describe === "Nature" (or similar) every time, that's Plan B, I suppose.
  • edited February 2017
    I'm still not seeing the point of having a setting, which the player has to toggle off, set another setting to a specific value, which the player could simply set appropriately in the first place. Either you're leaving something out of the description which would make this reasonable or that's horribly redundant—and unfriendly.

    To be clear, I can tell you what you want to know. The Setting API does not allow controls to be disabled/removed once they've been added, so that's a wash. As far as having one setting modify another, that is completely doable. It would be fairly easy to have the showDesc setting—or showdesc, either way case matters—set describe to "None" if it is toggled off by the player.

    I'm not trying to be difficult, I'm simply trying to understand why you want to do what seems like a less than stellar idea on first blush. I like to keep footgun moments to a minimum if I can.
  • Well, I want it to be impossible for the Player to set the describe level to other than "None" if showDesc is false.

    I realize I'm being a bit obscure here, it's a bit deliberate considering what I'm trying to control with these settings, so I'm describing it rather generic.

    How about this for a better case:
    Setting.addToggle("useSounds", {
      label: "Sound",
      default: true
    }
    
    Setting.addList("volBG", {
      label: "BG Volume",
      list: ["0", "1", "2", "3"],
      default: "2"
    }
    

    I want it so that if useSounds is false, volBG is set to 0 (and preferable can't be changed). Otherwise, the Player is free to set volBG to any of the levels.
  • Well, I want it to be impossible for the Player to set the describe level to other than "None" if showDesc is false.
    At present, there is no way to lock a setting. And now that you've got me thinking about that, changing describe based on changes to showDesc isn't going to work because of that—it's possible to do, however, since you cannot lock it there's nothing preventing the player from changing it again, so you'd always have to check both settings anyway.

    So, I suppose your best option here would either be to check both.

    You already know how to do this, but I'm enumerating it here for completeness:
    → JavaScript
    settings.showDesc && settings.describe === "Nature"
    
    → TwineScript
    settings.showDesc and settings.describe is "Nature"
    
  • Gotcha.

    Check for everything everytime, it is. If that's the case, then I need to ask one other question, which I shall do in another post.
Sign In or Register to comment.