Jump to content




Run 2 checks in a if statement?


  • You cannot reply to this topic
3 replies to this topic

#1 THC_Butterz

  • Members
  • 10 posts
  • LocationVirginia, US

Posted 08 December 2013 - 12:49 PM

how would i run multiple, 2 or more, checks in a if statement?
for example:

f = false
t1 = redstone.getBundledInput("back", 1)
t2 = redstone.getBundledInput("back", 2)
t3 = redstone.getBundledInput("back", 4)
if t2 ~= f and t3 ==f then
print("orange wire active")
end


#2 awsmazinggenius

  • Members
  • 930 posts
  • LocationCanada

Posted 08 December 2013 - 12:52 PM

Do you mean an elseif, or more then one if statement? Please make yourself a little more clear.

#3 electrodude512

  • Members
  • 167 posts
  • LocationEastern USA

Posted 08 December 2013 - 12:57 PM

I'm not really sure if you mean an elseif or a this and that, but this does both:

t1 = redstone.getBundledInput("back", 1)
t2 = redstone.getBundledInput("back", 2)
t3 = redstone.getBundledInput("back", 4)
if t2 and not t1 and not t3 then
print("orange wire active")
elseif t1 and not t2 and not t3 then
print("white wire active")
elseif t3 and not t1 and not t2 then
print("magenta wire active")
else
print("no wire active")
end


#4 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 08 December 2013 - 01:16 PM

Yeah, that's not the right usage of getBundledInput anyway, and the solution you want is overcomplicating the issue.

rs.getBundledInput() (rs is just short for redstone) does not accept a second number, and returns the actual input. To test what that input actually is, you use colors.test().
local input = rs.getBundledInput('back')

if colors.test(input, colors.white) then
  --# white wire active
elseif colors.test(input, colors.orange) then
  --# orange wire active
elseif colors.test(input, colors.magenta) then
  --# etc.
end

Edited by Kingdaro, 08 December 2013 - 01:16 PM.






2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users