SRL Archive - General

Fc Detection with simba


HoMoReXuaL

2012-07-08 18:17:30

This is what the code that Brandon gave me thankfully for checking who said a certain thing -


Brandon
SRL Member

King Black Dragon


Posts: 2,570
Join Date: Feb 2011
Location: Canada





07-06-2012, 04:54 PM
Simba Code:
{$I SRL/SRL.Simba}

{*
Author: Brandon.

Get's The Player's Name at the specified Line.
*}
Function GetPlayerName(Line: Integer): String;
var
TPA: TPointArray;
B: TBox;
P: TPoint;
Text: String;
begin
P:= TextCoords(Line);
If (FindColorsTolerance(TPA, CLBLACK, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(TPA);
Text := Trim(GetTextAtExWrap(B.X1 - 1, P.Y, B.X2 + 1, P.Y + 13, 0, 5, 2, CLBLACK, 0, SmallChars));
Result:= Copy(Text, 0, High(Text) - 2);
end;
end;

{*
Author: Brandon.

Gets the name of the player who said the text.
*}
Function GetPlayerWhoSaid(Text: String): String;
var
TPA: TPointArray;
P: TPoint;
B: TBox;
I: Integer;
begin
For I:= 1 To 8 Do
begin
P := TextCoords(I);
If (FindColorsTolerance(TPA, CLBLUE, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(TPA);
If (Text = Trim(GetTextAtExWrap(B.X1 - 1, P.Y, B.X2 + 1, P.Y + 13, 0, 5, 2, CLBLUE, 0, SmallChars))) then
begin
Result:= GetPlayerName(I);
Break;
end;
end;
end;
end;

begin
SetupSRL;

writeln(GetPlayerWhoSaid('Brandon'));
end.



it works pretty well but now i am trying to make it work in the friends chat in the lobby, and in the lobby, the names are White and the text is Red, i was wondering what code i would need to change those colors because i tried changing it to CLWHITE and CLRED and it does not work, Any help would be great, thanks!

Le Jingle

2012-07-08 18:23:53

Brandon's code works for use in-game. So if you wanted you use what he posted, you would need to also tweak the params of where the text is, not just the color (color is easy, use the eye-drop tool in Simba, to pick a new color -ideally the color of the lobby text- and use that # in place of clWhite/clRed/etc.) I'd also put the code of Brandon's you posted in simba tags to help onlookers read the code properly!

HoMoReXuaL

2012-07-08 18:29:15

Darn, thanks haha but im not sure how his code quite works since im new to this, so im not quite sure i know how to fix this..

Kasi

2012-07-08 20:08:12

Them Lines

If (FindColorsTolerance(TPA, CLBLUE, MCX1, P.y, MCX2, P.y + 13, 0)) then
begin
B := GetTPABounds(TPA);
If (Text = Trim(GetTextAtExWrap(B.X1 - 1, P.Y, B.X2 + 1, P.Y + 13, 0, 5, 2, CLBLUE, 0, SmallChars))) then
begin

Change CLBLUE to your color (there are 2 instances), and use SIMBA tags, makes code alot easier to read