Can no longer take screenshots with last love2d version

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
mojojojo
Prole
Posts: 4
Joined: Sun Sep 02, 2018 6:15 pm

Can no longer take screenshots with last love2d version

Post by mojojojo »

Hello I'm stuck on a problem that should be easy to overcome. I used to run a script that take screenshots of the window on my old computer which was unable to run love2d past the 10.0 version. Now I have a new computer and the last love2d ans apparently I have to use love.graphics.captureScreenshot instead of love.graphics.newScreenshot.

But when I do that there's no image in the target folder folder. In my old code I have another line screenshot:encode('png', os.time() .. '.png') but if I use it now it crashes saying the golbal "screenshot" in a nil value BUT there's is an image created, an actual screenshot of the crash message.

I'm oblivious to the problem and I'd appreciate your help. The attached code is short and very easy to understand.
Attachments
main.lua
(444 Bytes) Downloaded 159 times
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Can no longer take screenshots with last love2d version

Post by raidho36 »

The screenshot capture function returns nothing, it just takes a screenshot and saves it to the filesystem. No additional action is needed. Your followup line causes a crash because you're trying to call a function on nil object (because capture screenshot didn't return anything). The screenshot is that of the error message, because that's what was rendered at the end of that frame.
User avatar
zorg
Party member
Posts: 3441
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Can no longer take screenshots with last love2d version

Post by zorg »

While it's true that the captureScreenshot method doesn't return anything directly, you can also give it a Channel or a function as well; the former's only interesting if you work with threads, the latter can be more useful since captureScreenshot will call that supplied function with an ImageData of the screenshot when it finished capturing it... but for your use-case, the filename variant is fine.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
mojojojo
Prole
Posts: 4
Joined: Sun Sep 02, 2018 6:15 pm

Re: Can no longer take screenshots with last love2d version

Post by mojojojo »

I didn't understand how channels works but love.image.newImageData worked so I can just draw the screen to a virtual one (ImageData) then make a screenshot out of it. The good news on top of that is that I can manipulate pixels if I ever want to add effects.

I'll keep the channel thing in mind when I'm good enough in programming to use it. Thank you people.
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 123 guests