PDA

View Full Version : Device Control by ControlPath error



MarBe
December 31st, 2015, 10:50 AM
Hi,
I want to use control object to control device. It works to control by controlId, but not by controlPath.
The trouble is at /, at script it is bad recognized, last ) is red.
I tried more style of writting, but no success.

My script
control, err = deviceManager.control( "Home///Světlo obývák///Světlo obývák" )

if control then
deviceManager.requestControlValueChange(control.id , 50)
else
print(err)
end

Printscreen at attachment

Ron
December 31st, 2015, 11:23 AM
That's probably just the highlighter having trouble. What does the Lua Engine say when you try to run it?

MarBe
December 31st, 2015, 11:51 AM
čt pro 31 18:50:10 2015 Path Error

Ron
December 31st, 2015, 12:07 PM
Hmm, did you create that path by copy and pasting it from the device manager? If not try that. Select the control you wish to change and then right click. Select "Copy Control Path". Then paste that into the script. If that still doesn't work could you try without the international characters? If that solves it I'll have to dig where it's failing.

MarBe
January 3rd, 2016, 06:59 AM
Yes, the trouble is at international characters, I tried to control other device by copying control path from device manager without international charactersd, and it works.

Ron
January 4th, 2016, 07:48 AM
OK will investigate that.

Ron
January 11th, 2016, 03:11 PM
Turns out that Lua cannot read UTF8 as such when running that script it just gets garbage for the string. To fix that I've added a function to the Device manager that encodes a UTF8 string into something Lua can handle. You can use this by clicking on "Copy Control Path for Lua". If the string only contains ascii it will results in the same string. Only multi byte UTF8 characters get encoded.

for example
Home///Bla Bla 79///Světlo obývák
becomes
Home///Bla Bla 79///Sv\196\155tlo ob\195\189v\195\161k

Not very readable, but at least it works. This will release with the next Girder release.