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 ...
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.
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.Code:turf trap pit glue quicksand
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.
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.Code:turf/trap pit; glue; quicksand
Here's another version of the first example using braces:
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.Code:truf/trap { pit glue quicksand }
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.