Magic Lantern Forum

Developing Magic Lantern => Scripting Corner => Scripting Q&A => Topic started by: garry23 on December 02, 2017, 09:36:27 AM

Title: Menu Interactions
Post by: garry23 on December 02, 2017, 09:36:27 AM
I have two scripts running and I need to get one script interacting with another.

What I have tried, but it doesn't seem to work, is to simply get one script to change the menu settings of the other script. But nothing seems to happen.

Here is the code in one script, with Focus Bar being the ML menu created by the other script:

        if menu.get("Focus Bar","Focus Bar") == "ON" then
            menu.set("Focus Bar","Focus Bar","OFF")
        elseif menu.get("Focus Bar","Focus Bar") == "OFF" then
            menu.set("Focus Bar","Focus Bar","ON")
        end


Is the problem that Lua can't change a script created ML Menu?

Cheers

Garry
Title: Re: Menu Interactions
Post by: garry23 on December 02, 2017, 02:05:29 PM
I thought my confusing menu naming may be doing it.

So I changed to this:

if menu.get("Focus Bar","Display") == "ON" then
menu.set("Focus Bar","Display","OFF")
elseif menu.get("Focus Bar","Display") == "OFF" then
menu.set("Focus Bar","Display","ON")
end


Still no change. Unless a guru say otherwise, it looks to me that one script can't change the menu of another  :o
Title: Re: [SOLVED] Menu Interactions
Post by: garry23 on December 02, 2017, 02:47:37 PM
Ok in case there are other idiots out there  ;)

Always reread the API documentation!

You need to use this call

menu.get("Focus Bar","Display","") to get a string back.
Title: Re: Menu Interactions
Post by: a1ex on December 02, 2017, 03:03:32 PM
Would it make more sense to have menu.get return a string by default?

(I also forgot about this quirk and thought it must be a bug somewhere in the menu backend)
Title: Re: Menu Interactions
Post by: garry23 on December 02, 2017, 03:30:27 PM
@a1ex

I don't think that matters much, as long as you know how the menu is configured.

Cheers

Garry