Reply to Re: Talking
If you don't have an account, just leave the password field blank.
Brackets separate a piece of code that you only want to run under certain circumstances.
Examples:
void main( void )
{
if (&story == 1)
{
//stuff inside these brackets is run if &story is 1
say("look, a tree", 1);
}
if (&love == 1)
{
//stuff inside these brackets is run if &love is 1
say("I am in love", ¤t_sprite);
}
}
This will make the sprite say "I am in love" if &love is 1 and make dink say "look, a tree" if &story is 1. These events are independent, each happens regardless of whether the other happens. Why are the brackets neccesary? Because there would be another way to parse these statements if there were no brackets. Observe:
void main( void )
{
if (&story == 1)
{
say("look, a tree", 1);
if (&love == 1)
{
say("I am in love", ¤t_sprite);
}
}
}
Now, dink will say "look, a tree" if &story is 1, and the sprite will say "I am in love" if &love is 1 AND &story is 1, because the second if statement will not be reached unless &story is 1.
If this is confusing, here are some rules.
1.For every open bracket, there is a closed bracket.
2.Procedures, like void main( void ) or main talk( void ) require brackets (don't ask me why ). For example, this is good:
void main( void )
{
say("this is where the stuff goes", 1);
}
But this is bad:
void main( void )
say("This doesn't go here!", 1);
{
}
And this is bad
void main( void )
{
void talk( void )
{
}
}
But this is good:
void main( void )
{
}
void talk( void )
{
}
3.If statements require brackets, for reasons already explained.
Examples:
void main( void )
{
if (&story == 1)
{
//stuff inside these brackets is run if &story is 1
say("look, a tree", 1);
}
if (&love == 1)
{
//stuff inside these brackets is run if &love is 1
say("I am in love", ¤t_sprite);
}
}
This will make the sprite say "I am in love" if &love is 1 and make dink say "look, a tree" if &story is 1. These events are independent, each happens regardless of whether the other happens. Why are the brackets neccesary? Because there would be another way to parse these statements if there were no brackets. Observe:
void main( void )
{
if (&story == 1)
{
say("look, a tree", 1);
if (&love == 1)
{
say("I am in love", ¤t_sprite);
}
}
}
Now, dink will say "look, a tree" if &story is 1, and the sprite will say "I am in love" if &love is 1 AND &story is 1, because the second if statement will not be reached unless &story is 1.
If this is confusing, here are some rules.
1.For every open bracket, there is a closed bracket.
2.Procedures, like void main( void ) or main talk( void ) require brackets (don't ask me why ). For example, this is good:
void main( void )
{
say("this is where the stuff goes", 1);
}
But this is bad:
void main( void )
say("This doesn't go here!", 1);
{
}
And this is bad
void main( void )
{
void talk( void )
{
}
}
But this is good:
void main( void )
{
}
void talk( void )
{
}
3.If statements require brackets, for reasons already explained.