Jump to content




item:13: attempt to compare number with string expected, got number


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

#1 Inumel

  • Members
  • 120 posts

Posted 09 May 2013 - 06:12 PM

Okay so this is my code



print("Select which slot you wish to use 1,16")
ic = read()
b = tonumber(ic)
x = turtle.getItemCount(B)/>
print("How many items do you want to use? 0,64")
z = read()
if x == z then
  rs.setOutput("left", true)
  sleep(5)
  rs.setOutput("left", false)
else
  if x > z then
  print("Too many items in slot 5")
  end
  if x < z then
  print("Not enough items in slot 5")
end
end

Running this, it works fine up until x > z(and i assume x< z), It gives me the error that is the title of this post.. Problem is, I am new, so I don't know how to work around this(Or fix it!)

So i come to you pros, and help is appreciated :)

#2 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 09 May 2013 - 06:42 PM

You have
getItemCount(B)/>/>/>/>
unstead
getItemCount(B)/>/>/>/>
:)/>/>/>

I've cleaned it up:
 print("Select which slot you wish to use 1,16") 
ic = tonumber(read() )
x = turtle.getItemCount(B)/>/>/>/>/> 
print("How many items do you want to use? 0,64") 
z = tonumber(read()) 
if x == z then 
rs.setOutput("left", true) 
sleep(5) 
rs.setOutput("left", false) 
elseif x > z then 
print("Too many items in slot 5") --why slot 5?
elseif x < z then print("Not enough items in slot 5") 
end

EDIT:
Damn emoticon detection -.-
the b in the second snippet has to be lowercase.

#3 Inumel

  • Members
  • 120 posts

Posted 09 May 2013 - 06:50 PM

View PostFreack100, on 09 May 2013 - 06:42 PM, said:

You have
getItemCount(B)/>/>/>
unstead
getItemCount(B)/>/>/>
:)/>

I've cleaned it up:
print("Select which slot you wish to use 1,16")
ic = tonumber(read() )
x = turtle.getItemCount(B)/>/>/>/>
print("How many items do you want to use? 0,64")
z = tonumber(read()) if x == z then
rs.setOutput("left", true)
sleep(5)
rs.setOutput("left", false)
elseif x > z then
print("Too many items in slot 5") --why slot 5?
end
if x < z then print("Not enough items in slot 5") end
end

EDIT:
Damn emoticon detection -.-
the b in the second snippet has to be lowercase.

Thanks for the help! :) it was slot 5 because that's what I had it set to, before I added the user input! I forgot to change, thanks!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users