i dont know what am i doing wrong here is it possible for someone to help me finish this
i want the text to end exactly where the background ends and i tried the normal ways and yet didn't work
keeps on giving me errors all the time????
function love.load()
--from where to type
input ="input: "
text = "type here only"
end
function love.textinput(t)
text = text .. t
end
function love.draw()
--box
love.graphics.setColor(200,0,0,255)
love.graphics.rectangle("fill",0,0,500,20)
--text
love.graphics.setColor(255,255,255,255)
love.graphics.print(input,0,0)
love.graphics.printf(text, 40, 0, love.graphics.getWidth())
end
function love.keypressed( key, unicode )
if unicode > 31 and unicode < 127 then -- here is my problems it wont stop where box end that's where needs to end input text--
text = text .. string.char(key)
end
if key == "backspace" then
text = text:sub(1,-2)
end
end
if unicode > 31 and unicode < 127 then -- here is my problems it wont stop where box end that's where needs to end input text--
text = text .. string.char(key)
end
Second, you have a box of 500 characters long, and you want to do what?
You want to make the text that doesn't fit in the box invisible, so it doesn't look ugly
function love.draw()
--box
love.graphics.setColor(200,0,0,255)
love.graphics.rectangle("fill",0,0,500,20)
--text
love.graphics.setColor(255,255,255,255)
love.graphics.setScissor( 0, 0, 500, 20 )
love.graphics.print(input,0,0)
love.graphics.printf(text, 40, 0, love.graphics.getWidth())
love.graphics.setScissor()
end
You actually want the typing to stop. Well that's a bit harder. You see, you left 500 - 40 = 460 pixels of space, but how many characters is that? That depends on the font and which characters.