Getting Construct2 instance variables to change.

0 favourites
  • 9 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • Hi,

    I am using the Browser plugin to send and get data from an Adobe Captivate slide. The code I am using to set the data from the Captivate FO1 variable is correct as I have used it before. The get should be working also its the C2 instance variable object property I am unsure about. I'd appreciate some help with this.

    Here is the example code. The set is working but the get isn't showing up.

    "window.parent.cpAPIInterface.setVariableValue('FO1',1);";;;;;;;;;;;;;This works fine

    "this.runtime.textmmm.V1 = window.parent.cpAPIInterface.getVariableValue('FO2');";;;;;;;;;;;;;This isn't working at all.

  • This isn't the right forum to ask general Javascript language questions. If it's not specifically to do with the C2 Javascript SDK, then you probably want to ask on a site like StackOverflow.

  • Ashley hi,

    I am asking a C2 question here. Something I can't find on StackOverflow. I need to know how I communicate directly with a C2 Instanced variable using the Browser plugin. The textmmm.V1 is the variable I want to pass data to. Any help would be appreciated.

    Regards

    Luke

  • lukeo25

    You might trace the data type of private variables, they saves in an array object, so it could not wrote directly.

    A simple solution is - add an expression to export wrote value, then use action to write into instance's private variable.

  • So is that the same as the function that holds the array of variables. If so, doesn't that change on every runtime. Is it a requirement to do a "for loop" to find an var[] position of an instance variable.

  • lukeo25

    In editor, instance variables are indexed by a string name.

    In rumtime, instance variables are stored in an array (not a dictionary), the name-index info had been removed, even "for loop" could not get the variable back by name.

    ----

    There is another solution to have the name-index info.

  • So it's just given a random number and so on....bugger, I was hoping it was a bit more relatable to the editor name.

  • lukeo25

    Not a random number, it maps the names in sequence numbers (array indexes).

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So is the position determined by a rule set at edit ie; the first object etc?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)