SRL Archive - OSR Help

if IsUpText problem.


Tehmoo

2013-06-14 20:56:04

Alright so my problem really isn't UpText or maybe it is. I made a thread around monday asking for help for a private server. I was told that I needed to make my own font cause reg rs and rsps have different font types so the script can't read the private server text.

So I made the font and made a file for it in the fonts folder, I already called loadfont with the directory of the folder and all I need to know is what do I do next in order for it to check the font for UpText for the private server. I was trying to wrap my head around it but can't seem to do it.

bob_dole

2013-06-14 21:18:48

Well, let's take a look at the normal IsUpText function.

It defers to a few other functions before we get to the core function, 'P07_GetUpText'. In order to determine if the uptext contains what you are looking for, we need to fetch the actual up text. The code is:


Function P07_GetUpText: String;
Var
WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
Begin
WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'UpChars07');
BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'UpChars07');
YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'UpChars07');
OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'UpChars07');
FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
Result:=FoundText;
End;

You need to first copy and paste to create a completely new function. Name this function appropriately and it then looks like you need to change WhiteT, BlueT, YellowT and OrangeT to retrieve the text. First change the UpChars07 to the name of the font that you created. Then load the private server into your client and use the color picker/position tool to find out what pixel coordinates the text starts and ends at. The start coordinates are the upper left corner of the text; pick the pixel located directly where the text starts. The end coordinates are the bottom right corner of the text; pick the pixel located at the very end on the bottom.

The next two arguments (0 and 5) seem to be the minimum and maximum vertical spacing which for this particular purpose is irrelevant. I would just leave those as they are and then find the horizontal spacing between each letter (probably the same: 1) and then find the color of the uptext as found on your private server. The next argument is the tolerance, which you may need to do some experimenting on to find the correct values for each of the colors.

After you change the font to your custom made font and find the coordinates at which the uptext ends and starts, you should be able to successfully retrieve the up text from your private server.

A simple test script will help you in setting all of the arguments correctly.


program RSPS_Uptext;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}

Function RSPS_GetUpText: String;
Var
WhiteT,BlueT,YellowT,OrangeT,FoundText: String;
Begin
WhiteT:=GetTextAtExWrap(8, 8, 80, 21, 0, 5, 1, 14541281, 55, 'RSPSFont'); // These functions need to be editted to fit the server.
BlueT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 13423640, 65, 'RSPSFont'); // These functions need to be editted to fit the server.
YellowT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 1235160, 40, 'RSPSFont'); // These functions need to be editted to fit the server.
OrangeT:=GetTextAtExWrap(35, 8, 150, 21, 0, 5, 1, 4687583, 53, 'RSPSFont'); // These functions need to be editted to fit the server.
FoundText:=WhiteT + ' ' + BlueT + YellowT + OrangeT;
FoundText:= ReplaceWrap(FoundText, '.', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '/', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '\', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, ',', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '*', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '^', '',[rfReplaceAll]);
FoundText:= ReplaceWrap(FoundText, '"', '',[rfReplaceAll]);
Result:=FoundText;
End;

begin
setupSRL;
writeLn (RSPS_GetUpText);
end.

After you manage to retrieve the up text from the private server, you can start creating clone functions of the ones that SRL has for the 07 servers.



function RSPS_IsUpText(UpText: string): Boolean;
begin
Result := (Pos(UpText, RSPS_GetUpText) > 0);
end;

function RSPS_IsUpTextEx(Text: String): Boolean;
begin
Text := Replace(Text, '?', '.');
Result := ExecRegExpr('.*'+Text+'.*', RSPS_GetUpText);
end;

function RSPS_IsUpTextRe(RegEx: String): Boolean;
begin
Result := ExecRegExpr(RegEx, RSPS_GetUpText);
end;

And that should be everything you need to start using Up Text functions on your private server. Give it a try and tell me how it goes.