Jump to content
C4 Forums | Control4

Problem with first time using 'Properties'


Recommended Posts

Hi guys!

I've successfully implemented a function that adds dynamic bindings according to the value entered in the driver Properties.
Now I'm trying to assign names to the respective zones using a string, then split it by commas. That function is already implemented although not sure if programme correctly.
An example of how the string should be is attached to this topic.

What I have is this:

function OnPropertyChanged(strProperty)  local prop = Properties[strProperty]    if (strProperty == "Number of Zones") then    CreateZoneBindings(tonumber(prop))  end    if (strProperty == "Zones Names") then    local znames = string.sub(Properties[strProperty], 1, -1)    ZonesNaming(znames)  end     end

Function that splits string by commas

function ZonesNaming(nZones) -- Exemplo: Quarto, WC  local t = {}  for match in string.gmatch(nZones, "[^,]+") do  table.insert(t, match)  end end

Printing name of zone.
Message should be like "Zone WC1 opened." for when zone 1 is opened.

C4:SendToProxy(5001, "DISPLAY_TEXT", "<text>Zone" .. t[numzone] .. " opened.</text>")

EDIT: With this coding I get the message "[string "Lua Code"]:185: attempt to index global 't' (a nil value) (ReceivedFromNetwork)" each time I open a zone.

post-135486-0-85318600-1410188660_thumb.

post-135486-0-64638000-1410188661_thumb.

Link to comment
Share on other sites


Solved, t was declared has local, just removed local and it works like a charm!

One question, it's possible to have customized fields in Properties depending on the number of zones entered? (instead of one string with all names)
For example one enters 10 zones, so 10 fields should appear below "Number of Zones" to name each zone.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.