Forum rules - please read before posting.

Button variables

edited August 2016 in Technical Q&A
I think I need help! This is the first time that I meet with the variables. I don't understand in which way setting them? I have an example with three buttons: 1,2,3. If I press 2 and 3 something is triggered. The question is how to set the variables? Where to start? I admit I have no idea :-<

Comments

  • Set each button to run an actionlist asset when pressed. then in each actionlist asset, use the Variable:Set action. You will have to select which type of variable you are setting (local or global), then just provide the new value for the variable. If you want to check if a variable holds some specific value just use a Varible:Check action, with it you can check if the value is equal to the one you need or not (Var equals to 1 or not?). Checks will usually give two connectors(paths) one in case the result is false, and one in case it's true, that way you can do stuff if the result is either true or false.
  • Also, if your variable can hold more than two values, but still a finite number (1,2,3 for example), you could also use a PopUp variable type.

    This lets you define exactly which values it can have, and has the added bonus of working with the Variable: Pop Up switch Action, which lets you define as many outputs as there are values.
  • Hm, I think I understand. Means for each button a specific list of actions. For example: I want to press button 2 and 3 to give me some action: the object disappears! How the variables will know that I pressed both buttons? Not necessarily at the same time and order? If I understand correctly, in the end I would actually have to have a variable that checks all three buttons?
  • edited August 2016
    As stated above, bool variables (as switches) or popup variables would do the job. Just have each button notify when it's been pressed, which is to say, have it change the value of the variable when it's hit. For simplicity lets go with the bool switches example. 

    Let say you have two bool variables, one for each of the first two buttons (SwitchASwitchB). Both of them start as false. When a button is hit, the actionlist asset in the button should run a Variable:set action which then changes the state of one of those variables to true. Then let's say in button C you want to perform an action only if button A and B have been pressed. All you need to do is have the actionlist asset in button C run two Variable:Check actions, if SwitchA is true, continue to the next step, then If SwitchB is also true you go ahead and do the rest of the action.

    PS: ummm, this is asked a lot, I'll probably be making a wikia article about it in the near future.
  • edited August 2016
    Thank's Alverik! I think now I understand. I admit that these variables were always been my weakness and I have always avoided them but now I have to face them:>   I realize now how much the "variables" are valuable precisely for these tasks.

    PS: Oh and yes, I truly support the idea for wikipedia. It would be really good to have something like this  all in one place. It would mean a lot in this situation! Maybe,with some free examples..
Sign In or Register to comment.

Howdy, Stranger!

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

Welcome to the official forum for Adventure Creator.