문제

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
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top