-
Notifications
You must be signed in to change notification settings - Fork 468
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 returntrueon 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]. Returnstrueif 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