[SOLVED] Variables from other scripts?

How would I get a variable’s value from another script and transfer its value to a new script?

Hi @Fus_ion,

You can do this by:

  1. Getting a reference to the entity this script instance is attached to
  2. Referencing the script component and the script instance like this:
var value = this.app.root.findByName('myEntity').script.myScriptName.myPropertyName;

This way you can get the value from one script property, and in the same manner set it to another.

@Leonidas how about changing it?

Same way, as any regular JS property:

this.app.root.findByName('myEntity').script.myScriptName.myPropertyName = 'aNewName';

you could also use global variables but that’s not recommended