The Dink Network

Reply to Re: Globals and the if statement

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
July 27th 2002, 06:27 AM
fish.gif
Simeon
Peasant He/Him Netherlands
Any fool can use a computer. Many do. 
Next, why are there two separate if() statements when one will do if you phrase them like this

void talk(void);

{

return;

if (&story == 1);

{

freeze(1);

\Conversation is in here

&story = 2;

unfreeze(1);

return;

}

}

-------------------------

Well, bdjnk, that's not really true. JonSultar wants to let the person say something when &story = 1 and then change &story to 2. If Dink talks to that person again, the person says nothing. In your script, nothing happens when Dink talks to that person, no matter what happens. You see, if &story = 1, the return; command will be run before the script reaches the check to see if &story = 1 so it doesn't matter. If story is 1 or 2 or 1234, the return; command will be run first. Here's the corrected version of the script:

void talk(void)

{

freeze(1)

if (&story == 1)

{

//Conversation here - you guys even had the comments wrong.

//It has to be // and not \

&story = 2;

//The variable &story is now 2. Of course, this variable has to

//be a global so it has to be declared in Main.c

return;

}

if (&story == 2)

{

return;

}

unfreeze(1)

//It's better to have the freeze(1) and unfreeze(1) like this because

//then it's easier to add things later, otherwise you have to add

//those two commands for each time you want to let the person and Dink

//talk but it's your choice

}