Welcome to the RaGEZONE - MMORPG development forums.

[Guide]Chapter 5. Navigating the Code Tree

This is a discussion on [Guide]Chapter 5. Navigating the Code Tree within the BYOND Tutorials forums, part of the BYOND category; Welcome to chapter 5 ! Read carefully. If you have any questions of just want to leave your feedback, feel ...

Results 1 to 1 of 1
  1. #1
    Whiskey in the Jar
    Rank
    Alpha Member
    Join Date
    Jan 2009
    Location
    Bulgaria
    Posts
    1,581
    Liked
    204
    Steam ID: antimonss

    [Guide]Chapter 5. Navigating the Code Tree

    Click
    Welcome to chapter 5 ! Read carefully. If you have any questions of just want to leave your feedback, feel free to do it.


    Chapter 5. Navigating the Code Tree



    The previous chapter was a quick introduction to give you a taste for DM programming. This and the next chapters will cover the same ideas, but in greater detail.

    A DM program begins from the root of the tree and descends in the branches. Each branch has a name to distinguish from the others, but names are case-sensitive. (Example: Door and door are different) Names can be any length and may contain any combination of letters, numbers and underscores as long as they don't start with a number.

    Lets take a look at a code for example.

    Code:
    turf
       trap
          pit
          glue
          quicksand
    So we got few traps here, each of them is on a separate line and indentation is used to define relationships between them. Pit, glue and quicksand are children of trap, which is in turn derived from turf.

    DM provides flexibility when it comes to formatting the code. To compress code that is overly spread out, a semicolon may be used in place of a newline. In this way several children may reside on the same line.

    The following code is equivalent to the previous one.
    Code:
    turf/trap
       pit; glue; quicksand
    In addition braces may be used to mark beginning and ending of a node's children. C, C++ and Java programmers may find this better. With the compiler checking both braces and indentation, its hard for small mistakes to slip through. Sometimes its simple spelling and typesetting errors that are the hardest to notice.

    Here's another version of the first example using braces:

    Code:
    truf/trap
    {
       pit
       glue
       quicksand
    }
    You may used either Tabs or Spaces to indent your code. In conclusion we can say that DM provides freedom when it comes to formatting your code.

    Stick around for Chapter 6 and Thanks for reading!

    Guide is written with the help of Dantom's book.
    Last edited by Thunda; 07-05-12 at 10:15 AM.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •