Forum rules - please read before posting.

Using variable tokens in action lists

Hi folks,

Does anyone know if there's a way to use variable tokens "[var:ID]" in action lists? I've tested with the Print in Console function of the comment action and it just prints the token as if it were text, instead of reading the variable name.

In my particular case, I'd like to be able to show/hide menu elements based on variables (using Menu -> Change State). I'm developing a way to cycle through elements in a cut-scene (letting the user press any key to continue), and I need to be able to show/hide specific elements according to a variable.

Cheers!

Comments

  • edited November 2015
    The conversion of tokens in console text is a good suggestion, thanks.

    Have you looked into parameters?  They're a good way of recycling ActionLists in cases like this.

    Once your familiar with how they work, create a String parameter, and insert it into your Element textbox in the Menu: Change state Action.  Then, run this ActionList using the "ActionList: Run" Action, and you can set the String parameter within it.  Simply insert the variable's token into the box, and it'll be used in your Menu Action!
  • Thanks @ChrisIceBox,

    Okay, using parameters instead of directly inserting the token makes sense. I tried that, though, and had no luck.

    Here are my actions as per your suggestion:

    The action that calls the other action list:
    image

    And here's the other action list:
    image

    It produces this error:
    "Could not find element of name '[var:55]' on menu 'Demo intro'". This is the same error that I get if I try to use the token straight in the Hide Menu Element action. I've tried this with both integer and string variables and it always produces the same error; it's like it's not even trying to look at the value of the variable at all.

    I also tried setting the parameter in the other action list to a global variable, but unfortunately the "Hide Menu Element" action isn't interested in that at all: there isn't even an option to input that parameter.
  • OK.  It's not using tokens when I thought it would do, but I will add this to v1.50.
  • Awesome, thanks!
  • Actually, this is a very simple tweak.  Open up ActionParameter.cs and change line 157:

    stringValue = _value;

    to read:

    stringValue = AdvGame.ConvertTokens (_value);
  • It works like a charm! Thanks Chris :)
  • Hi, it seems the tweak @ChrisIceBox mentioned is not in the latest version AC 1.53d. I'd prefer not to hack AC (making updates harder), so could the tweak be added to the official version?

    In my case I actually would have liked it to work with floats and ints also, making it possible to set (any) variables in ActionLists, and then defining the newly added params for the other ActionList to run.

    Currently it seems my best bet is to copy a specific action, rename it and more or less hardcode it to fetch some specific vars.

    PS: It would be also very nice to have Action Object -> SendMessage -> Custom to allow other types of params than just integers. 

    PPS: In other news, I'm still totally in love with AC. Even making an physics/arcade game with it :)
  • The change was included - but due to other changes in that script the line I was referencing has since changed to.  You can see the ConvertTokens call on line 184.

    As the input boxes for parameter values are for numbers only, the values for int and float parameters can't contain token strings unfortunately.  It could also be dangerous to introduce this, as a misplaced ID number could break it.

    What are you trying to do exactly?  It may be that there's an alternative method.  One possible way would be to have a "switch" integer parameter, which is checked in the ActionList with ActionList: Check parameter and reacts accordingly.
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.