I have a function that allows me to add and remove character in a line by i want to limit it to around 10 characters
function love.keypressed(key, unicode)
if key == "backspace" or key == "delete" then
player = string.sub(player, 1, #player-1)
elseif unicode > 31 and unicode < 127 then
player = player .. string.char(unicode)
end
end
Could you not just restrict the length by not adding to the string if it's too long? Or were you after something else?
function love.keypressed(key, unicode)
if key == "backspace" or key == "delete" then
player = string.sub(player, 1, #player-1)
elseif unicode > 31 and unicode < 127 and #player <=10 then
player = player .. string.char(unicode)
end
end