panel script api

Questions about deployment and use of Air Manager Instruments

Moderators: russ, Ralph

Post Reply
Message
Author
flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

panel script api

#1 Post by flyatr »

Hi there,

I'm playing around with panel scripts. I'm trying to add a button to hide an instrument but it won't show up.

Code: Select all

button_id = button_add("knob_arc.png", "knob_arc_pressed.png", 10,10,200,200,callback_pressed, callback_released)
The API states that certain functions only work in panel scripts. But what about the other way round? Which functions do work in a panel script? I can't get a timer to work either.

Tetrachromat
Posts: 236
Joined: Sun Feb 14, 2021 6:55 pm

Re: panel script api

#2 Post by Tetrachromat »

I use code like this to show/hide instrument using a click spot on the panel:

Code: Select all

-- Instrument to Hide/Show
local instrument = {
  state = false,
  uuid = "92ad64fd-fa71-4266-add9-f7ac71c2b2cf"
}
instrument.id = instrument_get(instrument.uuid)

-- Instrument Clickspot
instrument.set = function ()
  instrument.state = not instrument.state
  instrument.display()
end
instrument.clickspot = button_add(nil, nil, 0, 800, 100, 100, instrument.set)

-- Hide/Show Instrument
instrument.display = function ()
  visible(instrument.id, instrument.state)
end

-- Initialze Panel
instrument.display()
-- END
Just replace the UUID above, with the one from your instrument. And place the clickspot where you need it.

Actually you can use all the AM API in your panel scripts, plus the 2 functions marked as only available for panel scripts. Otherwise there is no difference to instrument scripts.

Paul

flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: panel script api

#3 Post by flyatr »

That's a big help. Thanks very much.

flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: panel script api

#4 Post by flyatr »

Been busy but now I tried it. I get an error message. Not sure what's wrong, I triple checked the uuid.
I'd appreciate any assistance.
am.jpg

Tetrachromat
Posts: 236
Joined: Sun Feb 14, 2021 6:55 pm

Re: panel script api

#5 Post by Tetrachromat »

Where did you get that UUID from? It apparently is not a valid ID, as Air Manager cannot find it.

You can search manually in the instrument directory (for community and personal instruments: 'C:\Users\<your username>\Air Manager\instruments\OPEN_DIRECTORY' )

I do the following steps to get the proper UUID of an instrument:
- Select the 'Instrument' list
- Right click on the instrument name (opens the context menu)
- Select 'Copy the UUID to the clipboard'
- Go back to your panel script
- Paste the UUID into your code

Paul

flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: panel script api

#6 Post by flyatr »

Thanks but like I said I checked the uuid. It's a store version, so no clone or anything.
image.png

flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: panel script api

#7 Post by flyatr »

Okay I figured it out. This happened because I launched the panel from the create tab. Launching it from the Home tab works fine.

Post Reply