PDA

View Full Version : Action of a button in a script lua



sonata31
February 10th, 2009, 08:11 AM
In a script lua how to reach the action of a button situated in a page which is not the current page?

Rob H
February 10th, 2009, 02:37 PM
Not possible I don't think

sonata31
February 11th, 2009, 12:46 AM
It is indeed pity

Rob H
February 11th, 2009, 08:41 AM
There is a sort of workaround though. If you put a hidden frame in the device template with all the buttons on then you can access them from Lua that way

harleydude
February 11th, 2009, 09:03 AM
What exactly are you trying to do?

sonata31
February 11th, 2009, 09:07 AM
There is a sort of workaround though. If you put a hidden frame in the device template with all the buttons on then you can access them from Lua that way

These buttons are in a visible page

Rob H
February 11th, 2009, 09:12 AM
So why not let the buttons on the visible page be aliases for the 'real' buttons on a hidden frame.

As harleydude says, what are you trying to do?

sonata31
February 11th, 2009, 09:15 AM
What exactly are you trying to do?

I have a function which has several parameters and which can be called several places with the same parameters, among others a button.
To avoid having to modify several places if I change the parameters I shall like that the action connected to this button and which calls this functionoffice can be called in my script lua, as it if I change parameters, I would make it only only at the level of the button I clarify that this button

Rob H
February 11th, 2009, 09:22 AM
In that case why not create a new function that passes just those parameters that you're calling from the button and then use that on the button and elsewhere?

sonata31
February 11th, 2009, 09:26 AM
In that case why not create a new function that passes just those parameters that you're calling from the button and then use that on the button and elsewhere?

Because buttons represent configurations of remote control and because it is them who serve as reference

harleydude
February 11th, 2009, 10:37 AM
Can you post these functions you are using, maybe we can figure something out.

sonata31
February 11th, 2009, 12:08 PM
Can you post these functions you are using, maybe we can figure something out.

For example in a script lua I have the function :



function TVIncVol()
TVTelco("INCVOL", "0");
end;


On the other hand I have a button connected to a remote control, which contains the code lua following:



TVTelco("INCVOL", "0");


If I modify the function TVTelco () I am obliged to make it for several places.
I would like to have to make it only at the level of the button, because it is him who really represents the command of the remote control.
In that case I would like to call the action of the button to different places of my scripts lua

harleydude
February 11th, 2009, 12:36 PM
If the function TVIncVol() and the button both call TVTelco("INCVOL", "0"); you can have the button call TVIncVol() and achieve what you want.

sonata31
February 11th, 2009, 01:34 PM
If the function TVIncVol() and the button both call TVTelco("INCVOL", "0"); you can have the button call TVIncVol() and achieve what you want.

No, it is not the good method, because the basic function is TVTelco() and not TVIncVol()

Rob H
February 11th, 2009, 05:32 PM
I give up!

sonata31
February 12th, 2009, 12:47 AM
I give up!

What is the technical impossibility to call up the action of a button of a page other one than the current page?

Rob H
February 12th, 2009, 04:55 AM
The page containing the button isn't currently loaded into memory - the page would need to be loaded but not displayed and then the button located - unambiguously locating a button from Lua is tricky.

I don't see what is wrong with harleydude's suggestion. In fact I'd go further and say why not have a function for every button on the remote, put them all into a table called TV e.g.


TV = TV or {}
TV.IncVol = function() TVTelco("INCVOL", "0"); end ;
etc.

sonata31
February 12th, 2009, 05:31 AM
The page containing the button isn't currently loaded into memory - the page would need to be loaded but not displayed and then the button located - unambiguously locating a button from Lua is tricky.

I don't see what is wrong with harleydude's suggestion. In fact I'd go further and say why not have a function for every button on the remote, put them all into a table called TV e.g.


TV = TV or {}
TV.IncVol = function() TVTelco("INCVOL", "0"); end ;
etc.

Ok for the explanation

Finally I adopted the following solution which allows to be general:



function Telco(device, codeToSend)
...
SendIR (telcoName, codeToSend);
end;

function SendIR(device, codeToSend)
end;


telcoName is "TV", "SAT", "BLURAY", ...
codeToSend is "POWER", "LEFTARROW", "OK", "1", ...

The function SendIR () allows according to the device and commandsorde it to get back the code IR in a table appropriate for every device and to send it