Getting text input from the user.

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
PatDeer
Prole
Posts: 1
Joined: Tue Oct 20, 2015 1:58 am

Getting text input from the user.

Post 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..
User avatar
s-ol
Party member
Posts: 1080
Joined: Mon Sep 15, 2014 7:41 pm
Location: Milan, Italy
Contact:

Re: Getting text input from the user.

Post 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

s-ol.nu

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], Semrush [Bot] and 3 guests