DesignScript is a fantastic piece of the Dynamo puzzle.
It allows you to clean up messy definitions, nest node objects within each other and cycle through data using Replication Guides in a pretty efficient manner.
Node2Code (Dynamo 0.8.2 and above) will allow you to convert standard nodes to DesignScript, but will do so in a rather inefficient manner.
The basics of DesignScript are as follows:
There is a triumvirate of Creators (+), Queries (?) and Actions (Zap), that mirrors the node style in the library.
Creators will colour themselves green as shown below. Any time you partially type in a Creator, it should allow a dropdown menu showcasing the options you have.
Creators require Creation Methods. This is how your creator is to be formed and are coloured blue. A couple of examples are shown below:
After you have your chosen Method (Also available by a dropdown menu after your dot nomenclature), you need to put in values that the method requires to create your creator. These are always bound by brackets, and when you type in your open bracket you get an input prompt. You can cycle through this prompt with the arrow keys (For multiple creation methods). In the following example we can create a point by either a simple X and Y, or by X, Y and Z.
The prompt will tell you what type of data needs to go in, as well as give you the name.
After we put in our values, we close the Creator off with a Close Bracket and Semi-colon. The semi-colon wraps up that bit of code and calls it a day and is required for all DesignScript code.
That's the basics of Creators. But usually we need to use this data later on in the piece (Rather than simply using it's wire output), so we give it a name. After giving it a name we can call that thing by its name and apply queries or actions against it.
This is achieved by giving it a name followed by the equals sign as shown below:
Once we have this we can move onto our second item in the triumvirate, Queries, which also show up blue. It will, however, only show up blue when fully completed and written with the correct Title Casing.
Queries are achieved by putting a dot after a proper thing and subsequently writing out the query. Unfortunately, there is no dropdown list for these. You have to either know, or check the library - but it becomes second nature pretty swiftly.
In the case of Queries you don't use brackets (As it's simply querying and you don't need any values for a creation method).
An example of a query is shown below, where we want to get the Z-Value from our point, or get the Number of Cuves from a polycurve:
Any Query for that creation method type that can be done by nodes, can be done by code. If in doubt either use Node2Code to change a node or hover over the node in question and the DesignScript prompt will appear.
Our last triumvirate object is the Action.
This is where we want to do something to a thing.
As an example, we'll add a vector to our original point.
To action something, you also need to use the dot nomenclature, but as with queries, you don't get a prompt sadly, and will also show up blue. It will, however, only show up blue when fully completed and written with the correct Title Casing.
As noted previously in the creation section, we will need a method as we have to tell our action how to action. For this example we'll be using Point.Add as our Action Method.
Our chosen method will require values for it to action. So, as with our creator method, we need to use brackets to define these inputs. We need a little background knowledge on how our action works however as it won't give us prompts (Unfortunately).
In this case you'll need to know that the Point.Add command requires a vector. So we can either nest a creator within our action, or create a new line and define our vector with a name. Either will accomplish what we desire - which is moving our point up by 10 units.
You can also nest a whole bunch of methods together - and there are a couple of examples below courtesy of the extremely helpful folk at the Dynamobim.com forums (Namely for the images below: Dimitar Venkov, Vikram Subbaiah and Eprocauno).