Forum rules - please read before posting.

GlobalVariables.GetXValue Discussion

edited May 2015 in Engine development
I was working with AC earlier today and I came across a scenario where I wanted to grab a variable that I had stored in my Global Variables. So naturally I used the Global Variables class and the function GetStringValue to get the value of a string variable I had. However it asks me to supply the ID of the variable. 

While I'm not sure if this is part of some underlying system but would it not make more sense to pass in either the ID or the actual NAME of the variable? Is it possible that the ID's could ever change? I also feel from a coding stand point and readability it makes more sense to pass in the name of the variable you want to access the value of as opposed to an ID (which may seem like an arbitrary number).

Edit:
string sequence = AC.GlobalVariables.GetStringValue(18);

or 

string sequence = AC.GlobalVariables.GetStringValue(PostDialogueSequence);

Comments

  • ID numbers will never change - that's the point.  They have no bearing
    on the order in the Variables Manager they appear, just the order in
    which they're made.  The label of a Variable can be easily modified, and
    also can be shared across multiple variables, which is why this isn't
    relied on.

    It'd be simple to write a custom function that
    searches all variables for a particular label - just crack up the
    current GetStringValue and modify a duplicate - it could live in a
    custom static script of your own, wouldn't need to replace any of AC's
    scripts.
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.