refer to component by number or type instead of name?

i have a main script called main.js attached to a gameobject named main. I want to set variables in main from another script.

another script code:

var mainscript:main;
mainscript=GameObject.Find(“main”).GetComponent(“main”);
mainscript.somevariable=2;

I Update main.js a lot and change the name to main_1, main_2 to keep track of the versions I’m on. Is there a way to refer to main by the component type or number so I don’t have to keep changing the name everytime?

Thanks,

When you’re making a new main script, write it as a class that extends Main. This way you can keep the functions you want, overwrite the ones you don’t, and still have things look for Main.