Page 1 of 1

Forced Screenshots?

Posted: October 24th, 2009, 5:12 pm
by Baconius
Hey everyone,

My attempts to get cube2 to spit out a text file to record player stats hasn't been going as planned, though I thought of a potential workaround. Does anyone know of a script that could make a screenshot with a timestamp under certain conditions? Basically, when a player dies or completes a level could Cube make a new screenshot that doesn't overwrite an old one, in some sort of a series (like screenshot1, 2, 3, etc.). Or maybe place these screenshots in a folder with the players name? Any help is appreciated.

-B

Re: Forced Screenshots?

Posted: October 27th, 2009, 11:20 am
by Hirato
you could take one every few seconds or so; but this is far from optimal really

do to the setup you described, you'd have to create scripts to save screenshots in the appropriate places with the appropriate names; by default the name is totalmillis.png, totalmillis being the amount of milliseconds the program has been running (which is usually changes fast enough to avoid problems)

Re: Forced Screenshots?

Posted: October 28th, 2009, 9:09 am
by Mike
I don't know how you'd make it not overwrite a new screenshot, I've seen it done in various image capturing programs, maybe you could find some inspiration from an open source image capture program.

For taking a screenshot at the end of the game I think you'd be able to do something like this - trigger end of the game, (endsp), sleep, screenshot sleep mapchange whatever the new map is. I'm not sure on the exact syntax of what that code would be checking out my mapchange.cfg and map in packages/base would be a good start. Just screenshot in there actually might even work. Take care!
-mike

Re: Forced Screenshots?

Posted: October 28th, 2009, 10:59 am
by Obsidian
Making it not overwrite a previous screenshot would make me think that the best way to write it is to choose a unique name. Now, you can do it based off of the current UNIX timestamp, or you could use something like a hash for the contents of the image itself (md5, sha1, and so on). I would think having it UNIX timestamp based though would be much more efficient, as I know from experience how long it can take to get an md5 checksum of a large file.

Re: Forced Screenshots?

Posted: October 28th, 2009, 1:04 pm
by Mike
Right I never even thought about how each map would have a different map.cfg so you could just make the screenshot a different name in each one. I would imagine that /screenshot nameofscreen would produce a unique name though I haven't tested it. Here is some interesting code thanks for the Cube 2 documents:

Code: Select all

screenshot

Writes out "screenshotN.bmp", where N is the number of milliseconds since cube was launched (default key = F12).
A little modified example :

// do a pretty screenshot (hiding HUD and all)
MPscreenshot = [
    phh = $hidehud
    phs = $hidestats
    phg = $hudgun
    hudgun 0
    hidestats 1
    hidehud 1
    sleep 2 screenshot
    sleep 3 [hudgun $phg; hidestats $phs; hidehud $phh;echo SCREENSHOT made]
]
You probably don't need the hudgun stuff :) So it looks like in general that the screenshots will be different each time though it will have a number depending on how long you were in game. I don't think they'd overwrite themselves in general. In any case here is some neat stuff to think about. I think for your purposes just having "screenshot" in there would be fine. You could also search the source code and customize the output of the screenshot command as well. Take care!
-mike

Re: Forced Screenshots?

Posted: October 31st, 2009, 7:55 pm
by Baconius
Wow guys, thanks for all the help on this. It seems like this could be useful for a lot of things.