View Full Version : Reference Lua Variable from within Object Super Subclass

December 6th, 2013, 07:40 AM
I'm using the 'standard' transport lua code for some coms links, one of which I want to analyse the received data, and depending on what is contained in the received string to set a variable to a status.
I am using a CM11 X10 transceiver to control my lights and I would like this connected via a TCPIP -RS232 link, but the CM11 plugin can only reference a com port, not a IP address and the virtual com port software I've tried is not that robust.
Plus as the protocol does not seem too onerous, I thought I would have a stab at coding it myself as a transport.

So as an extract (I've missed the middle bit out as it is standard)

local Object = Super:Subclass ( {

Name = 'X10CM11Link',
Description = 'X10 CM11 Link',
GUIDefaults = {
allowedtransports = {
[constants.transport.GIP] = true,
[constants.transport.SERIAL] = true,
defaulttransport = constants.transport.SERIAL,
baud = 4800,
port = 7,

local c = ComponentManager:GetComponentUsingName("Transport Manager")
local tx = c:GetTransportUsingName("My X10CM11Link")
self.MacroCodeSent = false
self.SetupCodeSent = false

OnReceiveData = function(self, Event)
print(self.Name .. " Received: ")
local s = math.bytetohex(Event:GetData())

if s == "55" then
HOUSE.X10.CM11Ready = true

if s == "5A" then
tx:Send (math.hextobyte("C3"))

So when I receive "55", I want to set the variable:

HOUSE.X10.CM11Ready = true
But this sets:

Transport.X10CM11Link.HOUSE.X10.CM11Ready = true

I believe that I understand that being an object, everything is referenced to that object name, but how do I break that reference and force a reference from the beginning of the Girder variable name space?
I've tried random things like \G and girder. etc. But none seem to work.

With thanks

December 31st, 2013, 03:13 AM
Any advice with this?
With thanks.

April 4th, 2014, 06:18 PM
I have a new programming issue where I want to do exactly the same thing as above!
Any advice?
With thanks

April 4th, 2014, 06:50 PM
I believe _G ( underscore G ) gives you access to the global state.