Page 1 of 1

Cannot print() from lua code to windows 10 powershell

Posted: Sun Nov 08, 2020 6:23 pm
by leankyr
download.1.png
download.1.png (267.4 KiB) Viewed 5424 times
Hello fellows,

I found this so post about printing to powershell?? LUA console? however I cannot grasp what it is saying.
https://stackoverflow.com/questions/421 ... tom-editor.
Should I download this console?? should I try to sth else? Should the Lua console come built in with love2d?
On ubuntu there was no such problem, everything worked out of the box.

Cheers
leankyr

Re: Cannot print() from lua code to windows 10 powershell

Posted: Mon Nov 09, 2020 9:16 am
by ReFreezed
What exactly are you trying to do? PowerShell is just a command line tool - you don't print "to" it. If you just want to see the output of your program in a console window, run lovec.exe instead of love.exe (the former being the console version of LÖVE - in Windows there's a distinction between console programs vs windowed programs, unlike Linux).

And, as the SO post's answer mentions, Lua buffers output by default, so you probably want to put io.stdout:setvbuf("no") to the top of main.lua so you can see any output immediately.

Re: Cannot print() from lua code to windows 10 powershell

Posted: Mon Nov 09, 2020 9:55 am
by leankyr
Thank you sir!! Running lovec instead of love from the powershell worked. I just had not noticed the lovec application in the ProgramFIles/love/.

Small irrelevant note: As I can see you cannot add files to an answer right?

Re: Cannot print() from lua code to windows 10 powershell

Posted: Mon Nov 09, 2020 9:58 am
by nikneym
You have to change your build system in order to do that. Go to Tools > Build System > New Build System... in Sublime Text and paste:

Code: Select all

{
    "selector": "source.lua",
    "file_regex": "^Error: (?:[^:]+: )?([^: ]+?):(\\d+):() ([^:]*)$",
    "windows": {
        "cmd": ["lovec", "${folder:${file_path}}"],
        "shell": true
    },
}
then save and name it way you like. (maybe LOVE2D-Console) Next time when building your project, choose build system as LOVE2D-Console from Tools > Build System.

Also you can do the same thing by creating a conf.lua file and add t.console = true property. Check out config files.