Denovo

Script mode

The typed text language behind every block, and how it maps back and forth.

Every Denovo project can be edited as blocks or as text. Press script in the header to switch. Both views edit the same saved document, so you can move between them at any time. Switching back to blocks is refused only while the script has an error marked "fix this to switch back to blocks", such as a syntax error or an unknown name. Type errors and warnings are kept and show up in the blocks as well.

The script is printed from the blocks each time you open it, so its layout is always the canonical one. Comments you write are kept: a comment belongs to the statement or declaration under it.

The Definitions show how every single block is written in script mode.

Files

A project has one or more files, shown as tabs. Everything declared in one file (variables, functions, enums and structs) is visible in all the others. Right-click a stack of blocks to move it to another file.

Event handlers

A handler is a def named after the event, with on in front. Its parameter is the event, and the event's values are read with a dot:

def onBlockPlace(event) {
  event.player.sendMessage("You placed " + event.block.getType().toString())
}

@command("heal")
def onCommand(event) {
  event.player.setHealth(20)
}

Settings that the block has as typed-in fields become decorators, like @command("heal"). Type def on to get the list of events.

Variables

var round: int
var teams: List<Team>

Variables are declared once, at the top of any file, and are shared by the whole project. Like the variables in the blocks, they start empty for every run of a handler. The type is optional; without one it is taken from the first value stored in it.

Statements

ScriptBlock
x = valueset x to value
if a { } else if b { } else { }if / if-else
repeat 3 { }repeat
for item in list { }for each
breakbreak out of loop
wait 20wait ticks
log "hp " + xdebug log
endGame()end the game
return / return valuereturn

Values

  • Numbers 5, 1.5, text "hi", true / false, and _ for an empty slot.
  • Operators + - * / %, comparisons == != < <= > >=, and and, or, not.
  • "text" + value joins text. Use concat(a, b) when neither side is written as text.
  • Methods on Minecraft values: event.player.getWorld(). Completion lists what each value has.
  • Constants such as Particle.HAPPY_VILLAGER or Material.STONE.
  • Lists [a, b] and maps Map(), with list.add(x), list.get(0), map.put(k, v) and more.
  • onlinePlayers() is a list of every player on the server, and world.getPlayers() the players in one world. Go through either with for p in onlinePlayers() { }.
  • Each player has a scoreboard: p.scoreboard().setLine(1, "Alive: 3") changes a line, and p.scoreboard().update() shows every change at once, without flicker.

Functions

def reward(p: Player, amount: int) {
  p.sendMessage("+" + amount + " coins")
}

def total(): int {
  return 42
}

A function with a return type can be used as a value. Parameters are read-only; use a variable to keep state.

Enums and structs

enum Phase { WAITING, RUNNING, ENDED }

struct Team { name: string, score: int }

var teams: List<Team>

def onStart(event) {
  teams = [Team(name: "red", score: 0)]
  for t in teams {
    t.score = t.score + 1
  }
}

Each has its own blocks under My Blocks, next to Make a function, Make an enum and Make a struct.

On this page