Created
October 5, 2019 19:28
-
-
Save clarvalon/cf0983ca926bc9251f8cdc2077b30d9c to your computer and use it in GitHub Desktop.
ScreenShot.asc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use in script as follows to trigger screenshots being saved | |
SetScreenshotMode("EVERYFRAME"); | |
// ---------------------------------- | |
// ScreenShot.ash | |
import void SetScreenshotMode(String mode); | |
// ---------------------------------- | |
// ScreenShot.asc | |
String previousValue; | |
int count = 0; | |
Overlay* overlay; | |
String screenshotMode; | |
void SetScreenshotMode(String mode) | |
{ | |
screenshotMode = mode; | |
} | |
void UpdateCountAndOverlay(bool showOverlay) | |
{ | |
count += 1; | |
if (!showOverlay) | |
return; | |
String text = String.Format("%04d", count + 1); | |
overlay.SetText(50, 0, 65535, text); | |
} | |
void ScreenGrabOnChange(String mode, bool showOverlay) | |
{ | |
if (previousValue == null) | |
previousValue = ""; | |
if (screenshotMode == null) | |
return; | |
if (overlay == null && showOverlay) | |
overlay = Overlay.CreateTextual(2, 2, 50, eFontFont0, 1, ""); | |
if (mode == "PLAYER") | |
{ | |
String newValue = String.Format("%d %d %d %d", player.x, player.y, player.View, player.Loop); | |
if (newValue != previousValue) | |
{ | |
UpdateCountAndOverlay(showOverlay); | |
previousValue = newValue; | |
newValue = String.Format("%04d x%d y%d v%d l%d", count, player.x, player.y, player.View, player.Loop); | |
String fileName = String.Format("player %s.BMP", newValue); | |
SaveScreenShot(fileName); | |
} | |
} | |
else if (mode == "PLAYERFRAME") | |
{ | |
String newValue = String.Format("%d %d %d %d %d", player.x, player.y, player.View, player.Loop, player.Frame); | |
if (newValue != previousValue) | |
{ | |
UpdateCountAndOverlay(showOverlay); | |
previousValue = newValue; | |
newValue = String.Format("%04d x%d y%d v%d l%d f%d", count, player.x, player.y, player.View, player.Loop, player.Frame); | |
String fileName = String.Format("playerframe %s.BMP", newValue); | |
SaveScreenShot(fileName); | |
} | |
} | |
else if (mode == "EVERYFRAME") | |
{ | |
UpdateCountAndOverlay(showOverlay); | |
String fileName = String.Format("everyframe %04d.BMP", count); | |
SaveScreenShot(fileName); | |
} | |
} | |
function repeatedly_execute_always() | |
{ | |
ScreenGrabOnChange(screenshotMode, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment