Page 1 of 1

[Resolved] Need Help with Console

Posted: Wed Jan 30, 2013 2:17 am
by Rectar2
Hello, all.
I'm working on adding a debug console to the game. I got it open and started adding print() functions everywhere. But I need help reading input from the console. Right now I'm using io.read(), but I need it not to pause everything in the game while it's reading. Is there any other function for this?

Re: Need Help with Console

Posted: Wed Jan 30, 2013 6:03 am
by substitute541
It's a good idea not to use Lua's File I/O functions. Plus, please clarify what you mean by "Console" in the title, because, there's a window called "lua console" that pops up if you add the "t.console = true" line in your conf file. For the Debugging Console, I think you should use the Lua console I said earlier. Also, if you think you should really use the debugging console ingame, you can read input by just reading the text the user adds to the text box (if there is any) by checking if the user presses the "enter" key (or sends the "\n" char but nvm). Here's a sample code.

Code: Select all

function love.keypressed(key)
    if key != "return" then
        if key != backspace then
            input = input .. key
        else
            string.sub(blahblehbloh) -- sorry, I forgot the parameters of string.sub, try looking at the Lua 5.1 reference
        end
    elseif key == "return" then
       send_string(input)
    end
end

Re: Need Help with Console

Posted: Wed Jan 30, 2013 7:12 am
by Nixola
I use Bartbes' Repler for that. I can't make it work with conf.lua though, I have to call love._openConsole() inside love.load to make it work

EDIT: the input Repler receives is just Lua though, you'll have to create and use a function

Re: Need Help with Console

Posted: Wed Jan 30, 2013 4:55 pm
by Rectar2
Nixola wrote:I use Bartbes' Repler for that. I can't make it work with conf.lua though, I have to call love._openConsole() inside love.load to make it work

EDIT: the input Repler receives is just Lua though, you'll have to create and use a function
Thank you. That worked fine.