[Resolved] Need Help with Console

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Rectar2
Prole
Posts: 5
Joined: Wed Jan 30, 2013 2:09 am

[Resolved] Need Help with Console

Post 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?
Last edited by Rectar2 on Thu Jan 31, 2013 3:13 am, edited 1 time in total.
User avatar
substitute541
Party member
Posts: 484
Joined: Fri Aug 24, 2012 9:04 am
Location: Southern Leyte, Visayas, Philippines
Contact:

Re: Need Help with Console

Post 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
Currently designing themes for WordPress.

Sometimes lurks around the forum.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Need Help with Console

Post 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
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
Rectar2
Prole
Posts: 5
Joined: Wed Jan 30, 2013 2:09 am

Re: Need Help with Console

Post 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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 1 guest