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.
Can no longer take screenshots with last love2d version
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Can no longer take screenshots with last love2d version
- Attachments
-
- main.lua
- (444 Bytes) Downloaded 167 times
Re: Can no longer take screenshots with last love2d version
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.
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Can no longer take screenshots with last love2d version
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 True 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.
Re: Can no longer take screenshots with last love2d version
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.
I'll keep the channel thing in mind when I'm good enough in programming to use it. Thank you people.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests