SRL Archive - OSR Help

How to go though strings?


Troll

2010-12-18 07:15:03

Ok well im trying to return what was said last from chat.


Function LastLineOfChat:Integer;
Begin
Case GetChatBoxText(8,clChat) Of
End;

I'm not sure what to do, i want it to search though array's and see if the chat matchs any of the arrays.

Example

It finds 'Hello, today is a nice day'
and the arrays are
['I hate today','Today is a bad day']
['Its raining today','I hate the rain']
['Yay i leveled up','Woot 1 level closer to 99']
['Hello, today is a nice day','I love today']

So it returns 4 as it matchs array 4

Thanks :)

E: saw no point in a new thread, but a new question
For MouseBox what is the parameter clickType?
Thanks again :)

Edit: Thank a ton guys for all your help ;)
Im trying to send text. I needs to be from the array which is set in the parameter but can be from any in that array.

Function Reply(A:Integer):Boolean;
Var
i: Integer;
TheArrays: Array Of TStringArray;
S: String;
Begin

TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
TheArrays[2] := ['Array2_1', 'Array2_2'];
TheArrays[3] := ['Array3_1'];
TheArrays[4] := ['Array4_1', 'Array4_2'];

For I := High(TheArrays) DownTo 0 Do
If I = A Then
Begin
TypeSendEx(TheArrays[I],True);
writeln('Said '+TheArrays[I]);
End;

End;
I tryed this but got compileing errors

Thanks again for all your help, i know it seems like a lot but im find most my questions out my self :p

Frement

2010-12-18 07:19:41

Split the text by ' ' (SPACE) and then for each array element, do the same, and count the words that match the chat text, then save that to TStringArray[NumberOfWordsFound] = Answer;

Now that you have the number of words matched, you can a sort, so you get the highest count of words that were matched.

Now you can check if the word count was atleast 50% of the actual chat text's word count, and then return the answer.

Troll

2010-12-18 07:22:22

Umm you've lost me :p maybe an example? Also i want it to be 100% as this is for Khan(Srl clan) and will be talking but it will be the same scirpt that talks and replys just diffrent people :)

Richard

2010-12-18 07:25:02

By splitting the text into the various words, he means doing and "explode":

srl_Explode(str, del: string);

With str being your string, del being the character that splits the string.

Troll

2010-12-18 07:28:23

^Umm still lost sorry :(
Also why cant i just look for the full string as it has to be 100% anyway?

Thanks for the help though

Gu3st...

2010-12-18 07:54:09

type
T2DStringArray = array of TStringArray;

const
S = 'Array1_3';

var
TheArrays : T2DStringArray;
I : Integer;

function InStringArray(Str : String; sArr : TStringArray): Boolean;
var
I : Integer;
begin
for I := High(sArr) downto 0 do
if sArr[I] = S then
begin
Result := True;
Exit;
end;
end;

begin
SetLength(TheArrays, 5);
TheArrays[0] := ['Array0_1', 'Array0_2', 'Array0_3'];
TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
TheArrays[2] := ['Array2_1', 'Array2_2'];
TheArrays[3] := ['Array3_1'];
TheArrays[4] := ['Array4_1', 'Array4_2'];
for I := High(TheArrays) downto 0 do
if InStringArray(S, TheArrays[I]) then
WriteLn(I);
end.

Troll

2010-12-18 08:39:06

Thanks Zyt3x that helps a load :)

Thanks all

Awkwardsaw

2010-12-18 11:39:30

isnt there an srl function that returns the chat box into an array or something of that nature? :)

Troll

2010-12-18 17:10:48

Umm do you know why this does not compile?

Function CheckIfInChat:integer;
Var x,y,s:integer;
TheArrays:T2DStringArray;
Begin
S := GetChatBoxText(8,clfriend)
SetLength(TheArrays, 5);
TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
TheArrays[2] := ['Array2_1', 'Array2_2'];
TheArrays[3] := ['Array3_1'];
TheArrays[4] := ['Array4_1', 'Array4_2'];
For I := High(TheArrays) DownTo 0 Do
If InStringArray(S, TheArrays[I]) Then
Result := I
End;

Thanks

Home

2010-12-18 18:19:44

Try this :)

program new;
{$i srl\srl.scar}



// By Nava
function InStrArray(s: String; a: TStringArray): Boolean;
var
i, h: Integer;
begin
Result := True;
h := High(a);
for i := 0 to h do
begin
if (s = a[i]) then
Exit;
end;
Result := False;
end;







Function CheckIfInChat:integer;
Var
i: Integer;
TheArrays: Array Of TStringArray;
S: String;
Begin
S := GetChatBoxText(8,clfriend);
SetLength(TheArrays, 5);
TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
TheArrays[2] := ['Array2_1', 'Array2_2'];
TheArrays[3] := ['Array3_1'];
TheArrays[4] := ['Array4_1', 'Array4_2'];
For I := High(TheArrays) DownTo 0 Do
if InStrArray(S, TheArrays[I]) Then
Result := I
End;


begin
SetupSRL;
CheckIfInChat;
end.


~Home

Shuttleu

2010-12-18 18:23:34

im pretty sure than InStrArray is already in simba…

~shut

Home

2010-12-18 18:30:32

From: Shuttleu
im pretty sure than InStrArray is already in simba…

~shut


Ye, I thought so too. But it wasn't there :)


~Home

Shuttleu

2010-12-18 18:32:57

ah, found it
its called InStrArr and its in SRL/Core.Simba.simba

~shut

Home

2010-12-18 18:39:39

Ok this one should do the trick :)


program new;
{$i srl\srl.scar}


type
T2DStringArray = array of TStringArray;


var
TheArrays : T2DStringArray;
I : Integer;




Function CheckIfInChat:integer;
Var
S: String;
Begin
S := GetChatBoxText(8,clfriend);
SetLength(TheArrays, 5);
TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
TheArrays[2] := ['Array2_1', 'Array2_2'];
TheArrays[3] := ['Array3_1'];
TheArrays[4] := ['Array4_1', 'Array4_2'];
For I := High(TheArrays) DownTo 0 Do
if InStrArr(S, TheArrays[I], False) Then
Result := I
End;


begin
SetupSRL;
CheckIfInChat;
end.


~Home

Troll

2010-12-18 19:18:37

saw no point in a new thread, but a new question
For MouseBox what is the parameter clickType?
Thanks again :)

Shuttleu

2010-12-18 19:24:29

From: Troll Man
saw no point in a new thread, but a new question
For MouseBox what is the parameter clickType?
Thanks again :)


mouse_left
mouse_right

~shut

Bad Boy JH

2010-12-18 19:48:47

1 - left click
2 - Right Click
3 - Move Mouse

Gu3st...

2010-12-18 20:29:55

mouse_Left, mouse_Right or mouse_Move

Troll

2010-12-19 05:07:44

Thank a ton guys for all your help ;)
Im trying to send text. I needs to be from the array which is set in the parameter but can be from any in that array.

Function Reply(A:Integer):Boolean;
Var
i: Integer;
TheArrays: Array Of TStringArray;
S: String;
Begin

TheArrays[0] := ['Hi', 'Hello', 'Hi all'];
TheArrays[1] := ['Array1_1', 'Array1_2', 'Array1_3', 'Array1_4'];
TheArrays[2] := ['Array2_1', 'Array2_2'];
TheArrays[3] := ['Array3_1'];
TheArrays[4] := ['Array4_1', 'Array4_2'];

For I := High(TheArrays) DownTo 0 Do
If I = A Then
Begin
TypeSendEx(TheArrays[I],True);
writeln('Said '+TheArrays[I]);
End;

End;
I tryed this but got compileing errors

Thanks again for all your help, i know it seems like a lot but im find most my questions out my self :p

Gu3st...

2010-12-19 06:39:57

TheArrays is an array of array of String, meaning if you want to use it with TypeSendEx() you'll have to do TypeSendEx(TheArray[Index1][Index2], True);

It doesn't look like you're even using the other arrays, so I assume you meant to do TypeSendEx(TheArrays[0], True); but in that case you're gonna end up with a runtime error because you have to change stuff in the loop too

I hope you understand what I'm saying here.. :p
You could try reading a tutorial on arrays if you're having troubles

Death12652

2010-12-25 10:56:00

Sorry to intrude on your thread but I dont want to make another. What is "Indent : Integer" and "IdentType : String"

Frement

2010-12-25 11:03:29

From: death12652
Sorry to intrude on your thread but I dont want to make another. What is "Indent : Integer" and "IdentType : String"


In what procedure/function?

KingKong

2010-12-25 18:20:22

From: death12652
Sorry to intrude on your thread but I dont want to make another. What is "Indent : Integer" and "IdentType : String"


They're variables……Or did you mean to ask what they're used for.

Death12652

2010-12-30 13:56:49

In WithdrawItem() I know there variables yes what there used for.

Frement

2010-12-30 14:11:02

I think the first one could be a DTM/Bitmap, and the type would be 'dtm' or 'bitmap'.