User Tools

Site Tools


custom_macro

This is an old revision of the document!


Adding New Behaviors ——— Reference Home

Custom Macros

It's possible to write your own macros for use in your stories. Doing so will require knowledge of both JavaScript 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.

:: Hello macro [script]
macros['hello'] =
{
	handler: function()
	{
		alert('Hi, reader!');	
	}
}

:: Start
<<hello>>

If you're curious how a built-in macro works, browsing the source code repository may be helpful, too.

Adding New Behaviors ——— Reference Home

custom_macro.1411929882.txt.gz · Last modified: 2017/10/09 20:37 (external edit)