Make get_bit simpler again

This commit is contained in:
Jude Melton-Houghton 2021-07-30 13:19:56 -04:00
parent 4205efb6d0
commit d05a36676f
1 changed files with 2 additions and 5 deletions

View File

@ -163,12 +163,9 @@ function mesecon.getbinstate(nodename, states)
end
function mesecon.get_bit(binary,bit)
bit = bit or 1
local len = binary:len()
if bit then
if bit > len then return false end
else
bit = 1
end
if bit > len then return false end
local c = len-(bit-1)
return binary:sub(c,c) == "1"
end