Error accessing bit library

bit = require(“bit”)

this is generating an error message … is there an updated way to accomplish this snippet below?

if, ls) == b then
return v

What machine are you running this on? Your Lua installation may not have this installed by default.

(I moved this to a new topic from an eight-year-old thread.)

1 Like

either that or you have an oriented quote copy paste problem…

bit = require(“bit”)
should be
bit = require("bit")

1 Like

There are a number of bit libraries around: bit, bit32, … and they are rather compatible.
I use the following snippet I found on so I don’t have to bother which one is used:

local function requireany(...)
  local errs = {}
  for _,name in ipairs{...} do
    if type(name) ~= 'string' then return name, '' end
    local ok, mod = pcall(require, name)
    if ok then return mod, name end
    errs[#errs+1] = mod
  error(table.concat(errs, '\n'), 2)

-- Try to use whatever bit-manipulation library that is available
local bit, _ = requireany('bit', 'nixio.bit', 'bit32', 'bit.numberlua')


I think all Veras have nixio installed. Seems quite a complete set of functions. probably should look into it a bit more.

Cheers Rene

Best Home Automation shopping experience. Shop at getvera!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules