Plugin question

• Nov 7, 2022 - 21:05

I just really dont understand what is going on with my musescore debugger.
I want to display my variable "notes" as included in files attached. I just get some random numbers and not the actual result.

Btw I do not even know if in variable notes I should get the cursor position or what ?

Last question.
Why is cursor.element.type = 93 ?
Can you please help me.

Thank you


Comments

Isn't it very confusing that the text labels you show don't match the values you place after them?

The value of 93 is the numeric value of the property type of the element currently referenced by the cursor object. As per the plugin API documentation this integer is a value from the ElementType enumeration. In this case (and as evidenced by your surrounding "if condition") that value corresponds with the definition of Element.CHORD.

You might want to take a closer look at the walk.qml example plugin that outputs some useful information about the score contents and will guide you a bit in how to access the different elements within the score.

Welcome to musescore plugin coding

>> notes[]
I'd loop thru it
method1:
for (var i in cursor.element.notes){ console.log(i+', '+cursor.element.notes[i].pitch) }
method2:
for (var i = 0; i < cursor.element.notes.length; i++){ console.log(i+', '+cursor.element.notes[i].pitch) }

>> .type and random number
it's a number coz these enums are integer internally, you are doing the comparison correctly using CAPITAL LETTER ENUMs (click ElementType)

Human understandable info try .name instead
console.log( cursor.element.name )

>> cursor position
do you mean time? try .tick
Cursor has .tick
also use .parent to get to Segment and it has .tick

More info see runtime internal score structure reference, also tick length under "for manipulation of time"

>> Also try these, help me as a beginner
Try Object Explorer plugin which exhaustively print out element info
Try the other visual debugger
Try snippets

You can help others by adding what you learn to the wiki, just click the three dots to the right of the article title

Do you still have an unanswered question? Please log in first to post your question.