Before you start building any more serious example, you have to learn about DEF (naming objects so that you can reuse them) and PROTO (building your own node type).