SRL Archive - OSR Help

Need help with Ollybest's Save screen functions


bud_wis_er_420

2013-02-21 05:29:08

I been trying to get these to work. It seems like it works but I can't find any screen shots. I tried editing the path, but that didn't work. If I reading everything right this script should take a screen shot and save it to the simba/Scripts Folder.

program new;
{$DEFINE SMART}
{$I SRL/SRL.Simba}
{$i ObjectDTM\ObjDTMInclude.simba}

var
x,y,color: integer;

// By Ollybest
Function rs_TakeScreen(s: string): Integer;
var
tpa: TPointArray;
TIA, TIA2, TIA3: TIntegerArray;
w, h: Integer;
atpa: T2DPointArray;
begin
Result := BitmapFromClient(MSX1, MSY1, MSX2, MSY2);
setBitmapSize(Result, 673, 350);
setLength(atpa, 3);

TPAFromBoxWrap(mmBox, atpa[0]);
FilterPointsDist(atpa[0], 0, 76, MMCX, MMCY);
TPAFromBoxWrap(IntToBox(MSCX - 13, MSCY - 20, MSCX + 13, MSCY + 20), ATPA[1]);
TPAFromTextWrap(s, statchars, w, h, atpa[2]);

GetColorsWrap(atpa[0], TIA);
TIA2 := ColorsFromTPA(ATPA[1], clRed);
TIA3 := ColorsFromTPA(ATPA[2], clRed);
OffsetTPA(atpa[0], Point(-35, -6));
OffsetTPA(atpa[2], Point(2, +336))
MergeATPAWrap(ATPA, TPA);

try
fastSetPixels(Result, TPA, TIA+TIA2+TIA3);
except
writeln('rs_TakeScreen: Failed to set pixels, prehaps shutdown reason is too long!');
end;
end;
// By Ollybest
Procedure rs_SaveScreenshot(reason, savePath: string);
var
bmp, x: Integer;
begin
if (not(loggedIn)) then
Exit;

bmp := rs_TakeScreen(reason);
if FileExists(savePath + ' [' + ToStr(x) +']' + '.png') then
while FileExists(savePath + ' [' + ToStr(x) + ']' + '.png') do
Inc(x);

try
SaveBitmap(bmp, savePath + ' [' + ToStr(x) + ']' + '.png');
except
writeln('rs_TakeScreenshot: Failed saving screenshot');
finally
FreeBitmap(bmp);
end;
end;

// By Ollybest
Procedure shutdown(s: string);
var
path, name: string;
begin
path := AppPath + 'Scripts\';
name := 'Shutdown - '+ TheDate(Date_Day)+ ' ';
rs_SaveScreenshot(s, Path + Name);
end;

Begin
SetUpSRL;
//DeclarePlayers;
ObjDTM_Setup;
shutdown('1');
End.

bud_wis_er_420

2013-02-21 15:11:47

Anybody?


Also is there a way to remove TP's from an array that fall within a polygon instead of a box. ATM I'm using this.


Box := IntToBox(MSCX - 50, MSCY - 24, MSCX + 50, MSCY + 52);
TTPA := TPAFromBox(Box);
ClearTPAFromTPAWrap(arP, TTPA, arP);

but would be more accurate if I could remove the corners of the box.

Olly

2013-02-21 18:51:55

what do you want a polygon for?

@bud_wis_er_420

i luffs yeww

2013-02-21 19:06:31

From: bud_wis_er_420
Anybody?


Also is there a way to remove TP's from an array that fall within a polygon instead of a box. ATM I'm using this.


Box := IntToBox(MSCX - 50, MSCY - 24, MSCX + 50, MSCY + 52);
TTPA := TPAFromBox(Box);
ClearTPAFromTPAWrap(arP, TTPA, arP);

but would be more accurate if I could remove the corners of the box.


You could use InAbstractBox or TPAInATPA.

bud_wis_er_420

2013-02-21 21:09:05

From: Ollybest
what do you want a polygon for?

@bud_wis_er_420


Sry, meant Hexagon. Hayyyy, Olly how do I get your save screen functions to work? I can't believe you posted about the polygon without answering my main question, which was directed mainly at you since you created it. :duh:

From: i luffs yeww
You could use InAbstractBox or TPAInATPA.


Thx will look into that.

Sjoe

2013-02-21 21:10:17

Yeah he does that, quick answers and away lol

Olly

2013-02-21 21:26:17

From: bud_wis_er_420
I been trying to get these to work. It seems like it works but I can't find any screen shots. I tried editing the path, but that didn't work. If I reading everything right this script should take a screen shot and save it to the simba/Scripts Folder.


// By Ollybest
Procedure shutdown(s: string);
var
path, name: string;
begin
path := AppPath + 'Scripts\';
name := 'Shutdown - '+ TheDate(Date_Day)+ ' ';
if not DirectoryExists(Path) then
CreateDirectory(Path);

rs_SaveScreenshot(s, Path + Name);
end;



try that.

bud_wis_er_420

2013-02-21 21:33:39

From: Ollybest
try that.


Thx you very much, although I have no idea why that made a difference because the path I was trying to save to already existed, but it did. Hmmm Thx again.