This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheHappyBukkit's profile picture

XOR Function

Started by TheHappyBukkit, 28 August 2012 - 11:20 AM
TheHappyBukkit #1
Posted 28 August 2012 - 01:20 PM
Hi all,

I am looking for a XOR function. I remember seeing one somewhere but the search won't let me search for XOR.

Thank you!
sjele #2
Posted 28 August 2012 - 01:38 PM

while true do
if rs.getInput("right") and rs.getInput("left") then
rs.setOutput("back" false)
elseif rs.getInput("right") and not rs.getInput("left") then
rs.setOutput("back", true")
elseif not rs.getInput("right") and rs.getInput("left") then
rs.setOutput("back", true")
end
end

That might work
TheHappyBukkit #3
Posted 28 August 2012 - 10:32 PM

while true do
if rs.getInput("right") and rs.getInput("left") then
rs.setOutput("back" false)
elseif rs.getInput("right") and not rs.getInput("left") then
rs.setOutput("back", true")
elseif not rs.getInput("right") and rs.getInput("left") then
rs.setOutput("back", true")
end
end

That might work

Thanks, but I was more looking for a function, like XOR(a, :D/>/>. Do you know how to do that?
MysticT #4
Posted 28 August 2012 - 11:10 PM

bit.bxor(a, :D/>/>
TheHappyBukkit #5
Posted 29 August 2012 - 12:06 AM

bit.bxor(a, :D/>/>

That was easy. Thx!