Complex Menus

Started by garry23, December 28, 2019, 11:45:09 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

garry23

@a1ex

previously you told me that Lua doesn't handle 'complex menus' very well, ie at all.

I've tried to code up a solution in Lua and had partial success, see the function shutter below that takes the ML Expo Shutter and returns the shutter as a real number.

Where I'm failing is going the other way, ie pushing data to a complex menu item, like Desired FPS, see my attempt below, which doesn't work.

If you have any ideas about how to use Lua to solve complex menu interactions, I would be grateful.

--[[
TEST KEYS
]]

function shutter()
    local r = menu.get("Expo","Shutter","")
    local e = r:find(',')
    if e ~= nil then
        r = r:sub(1,(e-1))
    end
    if r:find('"') ~= nil then
        r = tonumber((r:gsub('"','')))
    else
        r = 1/(tonumber((r:sub(2))))
    end
    return r
end

local go = true
while go do
    msleep(1000)
    local r = menu.get("FPS override","Desired FPS","")
    local e = r:find("%(")
    r = r:sub(e) -- strip out the FPS part
    r = "0.23 "..r -- insert a new FPS
    menu.set("FPS override","Desired FPS",r)
    if key.last == KEY.UNPRESS_HALFSHUTTER then go = false end
end