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

io.read() help

Started by pinksheep00, 08 March 2013 - 10:01 PM
pinksheep00 #1
Posted 08 March 2013 - 11:01 PM
Title: io.read() help


function foo( xPos, yPos, var )
	term.setCursorPos( xPos, yPos )
	????
end

readIn( 3, 3, y)
print(y)

how can I make it so it set the cursor position to xPos, yPos and then make a variable "y" and set it to io.read() then prints whatever you type?
Lyqyd #2
Posted 09 March 2013 - 06:44 AM
Split into new topic.

Replace your question marks with `return read()` and replace `readIn(3,3,y)` with `y = readIn(3,3)`. Return values are the thing to use for this.
remiX #3
Posted 09 March 2013 - 07:20 AM
Split into new topic.

Replace your question marks with `return read()` and replace `readIn(3,3,y)` with `y = readIn(3,3)`. Return values are the thing to use for this.

Yeah, so make it like this:
function foo( xPos, yPos)
        term.setCursorPos( xPos, yPos )
        return read()
end

local input = readIn( 3, 3 )
print( input )

'return' will return what you type for the read()

Like when you use rednet.receive(), you use id, msg, dist = rednet.receive() because when a message is received, it returns the values