Jump to content




[SOLVED] Issue with conditionals


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

#1 retrotails

  • New Members
  • 2 posts

Posted 11 May 2013 - 04: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


#2 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 11 May 2013 - 04:49 PM

Split into new topic.

Use tonumber(read()). Strings aren't numbers.

#3 retrotails

  • New Members
  • 2 posts

Posted 11 May 2013 - 04:54 PM

View PostLyqyd, on 11 May 2013 - 04:49 PM, said:

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?

#4 Zoinky

  • Members
  • 144 posts
  • LocationWellington, New Zealand

Posted 11 May 2013 - 07:25 PM

View Postretrotails, on 11 May 2013 - 04:54 PM, said:

Also is input always a string?

Yep.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users