User Tools

Site Tools


coding:instructions

TODO: cleanup layout

Some coding instructions:

- two space indentation: Whenever you code try to use this two space rule. It makes your code much more readable.

- less than 80 characters per line If you make the lines longer they're running off the screen and need wrapping. Try to avoid this is it does not benefit readability. It also makes it difficult to keep your descriptions in a good format.

Bad example:


reset(arg) { if(!present("bear") && !present("deer") && !present("wolf")){
 
  {switch(random(3)){case 0:move_object(clone_object(BEAR),TO);break;case 1:move_object(clone_object(WOLF),TO);break;case 2:move_object(clone_object(DEER),TO);break;}}}
 
      if(arg) return;
 
      set_light(1);
      set_night_light(0);
      set_outdoor();
 
      set_short(FOREST_SHORT);
      set_long(FOREST_LONG);
      set_night_long(FOREST_LONG_NIGHT);
 
 
      add_item("forest","\The dark and unknown forest.\n\n");
      add_exit("west",NEWBIEPATH+"/areas/n1/fn1e1.c");
      add_exit("east",NEWBIEPATH+"/areas/n1/fn1e3.c");
      set_planet("caladan");
}

Should be:


reset(arg) 
{ 
  if(!present("bear") && !present("deer") && !present("wolf"))
  {
    switch(random(3))
    {
      case 0:
        move_object(clone_object(BEAR),TO);
        break;
      case 1:
        move_object(clone_object(WOLF),TO);
        break;
      case 2:
        move_object(clone_object(DEER),TO);
        break;
    }
  }
 
  if(arg) return;
 
  set_light(1);
  set_night_light(0);
  set_outdoor();
 
  set_short(FOREST_SHORT);
  set_long(FOREST_LONG);
  set_night_long(FOREST_LONG_NIGHT);
 
  add_item("forest","\The dark and unknown forest.\n\n");
 
  add_exit("west",NEWBIEPATH+"/areas/n1/fn1e1.c");
  add_exit("east",NEWBIEPATH+"/areas/n1/fn1e3.c");
 
  set_planet("caladan");
}

Also note that lines between certain parts of code add to the readability too. This is especially welcome if you code long files.

coding/instructions.txt · Last modified: 2010/04/27 06:51 by temujin