Jump to content




XOR Function


4 replies to this topic

#1 TheHappyBukkit

  • New Members
  • 13 posts

Posted 28 August 2012 - 12: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!

#2 sjele

  • Members
  • 334 posts
  • LocationSomewhere on the planet called earth

Posted 28 August 2012 - 12: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

#3 TheHappyBukkit

  • New Members
  • 13 posts

Posted 28 August 2012 - 09:32 PM

View Postsjele, on 28 August 2012 - 12:38 PM, said:

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?

#4 MysticT

    Lua Wizard

  • Members
  • 1,597 posts

Posted 28 August 2012 - 10:10 PM

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


#5 TheHappyBukkit

  • New Members
  • 13 posts

Posted 28 August 2012 - 11:06 PM

View PostMysticT, on 28 August 2012 - 10:10 PM, said:

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

That was easy. Thx!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users