]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
lamp-remote: tonumber after checking regex result
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 26 Aug 2017 23:03:37 +0000 (19:03 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 26 Aug 2017 23:03:37 +0000 (19:03 -0400)
Otherwise, r/g/b might be nil and tonumber(nil) doesn't work out well

lamp-remote.lua

index 3a59a61f916be3f66d069b5212f9ae81a0e9bd43..ba38d33832a421d755606d76fa315578b9145381 100644 (file)
@@ -35,8 +35,8 @@ return function(msg)
       -- on the next tick (for, e.g., delay's use).  This is done on a
       -- callback to prevent deep stacks.
       local m,r,g,b = s:match("^(%w+)%s+(%x+)%s+(%x+)%s+(%x+)%s*$")
-      g = tonumber(g,16); r = tonumber(r,16); b = tonumber(b,16)
       if m then
+        g = tonumber(g,16); r = tonumber(r,16); b = tonumber(b,16)
         fq(function()
           remotetmr:unregister()
           loaddrawfn(m)(remotetmr,remotefb,g,r,b); doremotedraw()