PDA

View Full Version : Capture the Girder event to be used in a script



noodleNT
August 12th, 2007, 05:01 PM
How do I caputer the EventString and pass it as a variable in LUA? For instance if I press the "1" key on my keyboard and the event "31000000" is sent to girder. I would like to capture that "31000000".


Example:
Press "1" ==> Prints 31000000

Event = gir.AddEventHandler("*",0,1,"")
Print (Event)

noodleNT
August 12th, 2007, 10:24 PM
Had to get me Case correct. :) Now that that is fixed, has the getGlobal function changed since Girder 3 to Girder 5? I need to return the value of the variable "Key_31000000". I am rewriting the Remote Input SMS style typing for Girder 5 and to teach myself LUA Scripting.

Thanks for any help,



local Event = EventString
local KeyEvent = "Key_"..Event
local Device = EventDevice
print ("Event:", Event)
print ("Device:", Device)

Key_31000000 = '1:/.@'


print (getGlobal(KeyEvent))

Rob H
August 13th, 2007, 02:02 AM
I'm not even sure what getGlobal did in G3.3 I'm afraid. Does anyone else know?

noodleNT
August 13th, 2007, 07:22 AM
I'm not even sure what getGlobal did in G3.3 I'm afraid. Does anyone else know?

Here is a thread of what it used to do:
http://www.promixis.com/forums/showthread.php?t=2780&highlight=getglobal

What I am trying to do is grab the value assigned to a variable dynamically.

So if the Number one key is pressed the event 31000000 is captured by girder. I then have a global set to Key_31000000 = '1:/.@'. I need to be able to get the value of this global dynamically. It should look something like this:

print("Key_"..EventString) = '1:/.@'

Rob H
August 13th, 2007, 07:40 AM
All globals are stored in a table called _G so you could use _G["Key_"..EventString].

However, it would make more sense to create a table to store these e.g.


Keys = {}
Keys['31000000'] = '1:/.@'

Then you should be able to use Keys[Event] to access it.

noodleNT
August 13th, 2007, 09:01 AM
Very cool idea with the table! Much cleaner!

This gives me the base work I need to rewrite the LUA script. Give me a few days and I hope to post back something that works. :>

noodleNT
August 13th, 2007, 03:32 PM
Thanks for the help... I have the updated Text Input script here:

http://www.promixis.com/forums/showthread.php?p=118260#post118260