mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-07-04 08:30:24 +02:00
Make get_bit simpler again
This commit is contained in:
@ -163,12 +163,9 @@ function mesecon.getbinstate(nodename, states)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function mesecon.get_bit(binary,bit)
|
function mesecon.get_bit(binary,bit)
|
||||||
|
bit = bit or 1
|
||||||
local len = binary:len()
|
local len = binary:len()
|
||||||
if bit then
|
if bit > len then return false end
|
||||||
if bit > len then return false end
|
|
||||||
else
|
|
||||||
bit = 1
|
|
||||||
end
|
|
||||||
local c = len-(bit-1)
|
local c = len-(bit-1)
|
||||||
return binary:sub(c,c) == "1"
|
return binary:sub(c,c) == "1"
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user