PDA

View Full Version : Plugin Actions from Lua



theguywiththefunnyhair
August 29th, 2006, 08:07 AM
hi,
i frequently want to use NetRemote plug actions from Lua, but i never know the syntax of the commands, is there a reference guide or some rules for how to do this?
For example right now i want to use the WebBrowser plugin action 'Go to URL' can i assume the syntax is 'NetRemote.GotoURL("browsername", "url")' ?
tanks
Dan

theguywiththefunnyhair
August 30th, 2006, 04:18 AM
I tried 'NetRemote.GotoURL("browsername", "url")' and it didnt work.
can i use this action from Lua?

honnt
August 30th, 2006, 05:32 AM
I'm certainly not the expert on this, but I use:


NetRemote.ExecuteAction(-2,1,32,"browsername,URL");

assumes, of course, that you're using the default instance of the WebBrowser plugin...

HTH,

theguywiththefunnyhair
August 30th, 2006, 06:48 AM
Hey honnt,
Thanks for your reply, its starting to make sense now... the '-2, 1, 32' matches up with the action ID that can be found on the top of the tab i see in NRD when i click on the action in the action designer. :D I think i'm ready to move foward!

It looks like the syntax you have posted is listed in the help files as being 'older', and im guessing;


[success] = [Instance]:ExecuteAction([actionid1], [actionid2], [params], [callno])

is the prefered method doing it.

Can anyone supply a code example of this new method? im not to sure where [Instance]: fits into the picture or what [callno] is for.

Cheers

Dan

Ben S
August 30th, 2006, 09:07 PM
I can. Terry's method will still work 100%, but you can also do ...



plugin = NetRemote.GetPlugin('Girder');
instance = plugin:GetCurrentInstance();
instance:ExecuteAction(-1,0,'Test');

theguywiththefunnyhair
August 31st, 2006, 02:54 AM
I am trying using Terrys method bu i cant get it to go to the URL i want, im pretty sure it finds the browser but i think its sending a bogus address.
the code im using is;


NetRemote.ExecuteAction(-2,1,32,"surf"..tostring(i), Dan.Menu.Web.URL)

where i and Dan.Menu.Web.URL are both Lua vars.
i have also tried;


NetRemote.ExecuteAction(-2,1,32,"surf"..tostring(i), "http://www.yahoo.com")

with the same result and;


NetRemote.ExecuteAction(-2,1,32,"surf2 , http://www.yahoo.com")

but that doesnt find the browser name

any help would be great.

Dan

honnt
August 31st, 2006, 06:05 AM
You might try something like this:


local i = 2
local url='http://www.promixis.com'
NetRemote.ExecuteAction(-2,1,32,'surf'..tonumber(i)..','..url)


Also an attached ccf to demonstrate.

theguywiththefunnyhair
August 31st, 2006, 06:35 AM
Thanks Terry, i soon as i saw the solution i was like "Of course!".
Its all working -exactly- as i want it to now.

Dan

Ben S
September 4th, 2006, 08:09 PM
Great! Can't wait to see the final CCF, Dan.

theguywiththefunnyhair
October 31st, 2006, 05:05 AM
plugin = NetRemote.GetPlugin('Girder');
instance = plugin:GetCurrentInstance();
instance:ExecuteAction(-1,0,'Test');


Hi Ben,
I've been playing around with doing things this way but im a little stuck.
this code raises a communication event in girder with the event string "1.0" and pld3 has the value 'Test'.
What i want is to define an event string and also if possible send a second variable as pld4.
Can i do this?
thanks
Dan

Rob H
October 31st, 2006, 07:05 AM
You have to build the event string with brackets e.g.


instance:ExecuteAction(-1,0,'Test('..payload..')')

The only problem with this is that payload can't contain a ')', and I think you're still restricted to a single payload

theguywiththefunnyhair
October 31st, 2006, 11:59 PM
Hi Rob,
thanks for your help, thing is your code still sends 'test([value_of_payload])' as pld3 and the log still shows a communication server event with the details 1.0.
Is this working for you? Im using NR2.0.0.80 and G4.0.8.1.
Dan

Rob H
November 1st, 2006, 04:30 AM
Hang on a second - those first two parameters are wrong!

Try this :-


instance:ExecuteAction(0, 1, 'Test('..payload..')')

theguywiththefunnyhair
November 1st, 2006, 10:33 PM
now we're cooking with gas.

Its a bit of a shame that we cant specify pld4 and pld5 at the moment they are bothy being recieved in girder as blank strings, i guess they are reserved for something else.