DLM Posted September 8, 2014 Share Posted September 8, 2014 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 endFunction that splits string by commasfunction ZonesNaming(nZones) -- Exemplo: Quarto, WC local t = {} for match in string.gmatch(nZones, "[^,]+") do table.insert(t, match) end endPrinting 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. Link to comment Share on other sites More sharing options...
DLM Posted September 8, 2014 Author Share Posted September 8, 2014 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.