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

And code

Started by Thomas9666, 24 May 2012 - 12:04 PM
Thomas9666 #1
Posted 24 May 2012 - 02:04 PM
Me again, how do I make a double if statement? like

local id, msg = rednet.receive()
if msg == "count" [and rs.getInput("left",true)] then
shell.run("count")
end
how do I code the and section of the if?
Lolgast #2
Posted 24 May 2012 - 02:20 PM
if (msg =="count" and rs.getInput("left", true)) then
shell.run("count")
end
The brackets around msg == "count" and rs.getInput("left", true) are optional, but are required if you want more advanced things, like (statement 1 or (statement 2 and statement 3))
Luanub #3
Posted 24 May 2012 - 09:41 PM
You dont need any brackets, you can simply do


if msg == "count" and rs.getInput("left") then -- you dont need the true for getInput, it will return either true or false
shell.run("count")
end