This WIP document was made to cover the expected code-style for this repository. Please follow this style as closely as possible to make pull requests as simple as possible. Note that the examples below are mostly non-sensical and written for the sake of being examples.
✔️ Do:
bool a = true;
if (a == true) {
//
} else if (a == false) {
//
}
❌ Don't:
bool a = true;
if (a) {
//
} else if (!a) {
//
}
✔️ Do:
class MyClass {
public int a = 10;
public int b = 10;
public int Add() {
return this.a + this.b;
}
}
❌ Don't:
class MyClass {
public int a = 10;
public int b = 10;
public int Add() {
return a + b;
}
}
When using local variables, prefix their names using an underscore. This does not need to be followed for variables used as iterators in loops.
✔️ Do:
string _myCharacterName = "John";
Console.WriteLine("My name is " + _myCharacterName);
❌ Don't:
string myCharacterName = "John";
Console.WriteLine("My name is " + myCharacterName);
Avoid using var
for types whenever possible. This does not need to be followed for one-off variables.
✔️ Do:
LInstance _instGlobal = _game.Instances[(double)LVariableScope.Global];
double _instX = _instGlobal.Variables["x"];
Console.WriteLine("Instance X position is: {0}", _instX);
❌ Don't:
var _instGlobal = _game.Instances[(double)LVariableScope.Global];
var _instX = _instGlobal.Variables["x"];
Console.WriteLine("Instance X position is: {0}", _instX);
✔️ Do:
int a = 0;
if (a > 0) {
//
} else if (a 0) {
} else {
}
for(int i = 0; i < 100; i++) {
//
}
❌ Don't:
int a = 0;
if (a > 0)
{
//
}
else if (a < 0)
{
//
}
else
{
//
}
for(int i = 0; i < 100; i++)
{
//
}