Page 1 of 1

Keyboard input in 0.8.0

Posted: Wed May 13, 2015 10:35 pm
by Periwasmarkedasspam
Im trying to get input from keyboard, but I need to do this in 0.8.0 (I have to do a game for my School and the Laptops are Debian which are stuck on the 0.8.0 version)

Im supossed to get to the "recordscore" and then, enable input for typing 3 chars (Like some old arcades), and what i have is this

Code: Select all

	function love.keypressed(key)
		...
		elseif state == "recordscore" then
			if key == "backspace" then
				recordName = ""
			else
				recordName = recordName .. key 
			end
		...
	end
if you need more bits of code / the file just ask... I need this Asap :D

Re: Keyboard input in 0.8.0

Posted: Wed May 13, 2015 10:54 pm
by Jeeper
What do you mean "stuck on the 0.8"? I am not a Linux guy, but I am quite sure that 0.9.2 runs without issues on Linux.

Re: Keyboard input in 0.8.0

Posted: Thu May 14, 2015 12:42 am
by veethree
I'm pretty sure your current code should kinda work. The proper way in 0.8.0 would be something like this:

Code: Select all

function love.keypressed(key, unicode)
	...
	elseif state == "recordscore" then
		if unicode > 31 and unicode < 127 then
			recordName = recordName..string.char(unicode)
		end
	end
	...
end

Re: Keyboard input in 0.8.0

Posted: Thu May 14, 2015 5:30 am
by arampl
Jeeper wrote:What do you mean "stuck on the 0.8"? I am not a Linux guy, but I am quite sure that 0.9.2 runs without issues on Linux.
Maybe he is allowed to use only installed packages or packages from "official" repositories which have only 0.8.0 version.

Re: Keyboard input in 0.8.0

Posted: Thu May 14, 2015 6:43 am
by Periwasmarkedasspam
Thanks for the help! Now it works