Sugarcube
Equivalent functionality in Sugarcube v2
Examples taken from the Sugarcube online documentation
Sugarcube and Moontale have fundamentally different use-cases! This guide is not exhaustive - in particular, it does not cover the DOM, Input, Audio, or utility functions.
Macros and Functions
As a rule, Moontale makes no distinction between a 'macro' and a 'function'. The changer syntax $foo[Text]
makes use of foo
as a Lua function, and using it in code e.g. {$ x = foo(y) $}
is just as valid.
Syntax
The following syntax is identical in Sugarcube and Moontale:
[[Passage]]
[[Link -> Target]]
[[Target <- Link]]
$variable
* Unordered lists
> Blockquote
Sugarcube
Moontale
<<print $name>>
{$ Show(name) $}
<<= 2 + 3>>
<$ 2 + 3 $>
"""No markup"""
<$ 'No markup' $>
{{{$name}}}
`$name`
[[Label|Target]]
and [[Label][Target]]
[[Label->Target]]
[[Go buy milk|Grocery][$bought to "milk"]]
$On.click<<bought = 'milk'; Jump('Grocery') end>>[Go buy milk]
[img[Image][Link]]
etc.
[[$Image('path/to/image')->Target]]
🚧
Single \
Line
\ text
New line
Single
Line
text
New line
Note the extra space to force a line break
!Heading 1
# Heading 1
!!Heading 2
## Heading 2
//Emphasis//
*Emphasis*
or _Emphasis_
''Strong''
**Strong**
or __Strong__
==Strikethrough==
~~Strikethrough~~
__Underline__
$Style.u[Underline]
# Item 1
# Item 2
1. Item 1
1. Item 2
{{{Code}}}
`Code`
{{{
Code
}}}
```
Code
```
----
---
or ***
Templates, e.g. ?He was always willing to lend ?his ear to anyone.
$Name.myTemplate[$He was always willing to lend $his ear to anyone.]
$With{He = 'She', his = 'her'}[$myTemplate]
🚧
/* Comment */
/% Comment %/
<!-- Comment -->
{$--[[ Comment --]]$}
<<capture foo bar>>
{$ local foo = foo; local bar = bar $}
<<run foo()>>
and <<script>>foo()<</script>>
{$ foo() $}
(Of course, this is Lua rather than JavaScript)
<<set $gold to 5>>
{$ gold = 5 $}
<<unset $cheese, $gold>>
{$ cheese = nil; gold = nil $}
<<include "Go West">>
[[ ->Go West]]
<< if $cash lt 5>>
$If(cash < 5)[
<<for i, name range $dwarves>>
$ForEach(dwarves)[
<<break>>
and <<continue>
Not supported in markup - use a script block with a for
loop
<<switch $hairColor>>
<<case "black" "brown">>
Dark haired, eh?
<<default>>
<</switch>>
$Switch(hairColor)
$Case('black', 'brown')[ Dark haired, eh? ]
$Else[ ]
🚧
Last updated