4 Commits

Author SHA1 Message Date
b91fe92d13 Merge remote-tracking branch 'upstream/master' 2021-08-04 21:42:16 +02:00
e15c55c066 Handle getting out-of-bounds bits in get_bit (#574)
The binary state is not padded with zeroes, so they must be inferred.
2021-08-02 21:33:45 +02:00
6a87290ead Merge remote-tracking branch 'upstream/master' 2021-07-26 22:19:21 +02:00
db5879706d Fix on_placenode conductor turnon link direction (#572) 2021-07-24 18:40:43 +02:00
2 changed files with 4 additions and 2 deletions

View File

@ -16,7 +16,7 @@ mesecon.on_placenode = function(pos, node)
-- also call receptor_on if itself is powered already, so that neighboring
-- conductors will be activated (when pushing an on-conductor with a piston)
for _, s in ipairs(sources) do
local rule = vector.subtract(pos, s)
local rule = vector.subtract(s, pos)
mesecon.turnon(pos, rule)
end
--mesecon.receptor_on (pos, mesecon.conductor_get_rules(node))

View File

@ -164,7 +164,9 @@ end
function mesecon.get_bit(binary,bit)
bit = bit or 1
local c = binary:len()-(bit-1)
local len = binary:len()
if bit > len then return false end
local c = len-(bit-1)
return binary:sub(c,c) == "1"
end