Caching script files for later use

Hey guys quick question…

private var playerInfo : ThirdPersonStatus;

This is basically stating that variable “playerInfo” is like loading the ThirdPersonStatus script into memory so I can access it’s functions and variables like:

playerInfo.Health -= 50;

Now assuming “health” is what you defined the variable as in the ThirdPersonStatus script would you still capitalize the first letter when accesing it like i did above, or it would it remain lowercase? [/code]

This is purely a matter of coding style.

Personally, I use this style:

Class names: CamelCase
Private class fields: m_CamelCase
All other class members (including fields, properties, and methods); these are essentially part of your API: CamelCase
Method parameters: lowerCamelCase
local/temporary variables in methods: lowerCamelCase
Constants: UPPER_CASE

This is my style, it’s not really a standard style I think, but a slight mishmash of others (CamelCase, PascalCase, Hungarian).

Some more reading, styles: Naming convention (programming) - Wikipedia

It’s mostly just important that you’re consistent across all your code, and that it’s readable and makes sense for you (and possibly others). For me, the style tells me instantly what the names are for: API vs private/inaccessable fields vs local/temporary variables vs constants.

so Health in my example would be a method parameter, correct, just to clear up another question i had floating around my brain…

Health in this case would be a field. Method parameters are what you define as input values for a method.

class MyClassName
{	
	const MY_CLASS_CONSTANT : int = 10; //constant

	private var MyClassField : int; //field

	public function MyClassMethod(methodParameter1, methodParameter2) //method parameters
	{
		var someLocalVariable : String; //local variable
	}
}