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

[SOLVED] Issue with conditionals

Started by retrotails, 11 May 2013 - 03:37 PM
retrotails #1
Posted 11 May 2013 - 05:37 PM
Sometimes CC (Minecraft 1.5.1) tells me 1 == 2 and 2 ~= 2. When I run a basic program I have no issues, but with this code it comes up.
http://pastebin.com/wYf0prC0
This line

	if y == yx then
	  print(y .. ' equals ' .. yx)
	  t.digDown()
	  t.down()
	else
	  print(y .. ' does not equal ' .. yx)
	end
ends up outputting

1 does not equal 2
2 does not equal 2
If I change it to

	if not y == yx then
	  print(y .. ' does not equal ' .. yx)
	  t.digDown()
	  t.down()
	else
	  print(y .. ' equals ' .. yx)
	end
it'll say

1 equals 2
2 equals 2
Lyqyd #2
Posted 11 May 2013 - 05:49 PM
Split into new topic.

Use tonumber(read()). Strings aren't numbers.
retrotails #3
Posted 11 May 2013 - 05:54 PM
Split into new topic.

Use tonumber(read()). Strings aren't numbers.
That works. Love2D didn't do this so I didn't know what to do. Also is input always a string?
Zoinky #4
Posted 11 May 2013 - 08:25 PM
Also is input always a string?

Yep.