How can I replace "this.instance_vars" method?

0 favourites
  • 3 posts
  • I'm porting Globals 2.0 plugin to the C3Runtime, and I faced the next problem.

    In Construct 2 SDK was "this.instance_vars" method. Using this method, you can get an array of values ​​of the object's instance variables. Using JSON.stringify(this.instance_vars) it looks like this:

    But Construct 3 SDK doesn't have this method. You can only get the count of instance variables and their values by index. The Globals plugin uses this method to store the values ​​of instance variables as a JSON string (as in the image above).

    How to solve this problem?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can only get the count of instance variables and their values by index.

    You can use that to make an array.

  • I tried to implement this with an array and the values ​​in the array were set. But only at the start of the layout.

    How to check if the values ​​of instance variables have changed, and if they changed, set the values ​​in the array to the values of instance variables.

    Here is my code in c3runtime/instance.js:

    	this.instance_vars = [];
    	this.defaultVarsValues = "";
    			
    	for (let i = 0; i < this.GetInstance().GetInstanceVariableCount(); i++)
    	{
    		this.instance_vars[i] = this.GetInstance().GetInstanceVariableValue(i);
    		this.defaultVarsValues = JSON.stringify(this.instance_vars);
    	}
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)