- Home /
Why can't I use == in mono develop?
im just starting to learn javascript and i cant use == i don't know if im doing something wrong or the program just doesn't allow it anymore. Anyways heres my script any help would be greatly appreciated.
pragma strict
function Start () {
} var gameReset = true;
function Update () {
if(gameReset == true);
{ gameObject.renderer.material.color =Color.white; } if(Input.GetKeyDown(KeyCode.R)) { gameObject.renderer.material.color =Color.red; } if(Input.GetKeyDown(KeyCode.B)) { gameObject.renderer.material.color =Color.blue; } if(Input.GetKeyDown(KeyCode.C)) { gameObject.renderer.material.color =Color.cyan; } if(Input.GetKeyDown(KeyCode.G)) { gameObject.renderer.material.color =Color.green; } if(Input.GetKeyDown(KeyCode.Y) { gameObject.renderer.material.color =Color.yellow; } var gameErrorCheck = false; var gameErrorPrint = " There are no Game Errors."; var gameErrorMessage = gameErrorCheck + gameErrorPrint; print (gameErrorMessage);
}
You should edit your qustion and use the 101/010 button to format your code.
== works just fine, so it's something else, probably in the line or two above the where the error is reported.
'if (something == true)' is redundant. You can just say 'if (something)'
Answer by DaveA · Jul 14, 2013 at 06:05 PM
The problem is not the == it is the ; at the end of that line. This makes it an empty statement which does nothing, and mono is smart enough to flag that as a problem.
Thanks! I'll give that's a try when I'm home from vacation, do you know any good websites for learning JavaScript for video games because my highschool doesn't offer any coding programs unfortunately.
C twert9, I can't recommend any websites, but the book Unity 3.x game development essentials was wonderful for me, I made most of my systems for my game functional, though not optimized, with no previous experience after reading it.