Skip to content

A text-based abstraction for node-based programs.

License

Notifications You must be signed in to change notification settings

dittocade/script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dittoscript

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.

Conventions

Nodes

Nodes are similar to expressions or statements in text-based programming.

I/O

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.

Execution flow

Nodes can provide multiple entries that can be called by other nodes and callbacks that will call further nodes.

Syntax

Invoking 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

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

Callbacks are defined by position or name after the inputs.

if(random() > 0.5) true {
    win()
} false {
    lose()
}

i = loop(_, 5) do {
    inspect(i)
}

Literal transformations

Literals might behave differently when used as inputs.

Numeric

Numeric literals will be transformed into number nodes.

-1.5 # num(-1.5)
3.14159 # num(3.14159)

Named

Named literals will be transformed to labels for assigned values. See assignments.

Defining nodes

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))
}

ToDo

  • implement the transpiler
    • lexer & parser
  • implement all node-based paradigms into text-based ones
    • recursion
    • declaring and calling callbacks
  • macros
    • batch list assignments

Disclaimer

We are not affiliated with Fancade. See our disclaimer. For inquiries please contact us.

About

A text-based abstraction for node-based programs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages