0

in my lua program, I want to check the sides for a redstone input (using a for loop to check). the last few lines are ment to print out ther result of the array, as a debug tool. the output is the side name followed by 0 (a true/false is expected). the data will be used later in the program.

thank you.

http://www.pastebin.com/0innMjcP

function array()
  a = {}
  for i=1, 6 do
    a[i] = {}

    for j=1, 2 do
      a[i][j] = 0
    end
  end
  a[1][1]= "front"
  a[2][1]= "back"
  a[3][1]= "left"
  a[4][1]= "right"
  a[5][1]= "top"
  a[6][1]= "bottom"
end

array()

for i=1, 6 do
  input=redstone.getInput(a[i][1])
  if input=="true" then
    a[2][2]="true"

  elseif input=="false" then
    a[3][2]="false"
  end
end
for i=1, 6 do
  print(a[i][1])
  print(a[i][2])
end

1 Answer 1

2

From the manual of redstone.getInput(), it returns a boolean, not a string, so this line

if input == "true" then

should be

if input == true then

The same for the elseif part.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.