User Tools

Site Tools


harlowe:dm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

harlowe:dm [2017/10/09 20:39] (current)
Line 1: Line 1:
 +**(dm: // <span class=parameter_optional>​[</​span>​...Any<​span class=parameter_optional>​]</​span>//​) -> //​[[harlowe:​Datamap|datamap]]//​**
  
 +Also known as: [[harlowe:​datamap|(datamap:​)]]
 +
 +Creates a [[harlowe:​datamap|datamap]],​ which is a data structure that pairs [[harlowe:​string|string]] names with data values.
 +You should provide a string name, followed by the value paired with it, and then another
 +string name, another value, and so on, for as many as you'd like.
 +
 +=== Example usage: ===
 +
 +''​%%(dm:​)%%''​ creates an empty datamap.
 +''​%%(dm:​ "​Cute",​ 4, "​Wit",​ 7)%%''​ creates a datamap with two names and values.
 +The following code also creates a datamap, with the names and values laid out in a readable fashion:
 +
 +<​code>​
 +(dm:
 +"​Susan",​ "A petite human in a yellow dress",​
 +"​Tina",​ "A ten-foot lizardoid in a three-piece suit",
 +"​Gertie",​ "A griffin draped in a flowing cape",
 +)
 +</​code>​
 +=== Rationale: ===
 +
 +For an explanation of what datamaps are, see the Datamap article.
 +This macro is the primary means of creating datamaps - simply supply a name,
 +followed by a value, and so on.
 +
 +In addition to creating datamaps for long-term use, this is also used to
 +create "​momentary"​ datamaps which are used only in some operation. For instance,
 +to add several values to a datamap at once, you can do something like this:
 +
 +<​code>​
 +(set: $map to it + (dm: "Name 1", "Value 1", "Name 2", "Value 2"))
 +</​code>​
 +You can also use (dm:) as a kind of "​multiple choice"​ structure, if you combine it with
 +the ''​%%'​s%%''​ or ''​%%of%%''​ syntax. For instance...
 +
 +<​code>​
 +(set: $element to $monsterName of (dm:
 +"​Chilltoad",​ "​Ice",​
 +"​Rimeswan",​ "​Ice",​
 +"​Brisketoid",​ "​Fire",​
 +"​Slime",​ "​Water"​
 +))
 +</​code>​
 +...will set $element to one of those elements if $monsterName matches the correct name. But, be warned: if
 +none of those names matches $monsterName,​ an error will result.
 +
 +=== See also: ===
 +
 +[[harlowe:​a|(a:​)]],​ [[harlowe:​ds|(ds:​)]]
harlowe/dm.txt ยท Last modified: 2017/10/09 20:39 (external edit)