121
Technical forum / Basic question about variables
« on: March 13, 2007, 06:40:37 PM »
OK. I'm just trying to learn how to use variables. What I'm trying to do is extremely basic, and I'm sure that I will sound like a complete fool, but here goes:
(I have been searching the documentation and forum for hours, but haven't found an answer).
Let's say that I have a switch that opens a door, and that I use a global variable called "dooropen". If I have clicked the switch, and then click the door, the door will open and take us to the next scene, and if I have not clicked switch, we will just hear the sound of the door handle.
Let's say that clicking the switch sets the variable "dooropen" to "1". Am I right in assuming that I just use the following code in the region entity for the switch?
global dooropen = 1;
OK, then there is the question about what code to use for the region entity for the door. I've tried every possible combination of something like this:
global dooropen;
if(dooropen = 1)
on "LeftClick"
{
Game.ChangeScene("scenes\xxx\xxx.scene");
}
else
{
Game.PlayMusicChannel(1, "sounds\xxx.ogg", false);
}
(I'm sure that there are better ways to play the sound than through a music channel, I just haven't gotten that far yet).
That's it. As I said, extremely basic, but once I can grasp this, I think I can master the method of variables.
Thanks in advance!
(I have been searching the documentation and forum for hours, but haven't found an answer).
Let's say that I have a switch that opens a door, and that I use a global variable called "dooropen". If I have clicked the switch, and then click the door, the door will open and take us to the next scene, and if I have not clicked switch, we will just hear the sound of the door handle.
Let's say that clicking the switch sets the variable "dooropen" to "1". Am I right in assuming that I just use the following code in the region entity for the switch?
global dooropen = 1;
OK, then there is the question about what code to use for the region entity for the door. I've tried every possible combination of something like this:
global dooropen;
if(dooropen = 1)
on "LeftClick"
{
Game.ChangeScene("scenes\xxx\xxx.scene");
}
else
{
Game.PlayMusicChannel(1, "sounds\xxx.ogg", false);
}
(I'm sure that there are better ways to play the sound than through a music channel, I just haven't gotten that far yet).
That's it. As I said, extremely basic, but once I can grasp this, I think I can master the method of variables.
Thanks in advance!