Author Topic: Menu Interactions  (Read 921 times)

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1736
Menu Interactions
« 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:

Code: [Select]
        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

  • Contributor
  • Hero Member
  • *****
  • Posts: 1736
Re: Menu Interactions
« Reply #1 on: December 02, 2017, 02:05:29 PM »
I thought my confusing menu naming may be doing it.

So I changed to this:

Code: [Select]
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

  • Contributor
  • Hero Member
  • *****
  • Posts: 1736
Re: [SOLVED] Menu Interactions
« Reply #2 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

Code: [Select]
menu.get("Focus Bar","Display","") to get a string back.

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 12223
  • Maintenance mode
Re: Menu Interactions
« Reply #3 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)

garry23

  • Contributor
  • Hero Member
  • *****
  • Posts: 1736
Re: Menu Interactions
« Reply #4 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