Hi,
What I do with critical variables in LUA is store them as Global Variables in MA and then get those variables when I need them from LUA. This way it gets stored with the showfile.
Best,
Maxwell
Hi,
What I do with critical variables in LUA is store them as Global Variables in MA and then get those variables when I need them from LUA. This way it gets stored with the showfile.
Best,
Maxwell
Amazing! Thank you. This makes sense.
Hi Everyone,
Am I able to get the root index of a layout object by giving the ID of the macro assigned to that object?
Something like this
ShowData().DataPools.Default.Layouts[1].ID[2515]
Where I give the ID number and it returns the index of that layout element.
Thanks,
Maxwell
Display Moreto my knowledge:
only the mouse object has a get-able coordinates (cursor), not the touch object
in Lua/UI context the touched object is the Layout Viewer Canvas, not the actual macro.
still I don't think it is impossible to get the screen coordinates of the layout element, just a lot of work and calculation based on the properties of the canvas, and the properties of the layout elements.
I think I can get the coordinates the hard way, by getting the object location within the layout, then do some math to get the coordinates on the screen within the layout. I am having trouble getting the current object information. Do you have any insight on which function would help me get the index of the object I touch in a layout view. Then I can get its coordinates within the layout, and go from there.
Thanks,
Maxwell
I found that this doesn't work on a console. The cursor moves to where I touched, but it does not recalculate the coordinates. Only when I plug in a mouse will the coordinates update.
This seems to work. Thanks!
Thanks for your suggestion. I don't think it will work for this specific button I am making, but will be super useful for other things I am trying to impliment.
Thanks,
Maxwell
Hi Everyone,
Is there a way to tell if the user short pressed or long pressed an executor via Lua?
I am trying to create a button that acts as a toggle button when short pressed, but a temp when long pressed.
Thanks,
Maxwell
Looking at this code, do you know how we can input a custom color instead of using the system colors in the Root folder?
Looking for something like this:
Thanks,
Maxwell
This works great in OnPC. Thank you for your help. I will have to try it on the console touch screen. Do you think the TouchObj function would work on the console instead of MouseObj?
I think getting the cursor coordinates would work for me in this case, and would be the simplest. Could you please give an example of how I would get those? I can't find any documentation on how to use Mouse, MouseObj, or TouchObj.
Thanks,
Maxwell
Hi,
I am on MA3 and trying to get the X,Y coordinates of either the users touchscreen press or the coordinates of the object they touched. Is this possible in LUA?
Example:
When the user presses a macro in a layout window I run a LUA function that opens a Popup Input Dialog. I am trying to get this popup to open where the layout object's X, Y coordinates are on screen.
Thanks,
Maxwell
Display Moredon't do this:
repeat until buttonReturn
to see what's happening, try to exhange this line to
repeat Echo('checking if there is a buttonReturn') until buttonReturn
look at system monitor and the timestamps of the echos, and consider if this is efficient code.
then try exchange with the equivalent of my suggestion:
repeat Echo('checking if there is a buttonReturn') coroutine.yield(0.05) until buttonReturn
look at system monitor and the timestamps again
- checking 10-20 times a second instead of 10000+ times a second is more efficient.
You are absolutely correct. Thank you for your input.
Best,
Maxwell
Hi,
I am wondering if anyone has been able to get the coordinates of the user input on the touchscreens, or even just able to get the position of the object that was selected? I have created a custom dialog in Lua that is triggered from a macro in MA. When the user taps on the macro in a layout, the popup appears at 0,0. I am able to input coordinates to place the dialog anywhere on the screen, but I would prefer to make it dynamic so the coordinates come from wherever the user tapped. Again, for my purposes this can come from the user tap coordinates or the coordinates of the tapped object on the layout. This would function just like a swipey, but without the 'Swiping' part.
Thank you,
Maxwell
the easiest solution would be to yield while the dialog exists:
Hi Andreas,
Thank you for your response. I ended up getting this working using the following code. Would you recommend your solution over the repeat loop I am using at the end? I'm just trying to learn how to make my code as efficient as possible.
function directionSelectionPopup()
--Define variables
local buttonReturn
--[[ POPUP DIALOG UI CODE THAT RETURNS THE BUTTON THAT WAS PRESSED ]]--
--Handlers
signalTable.ButonClicked = function(caller)
buttonReturn = caller.text)
Echo('Clicked: ' .. buttonReturn)
Obj.Delete(screenOverlay, Obj.Index(baseInput))
end
repeat until buttonReturn
return buttonReturn
end
Display More
Thanks,
Maxwell
Hi,
I have successfully created a custom dialogue with 9 buttons in a 3 x 3 configuration. I am trying to call my popup dialogue and send the button pressed to a variable in another function. The problem I am having is that the function continues to run in the background while the popup dialogue is active. Therefore my selection in the popup doesn't get injected into the function in the right place. Below is a simplified example of my scenario.
The "popup" function returns the number of the button that was clicked.
My issue is that the "getMode" function runs, then the "popup" function runs, and the "getMode" function finishes, then when I click the popup button, it doesn't get assigned to the "mode" variable and the function echoes a nil value.
Is there a way to have the popup hault the running function until a selection or cancel happens?
Thanks,
Maxwell