Sublime text - is it possible to have live console output?

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
Johannes
Prole
Posts: 18
Joined: Sat Jun 08, 2013 6:51 pm

Sublime text - is it possible to have live console output?

Post by Johannes »

Here's a quick question for any Sublime Text 2 users


For my Löve projects I'm using this build script:

Code: Select all

{
	"selector": "source.lua",
	"cmd": ["/Applications/love.app/Contents/MacOS/love", "$filepath"]
}
(this is for mac of course, you can check this page on the wiki for the corresponding windows script)

It works great, but I noticed that when I use print() in my code I don't see the output until I've closed the löve.app window.

So for example, when I run the simple code:

Code: Select all

function love.load()
	love.graphics.setColor(255,255,255,255)
	love.graphics.print(_VERSION, 100, 100)

	for var = 0, 10, 1 do
		print("test: " .. var)
	end
end
Which displays the Lua version in the Löve.app window and outputs the following in the sublime text console:

Code: Select all

test: 0
test: 1
test: 2
test: 3
test: 4
test: 5
test: 6
test: 7
test: 8
test: 9
test: 10
[Finished in 2.9s]
but not until I actually closed the window (which as you can see there took me 2.9 seconds)

When I run the program manually from the terminal or when using my script file the terminal shows the print output live as it happens:
iI3hUHf.png
iI3hUHf.png (38.69 KiB) Viewed 300 times

Is there a way to make the output display live in sublime text 2 as well?
User avatar
Johannes
Prole
Posts: 18
Joined: Sat Jun 08, 2013 6:51 pm

Re: Sublime text - is it possible to have live console outpu

Post by Johannes »

Ah, I found the answer on Stack Overflow

You can make the output display live by adding the following code in your main.lua file:

Code: Select all

io.stdout:setvbuf("no")
User avatar
verilog
Citizen
Posts: 97
Joined: Thu Nov 03, 2011 3:15 am
Contact:

Re: Sublime text - is it possible to have live console outpu

Post by verilog »

Interesting, I'll make sure to check this out, thanks for sharing! :D
User avatar
Philbywhizz
Prole
Posts: 24
Joined: Mon May 13, 2013 3:17 am
Location: Brisbane, Australia
Contact:

Re: Sublime text - is it possible to have live console outpu

Post by Philbywhizz »

That's a very handy tip

Thanks! :awesome:
Philbywhizz.com - a blog too far...
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: Sublime text - is it possible to have live console outpu

Post by scutheotaku »

I'm using Sublime Text 2 and am getting "live" console output from LOVE just fine, and I don't have to add anything to my main.lua or do anything else special.

Here is my build script (I'm on Windows):

Code: Select all

{
    "folders": [
        {
            "path": "./"
        }
    ], 
    "build_systems": [
        {
            "cmd": [
                "love2d", 
                "--console", 
                "$project_path"
            ], 
            "name": "LOVE", 
            "target": "run_love2d"
        }, 
        {
            "cmd": [
                "love2d_jit_dll", 
                "$project_path"
            ], 
            "name": "LOVE JIT Dll", 
            "target": "run_love2d"
        }
    ]
}
Post Reply

Who is online

Users browsing this forum: Bing [Bot], MrFariator and 151 guests