View Full Version : FindText
Jason2gs
02-18-2007, 05:14 AM
I think this is the right forum...
Could someone please explain the "FindText" command, to me?
Thanks,
Mike.
the scar noob
02-18-2007, 01:24 PM
FindText searches for a specify text (text you wanne search for) in a specified area/box (by coords)
For example
FindText(x,y,'Welcome To RuneScape',MSX1,MSY1,MSX2,MSY2);
will search for the text 'Welcome To RuneScape' in the Main Screen coords (rs main screen) sp this are bad coords, i should take the coords from the text box in rs :)
But i'm to lazy atm :)
Buckleyindahouse
02-18-2007, 02:07 PM
If you trying to find something in runescape then use:
IsUpText('ttack');
This checks to see if part or all of the text is in the left upper corner.
Jason2gs
02-18-2007, 07:25 PM
So the FindText command searches for any kind of text? Or just text in RS? What command should I use to find if someone asks me my WC level? Could you please show me an example of it?
Jason2gs
02-18-2007, 07:57 PM
If you trying to find something in runescape then use:
IsUpText('ttack');
This checks to see if part or all of the text is in the left upper corner.
I tried that, I'm getting this error:
[Runtime Error] : Exception: Access violation at address 0065478C in module 'scar.exe'. Read of address 00000000 in line 196 in script C:\Program Files\SCAR 2.03\includes\srl\srl\core\Text.scar
Help, please?
function GetNewChatMsg: String;
By: Stupid3ooo
Description:
Get last chat message.
If(GetNewChatMessage= 'wc lvl') Then
function IsChatMessage(s: String): Boolean;
By:
Description:
Checks if last chat message matches specified.
If(IsChatMessage('wc lvl')) Then
function InChat(Text: String): Boolean;
By: WT-Fakawi
Description:
Grabs Last Chat Line and performs checks on occurence of text
If(InChat('wc lvl')) Then
function FindChatText(txt: String): Boolean;
By: Stupid3ooo
Description:
Searches for text in chat window
If(FindChatText('wc lvl') Then
Something like that? I reccommend FindChatText for that because it searches the whole chat box rather than just the last message.
Smartzkid
02-18-2007, 08:18 PM
I tried that, I'm getting this error:
[Runtime Error] : Exception: Access violation at address 0065478C in module 'scar.exe'. Read of address 00000000 in line 196 in script C:\Program Files\SCAR 2.03\includes\srl\srl\core\Text.scar
Help, please?
Program TextFinder
{.include SRL/SRL.scar}
....
begin
SetupSRL;
istext....
...
Jason2gs
02-18-2007, 08:18 PM
Thanks, town =) Exactly what I needed.
Jason2gs
02-18-2007, 08:19 PM
Lemme try that, smartz. I'll post back and see if it worked.
Jason2gs
02-18-2007, 08:27 PM
Doesn't seem to be working... It my mouse just went up to the corner of the screen.
Jason2gs
02-18-2007, 08:37 PM
I got FindChatText to work, but here's the thing...
Without the repeat, it makes one search and stops the script.
With the repeat, it makes search after search after search, making it too laggy to do anything.
How do I get it to be on a constant search, without making it to where I can't do squat?
Smartzkid
02-18-2007, 08:59 PM
put in something like wait(500+random(250)); inside the loop
Jason2gs
02-18-2007, 09:07 PM
Thanks, smartz =) Didn't even think of that...:rolleyes:
Smartzkid
02-18-2007, 09:12 PM
:p No prob.
Could you post the script that you're making? I'm curious to see it...
Jason2gs
02-18-2007, 09:18 PM
Right now I'm not making much of anything. Just learning different things, and I thought this would be useful.
I am planning on making:
Rune Mysteries Quester, in hopes of SRL membership. Do you think it'll get me in?
And the largest auto-responder ever ( I can dream :p ).
Smartzkid
02-18-2007, 09:22 PM
:p Good luck, But I suggest you try out the auto-responder first, cause making any quester is likely to be very hard and riddled with problems. Until you're familiar with SCAR, and SRL, it will be very hard to make a good script, start small, and go on from there.
But yes, if you could create a stable Rune Mysteries Quester, I'm sure it would get you a SRL membership
Jason2gs
02-18-2007, 09:28 PM
Awesome, thanks :D
I'm trying to think of a good way to set up the autoresponder... I'd have to have at least three or four different responses to each phrase... That's gonna be a little hard :p
Smartzkid
02-18-2007, 09:43 PM
if(InChat('text'))then
begin
case random(5) of //one more than the number of responses there are
0:sendkeys('reply1');
1:sendkeys('reply2');
2:sendkeys('reply3');
3:sendkeys('reply4');
4:sendkeys('reply5');
end;
Just instead of using 'sendkeys' you should make your own chat procedure that sends letters one at a time
Jason2gs
02-18-2007, 09:48 PM
I can make my own chat procedure? Like clickmouse or typesend... Only something that I make up?
Smartzkid
02-18-2007, 09:52 PM
Yeah, why not? I'll post one in a sec, just gotta find it...
Jason2gs
02-18-2007, 10:07 PM
That's cool :P
You seem to know a lot about SCAR and scripting.
Would you mind telling me a couple of things?
1) In your example of the autoresponder, how would I add more primary phrases without adding another case ... of setup? Like...
if(inchat('Hey'))then
How would I make something like this...
"if(inchat('hey')('hi')('sup'))then"
2) How do I place the "AND" and "OR" commands? I can never seem to get them to work the way I want them to work... like...
if(InChat('Hey'))then
wait(2000+(500))and
TypeSend('hi, what''s up')or
TypeSend('hi')or
TypeSend('hello')
end;
Did I do that right?
Smartzkid
02-18-2007, 10:10 PM
For your first question,
if(InChat('Hey'))or(InChat('Hi'))or(InChat('Hello' ))then
begin
case random(3)of
0:SendText('hi, whats up');
1:etc...
end;
end;
Also, here's how to make it send things one character at a time:
procedure SendText(text: string);
var i: Integer;
begin
for i := 1 to Length(Text) do
begin
SendKeys(Text[i]);
Wait(50+random(50));
end;
SendKeys(Chr(13));
end;
Jason2gs
02-18-2007, 10:14 PM
Ohhhh
I thought you ment your own *command*.
As in sendkeys or clickmouse :p
My bad. Thanks for finding that though. It looks like it waits between 50 and 100 miliseconds between each keystroke, right?
Smartzkid
02-18-2007, 10:24 PM
Yup, good observation.
To do and's, or's, or xor's (no, thats not a typo :p), you do something like this:
if(a=1)and(b=2)or(c=3)then....
if a=1 and b=2, or c=3, it will continue.
if(a=1)or(b=2)and(c=3)then....
if a=1, or b=2 and c=3, it will continue.
xor's are pretty confusing, they're kinda like using:
if(a=1)or(not(b=2))then...
if a=1 or if b doesn't equal 2, it will continue, so instead of using the above code, you could use:
if(a=1)xor(b=2)then...
and for your second question:
say you had this:
if(a=2)then
writeln('a=2');
but you wanted it to display 'a=2' and do something else, you might use the below code:
if(a=2)then
writeln('a=2'); <--- this would only be run if a equals 2
anotherthing; <--- this would be run nomatter what
but, as you can see, the above example wouldn't work. To make it work, you'd have to use begin/end; as shown below
if(a=2)then
begin
writeln('a=2');
anotherthing;
end;
Jason2gs
02-18-2007, 10:35 PM
but you wanted it to display 'a=2' and do something else, it wouldn't work as shown in the below example.
if(a=2)then
writeln('a=2'); <--- this would only be run if a equals 2
anotherthing; <--- this would be run nomatter what
to make the above example work, you'd have to use begin/end; as shown below
if(a=2)then
begin
writeln('a=2');
anotherthing;
end;
That's exactly what I needed to know =)
You've been very helpful to me, thank you =)
Jason2gs
02-18-2007, 10:42 PM
One more thing before you leave-
Could I theoretically create my own private include?
And the thing with includes...
When you set an include at the top of your script, does that include last throughout the whole script? Like if I go through with my AutoRespond, would I be able to set it as an include, and have it run throughout my entire script?
Smartzkid
02-18-2007, 10:49 PM
Well...Sort of.
See, when you include a file, it allows you to use all the procedures in that include.
So if your include had a procedure called CheckResponses, you could call CheckResponses; all throughout the script.
Jason2gs
02-18-2007, 10:53 PM
Ah. Alright. Would you mind telling me why this isn't working real quick?
program New;
{.include SRL/SRL.scar}
begin
if(InChat('Hey'))or(InChat('Hi'))or(InChat('Hello' ))then
begin
wait(2000+(500))
TypeSend('hi')or TypeSend('sup')or TypeSend('whats up');
end;
end.
Line 7: [Error] (17673:15): Identifier expected in script
Smartzkid
02-18-2007, 10:56 PM
When you include SRL, you allways have to call SetupSRL; before you use anything else.
EDIT:
also, wait(2000+(500)) should be wait(2000+random(500));
and, TypeSend('hi')or TypeSend('sup')or ('whats up');
should be something like this:
case random(3) of
0:TypeSend('hi');
1:TypeSend('sup');
2:TypeSend('whats up');
end;
Jason2gs
02-18-2007, 11:01 PM
I included the SetupSRL; and fixed the wait(2000+random(500)), but I still have the same error =/
Jason2gs
02-18-2007, 11:03 PM
and, TypeSend('hi')or TypeSend('sup')or ('whats up');
should be something like this:
case random(3) of
0:TypeSend('hi');
1:TypeSend('sup');
2:TypeSend('whats up');
end;
That's the only way to get this to work? I didn't want to mess around with cases, but if it's the only way to get it to work... =/
Thanks though, I'll try it out and see if it works.
Jason2gs
02-18-2007, 11:05 PM
program New;
{.include SRL/SRL.scar}
begin
SetupSRL;
if(InChat('Hey'))or(InChat('Hi'))or(InChat('Hello' ))then
begin
wait(2000+random(500))
case random(3) of
0:TypeSend('hi');
1:TypeSend('sup');
2:TypeSend('whats up');
end;
end.
Still getting the same error- Identifier expected.
Smartzkid
02-18-2007, 11:06 PM
you could also do something like this:
response:=random(3);
if(response=0)then
TypeSend('hi');
if(response=1)then
...
Okay, I found the error- you're one 'end' short. I would fix it for you, but it would be better for you to fix it; Practice makes Perfect :p
Jason2gs
02-18-2007, 11:11 PM
You do know a lot about scripting =)
I'll try that one out, the response thing.
I need to set response at a var right?
Smartzkid
02-18-2007, 11:14 PM
Yup, you could also use arrays to handle the responses, but this way is just as good, and arrays can get a bit confusing. The only advantage to using arrays is that it would be easier to change the responses, say if it were being translated or something...ofcourse, not many scripts get translated...
Jason2gs
02-18-2007, 11:17 PM
So...
Amount of begins = Amount of ends + 1?
One end for each begin, and a final end to shut of the program (program New)?
Smartzkid
02-18-2007, 11:21 PM
no, its just amount of begins+amount of case's = amount of ends. Case statements, begins and a few other statements (cant think of any right now, you dont use them much) need ends. You had ends for one of the begins, and the case statement, but you didn't put an end for the begin that is right after the if. =S try to read that and not get confused :p
Jason2gs
02-18-2007, 11:27 PM
IT COMPILES!!!
Thank you smartz =)
Only thing now is the fact that it only runs through once, and stops.
I could always have it scan every few seconds, but the game gets a little laggy when it does that =/
Smartzkid
02-18-2007, 11:36 PM
I think, from the code you posted before, that it is doing something like this:
...
repeat
if(...)then
begin
wait(x);
...
until(false)
...
if you moved the wait from inside the if, to right before it, the lag should go away; right now it's constantly checking for the chat words, and waiting when the chat text is found. it only needs to check for the text every few seconds...moving the wait will fix that
If you were using this in a script, you wouldn't need a wait, because you would probably only check for chat messages when you check for randoms (normally every few seconds), so it wouldn't be checking constantly
Jason2gs
02-18-2007, 11:47 PM
I don't only want it to do it when it checks for randoms. I want this to hold a good, artificial conversation; meaning it checks constantly for text.
Jason2gs
02-18-2007, 11:49 PM
One question about this command, InChat.
Let's say I want it to check for the phrase "Wc level"-
If someone said "Wc level?" would it still count as "Wc level"?
If it does, I can save a lot of time.
Smartzkid
02-18-2007, 11:51 PM
ahh, I see. I thought you were writing this to be included in a script as antiban...
Well, in that case, you should just take the wait out from inside the if and move it to right before the if. You should probably change the wait time to 500 instead of 2000. That shouldn't lag too much, and will be responsive enough to provide a more convincing conversation.
EDIT:
Yes, from the description of what InChat does (I looked in the SRL Manual) It should check for one string throughout the whole chat window. So if you searched for 'ap', it would detect 'happy', 'apple' etc.
Jason2gs
02-18-2007, 11:55 PM
Kk.
Only problem I have right now is wondering what to make my WC level incase somebody asks =)
if(InChat('wc level'))or(InChat('wc level?'))or(InChat('wc lvl'))or
InChat('wc lvl?'))or(InChat('wc levl'))or(InChat('wc levl?'))or
InChat('wc lvel'))or(InChat('wc lvel?'))or(InChat('wclevel'))or
InChat('wclevel?'))then
Jason2gs
02-19-2007, 12:02 AM
The whole chat window, or just the last line? If it's the whole chat window... I'll have to get a new command...
Smartzkid
02-19-2007, 12:04 AM
you could put in something like this:
if(InChat('wc'))or(InChat('woodcutting'))then
if(InChat('level'))or(InChat('lvl'))then
begin
wclvl:=GetSkillLevel('woodcutting');
case random(2) of
0:sendkeys(inttostr(wclvl));
1:sendkeys('Mines '+inttostr(wclvl));
end;
end;
Jason2gs
02-19-2007, 12:07 AM
GetSkillLevel? That's a command?
Neat =)
So I need to set wclvl as a var and then TypeSend + wclvl... That should be easy enough...
Lemme try it, thanks =)
Jason2gs
02-19-2007, 12:11 AM
[Runtime Error] : Exception: Access violation at address 006549BC in module 'scar.exe'. Read of address 00000000 in line 103 in script C:\Program Files\SCAR 2.03\includes\srl\srl\core\GameTab.scar
I've gotten a runtime error again... What does this one mean?
Smartzkid
02-19-2007, 12:13 AM
also, you might want to put:
procedure SendText(text: string);
var i: Integer;
begin
for i := 1 to Length(Text) do
begin
SendKeys(Text[i]);
Wait(50+random(50));
end;
SendKeys(Chr(13));
end;
right after {.include SRL/SRL.scar}
so your program would be:
program New;
{.include SRL/SRL.scar}
procedure SendText(text: string);
var i: Integer;
begin
for i := 1 to Length(Text) do
begin
SendKeys(Text[i]);
Wait(50+random(50));
end;
SendKeys(Chr(13));
end;
begin
//main program
end.
then instead of using TypeSend, use SendText(...);
Smartzkid
02-19-2007, 12:15 AM
I've gotten a runtime error again... What does this one mean?
Post the script, and I'll have a look at it. I'm pretty sure I've got that error before, hopefully I'll remember how to solve it. =D
EDIT: sorry about double post =)
warlord94
02-19-2007, 12:18 AM
figure it out urself, not to be mean
Smartzkid
02-19-2007, 12:19 AM
Lol, except that some of the SRL errors can be pretty tricky to solve...I've spent hours on ones like this before
Jason2gs
02-19-2007, 12:22 AM
program New;
{.include SRL/SRL.scar}
var
wclvl : integer;
begin
wclvl := GetSkillLevel('woodcutting');
writeln(IntToStr(wclvl) + '');
end.
Smartzkid
02-19-2007, 12:33 AM
tsk tsk
You forgot SetupSRL;
Jason2gs
02-19-2007, 12:37 AM
Heh, thanks =)
How important is SetupSRL;? What does it have? I thought {.include SRL/SRL.scar} contains SetupSRL;
Jason2gs
02-19-2007, 12:43 AM
And why is sendtext better than typesend?
Smartzkid
02-19-2007, 01:12 AM
because that sendtext will send the text humanly, unlike typesend (as far as i know) when just sends it all at once
Boreas
02-19-2007, 01:27 AM
Setupsrl; loads the fonts (amongst other things) which are needed for text finding, getting levels, etc. It's good practice to put it in evey RS script. See the end of my FAQ (link in sig) for a way to make it so that setupsrl is automatically in the script.
Jason2gs
02-19-2007, 01:57 AM
Thank's boreas ;)
Smartzkid
02-19-2007, 02:11 AM
...evey...
!!!!!
Boreas made a typo!!!
obviously he isn't using the latest firefox with built in spellchecking. Or he just disregarded the squiggly red lines...
^^^^^I wont get in trouble for using that will I?^^^^^
Jason2gs
02-19-2007, 02:20 AM
Lol Smartz =P
Boreas
02-19-2007, 03:19 AM
Lol, I do have firefox with squigglys. First I made the typo 'evety', I saw the red line, deleted the 't', but didn't replace it with an 'r', having seen the red line the first time, my brain assumed I fixed it and moved on hehe.
Anyways... yea follow freddys tut, I haven't had that problem in a long time thanks to that trick.
omgh4x0rz
02-19-2007, 01:18 PM
Make sure you test the responder ingame before you use it in any scripts though. The first time I tried mine, It kept finding the same statement for a while so it responded a bunch of times to one thing. I fixed, but I think I made it more complicated than it has to be.
Smartzkid
02-19-2007, 03:52 PM
Ohh true...Maybe put in a variable, like when it responds to phrase #1, it sets the variable lastphrase to 1; while lastphrase is 1, the script won't respond to phrase #1, because it knows it allready has
I don't know how confusing that was, if you showed me a script, I could show you an example of what I mean
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.