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

Computer slot changing (io.read())

Started by calmilamsy, 06 April 2013 - 06:05 AM
calmilamsy #1
Posted 06 April 2013 - 08:05 AM
I am trying to make a slot option using io.read() but it doesnt seem to work:-

print("enter slot number")
g = io.read
turtle.select(g)


then it says

number expected :(/>
if you want to see the whole code then tell me
Telokis #2
Posted 06 April 2013 - 08:17 AM
You have to do something like

turtle.select(tonumber(g))

Because read returns a string !
calmilamsy #3
Posted 06 April 2013 - 08:48 AM
You have to do something like

turtle.select(tonumber(g))

Because read returns a string !

thanks! now i can do stuff now :D/>
remiX #4
Posted 06 April 2013 - 09:24 AM
You can also do it in one line :)/>

turtle.select( tonumber( read() ) )

io.read is not needed because you can just call read.

Note: read() / io.read() always returns a string