Page 1 of 1

Getting text input from the user.

Posted: Tue Oct 20, 2015 2:05 am
by PatDeer
I've read that using io.read() will get input in lua itself, but does love have it's own type of use or format for it?
I'm trying to execute it inside of an if statement, but I'm sure it's not activating. (Or I'm doing it wrong :death: )

Code: Select all

if path == 0 then
		love.graphics.print("Omitted",0,0)
		pName = io.read()
	end
EDIT: I should maybe specify that the input is for the user to type their name out, or a sentence and save it to a string, eheh..

Re: Getting text input from the user.

Posted: Tue Oct 20, 2015 10:09 am
by s-ol
PatDeer wrote:I've read that using io.read() will get input in lua itself, but does love have it's own type of use or format for it?
I'm trying to execute it inside of an if statement, but I'm sure it's not activating. (Or I'm doing it wrong :death: )

Code: Select all

if path == 0 then
		love.graphics.print("Omitted",0,0)
		pName = io.read()
	end
EDIT: I should maybe specify that the input is for the user to type their name out, or a sentence and save it to a string, eheh..
io.read reads from the command line / terminal which usually doesn't even exist in a packaged LÖVE application. Read the löve documentation, not the lua one: https://love2d.org/wiki/love.textinput https://love2d.org/wiki/love.keypressed