# Accessing variables defined in another .js file in rpgmaker MV

I'm coming from C++, diving into JS and enjoying the journey so far but I've been at an en passe for the past 2 days and I'm exhausted.

I need help figuring out how to access variables across plugins.

I tried following the guidance in this posting (and numerous others stating to follow the same syntax): https://forums.rpgmakerweb.com/index.php?threads/mv-syntax-for-variables-in-script-calls.48422/

I set these values in plugin1.js:

var weaponRight = 0;
var weaponHeight = 0;

var a = weaponRight;
var b = weaponHeight;

$gameVariables.setValue(5, a);$gameVariables.setValue(6, b);


Then try to access them in this script:

var z1 = eval($gameVariables[5]); var z2 = eval($gameVariables[6]);
...
this.x += (z1 || 0);
...


if I just enter an int, say 5--in place of z1--the transform executes. In addition, I emulated the parsing logic in the first JS file to the 't', so I'm certain the error is coming from my ignorance.

var globalDummyVariable = 0;

Yanfly.globalDummyVariable