Dittoscript is a text-based abstraction for node-based programs. It achieves simplicity by replacing node-based programming paradigms with familiar text-based ones. Its syntax has similarities with Python and Go.
Nodes are similar to expressions or statements in text-based programming.
Nodes can optionally be invoked with inputs and provide outputs. Builtin nodes can also be passed literals, custom data which cannot be changed by any inputs. Inputs and literals not passed fallback to a default value, while outputs not used are discarded.
Nodes can provide multiple entries that can be called by other nodes and callbacks that will call further nodes.
Nodes can be directly invoked by their name. Inputs and literals can be passed
in parentheses seperated by commata. They can be passed positionally, by name,
or left out using _
. Literals are positioned after the inputs.
set_score(5) # Input by position
set_score(coins 3) # Input by name
set_score(_, 3) # Skip input
set_score(5, _, most_points) # Mixed inputs and literals
win(delay: 20) # Literal by name
Assignments replace node-based wire splitting and spaghetti code with clear reusable labels. They work by assigning a value to a named literal to be used as label. Labels can be used as inputs in place of nodes.
obj = grass()
obj = clone(obj)
_, y = touch_sensor()
y: y = touch_sensor()
Callbacks are defined by position or name after the inputs.
if(random() > 0.5) true {
win()
} false {
lose()
}
i = loop(_, 5) do {
inspect(i)
}
Literals might behave differently when used as inputs.
Numeric literals will be transformed into number nodes.
-1.5 # num(-1.5)
3.14159 # num(3.14159)
Named literals will be transformed to labels for assigned values. See assignments.
Nodes can be defined after the def
keyword with their outputs, name, inputs
and entries in that order.
def result = lerp(from, to, amount) {
result = add(from, mul(sub(to - from), amount))
}
- implement the transpiler
- lexer & parser
- implement all node-based paradigms into text-based ones
- recursion
- declaring and calling callbacks
- macros
- batch list assignments
We are not affiliated with Fancade. See our disclaimer. For inquiries please contact us.