Using:
Code: Select all
require 'consolebox'
function love.load()
cb.load()
end
function love.draw()
cb.draw()
end
Code: Select all
cb.addMs(put string here)
Code: Select all
local utf8 = require("utf8")
cb = {}
function cb.load()
messages = {}
ms = -15
ms2 = 0
input = ""
end
function cb.draw()
if messages[ms] then love.graphics.print(messages[ms], 5, 5) end
if messages[ms+1] then love.graphics.print(messages[ms+1], 5, 20) end
if messages[ms+2] then love.graphics.print(messages[ms+2], 5, 35) end
if messages[ms+3] then love.graphics.print(messages[ms+3], 5, 50) end
if messages[ms+4] then love.graphics.print(messages[ms+4], 5, 65) end
if messages[ms+5] then love.graphics.print(messages[ms+5], 5, 80) end
if messages[ms+6] then love.graphics.print(messages[ms+6], 5, 95) end
if messages[ms+7] then love.graphics.print(messages[ms+7], 5, 110) end
if messages[ms+8] then love.graphics.print(messages[ms+8], 5, 125) end
if messages[ms+9] then love.graphics.print(messages[ms+9], 5, 140) end
if messages[ms+10] then love.graphics.print(messages[ms+10], 5, 155) end
if messages[ms+11] then love.graphics.print(messages[ms+11], 5, 170) end
if messages[ms+12] then love.graphics.print(messages[ms+12], 5, 185) end
if messages[ms+13] then love.graphics.print(messages[ms+13], 5, 200) end
if messages[ms+14] then love.graphics.print(messages[ms+14], 5, 215) end
if messages[ms+15] then love.graphics.print(messages[ms+15], 5, 230) end
love.graphics.print(input, 5, 255)
end
function cb.addMs(message)
messages[ms2] = message
if ms2 > ms-15 then ms = ms+1 end
ms2 = ms2+1
end
function cb.mp(x,y, button)
if button == "wu" then
ms = ms - 1
elseif button == "wd" then
ms = ms + 1
end
end
function cb.kp(key)
if key == "return" then
messages[ms2] = input
if ms2 > ms-15 then ms = ms+1 end
ms2 = ms2+1
input = ""
elseif key == "backspace" then
byteoffset = utf8.offset(input, -1)
input = string.sub(input, 1, byteoffset - 1)
else
input = input..key
end
end
Code: Select all
cb.mp(x, y, key)
Code: Select all
function love.mousepressed(x, y, key)
Code: Select all
cb.kp(key)
Code: Select all
function love.keypressed(key)