Menu Interactions

Started by garry23, December 02, 2017, 09:36:27 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

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

garry23

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

garry23

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.

a1ex

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)

garry23

@a1ex

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

Cheers

Garry