The Dink Network

Reply to Re: return;

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:
 
 
February 9th 2010, 09:10 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
"return;" stops running the script:

void talk( void )
{
  say_stop("The next line has return on it",1);
  return;
  say_stop("I'll never say this line!",1);
}


It is commonly used whenever you use a lot of ifs.

void talk( void )
{
  if (&story == 0)
  {
    say_stop("Oh, my, story is 0!",1);
    return;
  }
  if (&story == 1)
  {
    say_stop("Right now, story is 1!",1);
    say_stop("Let's set it to 2.",1);
    &story = 2;
    return;
  }
  if (&story == 2)
  {
    say_stop("Story is 2!",1);
    return;
  }
  say_stop("Story is not 0, 1, or 2",1);
}


If I hadn't used "return;" everywhere, Dink would have said the last line whenever you talked to whatever this script is attached to. Even worse, when &story is 1, it'd set &story to 2, and it'd immediately say that "Story is 2!" as well. Which is something you often don't want.