It would help to know in what language you script.
I know for C# you can secure almost everything simply by stating its availability in its decleration:
public ClassName : MonoBehaviour {
public string String = "Which will appear in the editor";
private string AnotherString = "Which will not appear in the editor, or be accessible by other scripts.";
internal string YetAnotherString = "Which is available only in the program the script/code is added to, though I'm not sure if it'll show in the editor.";
public string MethodName() {
return "This method is available by basically anything.";
}
private string PrivateMethodName() {
return "This method is available only by this class/script.";
}
internal string InternalMethodName() {
return "Again, not sure about the internal accessor, might wanna play around with it if C# is your forte.";
}
}
Basically ‘private’ makes anything in the same class or method available by anything in that same class or method, or lower levels. So if you have an object in your class that object can also access it, but an object that contains an instance of this object cannot.
Another method is grouping scripts together in 1 script. Say for instance you have a script that controls a character, just add the script that controls that characters eyes to the script that controls the rest of the character.
The beauty of classes and methods is you don’t HAVE to use all of their functions, so even those small snippets you mentioned can be easily tucked away, possibly even in a subclass with the rest of the snippets.
A LOT of comments in your code can also help a lot. I often use complete lines of commented ‘-’ just to seperate sections of code, but this works best after you have grouped codes together. It is also good policy since you will probably not remember what a few of lines code do that you have written 2 months ago and had to get back to for tweaking or expanding or whatnot. With comments at least you know what the code does where and its easier to find back and edit the right line.
But again, you really need to concider what scripting language you use. I’m not fond of scripting, so you’ll find me programming C# most of the time, most importantly because it isn’t a scripting, but a programming language, and I have little to no experience with the other ones available (lil Java, but thats bout it).
The MonoDevelop application, like most programming interface, features beautifull little blocks with a ‘-’ sign just right of the line number. They collapse and expand pieces of code. Use them often. You don’t need to see the code of a characters leg if your working on the eyes.