The Dink Network

Reply to Re: no for loop and != in dink c?

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:
 
 
May 6th 2011, 07:02 AM
custom_magicman.gif
magicman
Peasant They/Them Netherlands duck
Mmmm, pizza. 
Read the chapter about "Control Structures" of dinkc.chm.

All usual comparison operators are allowed, just a couple of notes. We also have else-statements.

There must be a space after "if".
There must be spaces around the comparison operator.
Function calls inside the condition are not really allowed. It works for some functions (like "get_sprite_with_this_brain()"), and doesn't for others. I always use a temporary variable.
I have no clue if it accepts 0 and 1 as false/true. I always just use "== 0" and "== 1" and such.
Put "if (condition)" on its own line. Also put "{" and "}" on their own lines.
Put "else" on its own line. Also put "{" and "}" on their own lines.

The only kind of loop you have to make yourself with a combination of goto and if-statements. In short, things can look like this:

void main( void )
{
  int &count = 5;
}

void talk( void )
{
  freeze(1);
  loop:
  if (&count != 0)
  {
    say_stop("`%&count bottles of beer!", &current_sprite);
    &count -= 1;
    goto loop;
  }
  else
  {
    say_stop("`%Strictly, this else is not needed, but for demonstration purposes...", &current_sprite);
    say_stop("Okay, now you're really not making sense...",1);
  }
  unfreeze(1);
}