This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
writing_your_own_macros [2014/01/15 03:45] l |
writing_your_own_macros [2014/01/15 03:45] l |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Custom Macros ===== | + | #redirect [[custom macro]] |
- | + | ||
- | It's possible to write your own macros for use in your stories. Doing so will require knowledge of both Javadcript and the Twine engine. | + | |
- | + | ||
- | Here's an example passage that creates a macro named ''<<hello>>'' that, when invoked in another passage, displays an alert that greets the reader. | + | |
- | + | ||
- | <code> | + | |
- | :: Hello macro [script] | + | |
- | macros['hello'] = | + | |
- | { | + | |
- | handler: function() | + | |
- | { | + | |
- | alert('Hi, reader!'); | + | |
- | } | + | |
- | } | + | |
- | + | ||
- | :: Start | + | |
- | <<hello>> | + | |
- | </code> | + | |
- | + | ||
- | If you're curious how a built-in macro works, browsing the [[https://github.com/tweecode/twine|source code repository]] may be helpful, too. | + |