- Home /
Why are my variables not showing up?
I am writing a chemical combination game, where the player combines chemicals that they use to complete levels. I just wrote the main inventory script for the player, but when I save and exit monodev, the inspector (attached to the player) does not register my script's variables! I can see the script, but not the variables. This is the first time I have ever had this problem.
This is my script-
var oxygennumber = 10;
var hydrogennumber = 10;
var water = 10;
var HP = 10; //HP stands for Hydrogen Peroxide
if(Input.GetKeyDown(KeyCode.Z)){
if(oxygennumber > 1){
if(hydrogennumber > 2){
oxygennumber - 1 == oxygennumber;
hydrogennumber - 2 == hydrogennumber;
water + 1 == water;
}
}
}
if(Input.GetKeyDown(KeyCode.X)){
if(oxygennumber > 2){
if(hydrogennumber > 2){
oxygennumber - 2 == oxygennumber;
hydrogennumber - 2 == hydrogennumber;
HP + 1 == HP;
}
}
}
if(Input.GetKeyDown(KeyCode.I)){
oxygennumber + 1 == oxygennumber;
}
if(Input.GetKeyDown(KeyCode.O)){
hydrogennumber + 1 == hydrogennumber;
}
Am I not stating the variables properly?
-Thanks in advance -Please respond quickly, I need this done by Sunday (3/17/13)
Answer by Ziibii · Mar 12, 2013 at 03:36 AM
public var asd : int = 12 should work. Also when you assigning variables like :
oxygennumber - 1 == oxygennumber
it should be oxygennumber = oxygennumber - 1;
or oxygennumber -= 1;
when assigning variables around use one "=", when you compared something use "==".
Answer by Tarlius · Mar 12, 2013 at 06:19 AM
Is this the entire content of the script? If so, does it even compile?
If not, is this your Update function? if so, you need to move the variables outside of it to change their scope.
Also, if this is C#, you need to make them public (and you should probably declare them as int and not as var)
Edit: After noticing the answer posted by @Ziibii and a closer inspection of the code, I'm leaning towards the "didn't compile" idea. c - 1 == 0;
is definitely not valid C#, and I doubt JS will allow it either. I won't bother posting correct syntax as he already did that for you.
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
How do I delete an object on collision with another object? 1 Answer
Change variable value of a script from another script. both in different Game object 1 Answer
Countdown code not working 1 Answer