Skip to content

Component NoteBlock

Florian Nücke edited this page Mar 14, 2014 · 6 revisions

This component represents a vanilla note block.

Important: this component is only available if OpenComponents is also installed!

Component name: note_block.
Callbacks:

  • getPitch(): number
    Gets the current pitch set on the note block. This will always be a number in the interval [1, 25].
  • setPitch(value: number): boolean
    Sets the pitch for the note block. Must be a number in the interval [1, 25] or this will throw an error. Will return true on success.
  • trigger([pitch: number]): boolean
    Plays a note on the note block. If specified, sets the given pitch first, which must be in the interval [1, 25]. Returns true if a note was played, i.e. the block above the note block is an air block.

Example use:

local component = require("component")
val nb = component.note_block -- get primary note block
nb.setPitch(10)
nb.trigger()
for pitch = 1, 25 do
  nb.trigger(pitch)
end

Clone this wiki locally