SRL Archive - OSR Help

Finding Number in ChatText?


Sin

2012-06-19 11:56:53

Here's what I have so far.




function GetTaskAmount:Integer;
var
i,revAmount:Integer;
sAmount:String;
begin
if not FindBlackChatMessage('assign') then
exit;
for i := 1 to 300 do //300 is the max number of monsters she can assign
begin
sAmount := IntToStr(i);
if FindBlackChatMessage(sAmount) then
begin
writeLn(sAmount);
revAmount := StrToInt(sAmount);
end;
end;
end;



SRL Compiled in 0 msec
1
2
5
12
25
125
Successfully executed.

I was thinking of using High(revAmount) as the thing.

Is there any better way to do this?

putonajonny

2012-06-19 12:03:58

From: Shay
Here's what I have so far.




function GetTaskAmount:Integer;
var
i,revAmount:Integer;
sAmount:String;
begin
if not FindBlackChatMessage('assign') then
exit;
for i := 1 to 300 do //300 is the max number of monsters she can assign
begin
sAmount := IntToStr(i);
if FindBlackChatMessage(sAmount) then
begin
writeLn(sAmount);
revAmount := StrToInt(sAmount);
end;
end;
end;



SRL Compiled in 0 msec
1
2
5
12
25
125
Successfully executed.

I was thinking of using High(revAmount) as the thing.

Is there any better way to do this?


how about GetNumbers with StrToInt…

so:
for i := 1 to 8 do
if(FindChatBoxText('assign', i, clMessage))then
break;
if((i = 8) and (not FindChatBoxText('assign', 8, clMessage)))then//just incase it didn't find it...
exit;
S := GetNumbers(GetChatBoxText(i, clMessage));
if(S <> '')then
i := StrToInt(i);

Sin

2012-06-19 12:04:09

Aha! I got it working, thank you!
Thread can be closed..



function GetTaskAmount:Integer;
var
i,hAmount,revAmount:Integer;
sAmount:String;
begin
if not FindBlackChatMessage('assign') then
exit;
for i := 1 to 300 do //300 is the max number of monsters she can assign
begin
sAmount := IntToStr(i);
if FindBlackChatMessage(sAmount) then
begin
writeLn(sAmount);
revAmount := StrToInt(sAmount);
end;
end;
Result := (revAmount)
writeLn(IntToStr(Result));
end;

putonajonny

2012-06-19 12:10:01

From: Shay
Aha! I got it working, thank you!
Thread can be closed..
So not my super efficient way… :( ;)

Main

2012-06-19 12:14:54

or
find text between 'only', 'more'

something like that (search text between).

EDIT:
function Between(s1, s2, str: string): string;

J J

2012-06-19 12:51:06

From: Main
or
find text between 'only', 'more'

something like that (search text between).

EDIT:
function Between(s1, s2, str: string): string;

I used something like this

procedure TokensUpdate;
var
i: Integer;
TokensBox: TBox;
TokensBoxTPA: TPointArray;
TokensGainedString: String;
NumbersCheck: Array of String;

begin
TokensGainedString := GetChatBoxText(8, clBlack);
NumbersCheck := ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];

for i:=0 to 10 do
begin
if Pos(NumbersCheck[i], TokensGainedString) > 0 then
begin
TokensGained := StrToInt(GetNumbers(TokensGainedString));
Tokens := (Tokens + TokensGained);
TokensBox := IntToBox(289, 456, 350, 470);
TPAFromBoxWrap(TokensBox, TokensBoxTPA);
SMART_DrawDotsEx(False, TokensBoxTPA, RGBtoColor(194, 178, 146));
SMART_DrawText(290, 457, UpChars, ''+IntToStr(Tokens)+'', clWhite);
Exit;
end;
end;
end;
if the line contains numbers then use GetNumbers.. way more efficient than looping through everything.

Brandon

2012-06-19 12:54:24

Easiest one line solution:

int meh := StrToIntDef(ExtractFromStr('OurStringOfTheChatHere', NUMBERS), 1);