Boreas
2008-12-19 18:41:37
It's my first tutorial in a long time so bear with me;)
How To Make and Use TPA Text INI Files
What Are TPA Text INI Files?
TPA Text INI Files are a result of me being lazy :p. I was working on a script with lots of text reading from talking to an NPC, and wanted to give the option to talk to other NPCs, that say different things, in different colors. But I was too lazy to go through and make lots of DTMs for each NPC, or even just type out exactly what they are saying for a slow text finding function. So TPA Text INI files are a way to store TPAs for finding text. They work with constant colors, with text in constant positions.
How Can I Make a TPA Text INI File?
How Can I Use a TPA Text INI File?
A Few Points to Keep in Mind
If FindTPAText finds the TPAText, it will click or type, and result true, if it can't, it will result false.
If you forget what you called your TPATexts, just open the INI in notepad, and they will be in a list (in the order you made them).
The INI maker script is designed to make all the TPATexts for one script in one run (which means you have to run it while doing everything text-related in your script's loop). If you can't do it in one go, pause the script, not stop it. If you stop it and restart it, the list I just mentioned will be messed up, and LoadTPATextsFromINI won't load the ones from the first run. They will still be in the INI, but you will have to load each one using ReadINI.
How To Make and Use TPA Text INI Files
What Are TPA Text INI Files?
TPA Text INI Files are a result of me being lazy :p. I was working on a script with lots of text reading from talking to an NPC, and wanted to give the option to talk to other NPCs, that say different things, in different colors. But I was too lazy to go through and make lots of DTMs for each NPC, or even just type out exactly what they are saying for a slow text finding function. So TPA Text INI files are a way to store TPAs for finding text. They work with constant colors, with text in constant positions.
How Can I Make a TPA Text INI File?
- Download TPATextINIMaker.scar below.
- Target runescape, and run. You will be asked to give your INI file a name. I suggest your script name. You can use more than one INI file per script, or more than one script per INI file, but I suggest using one per script.
- Now go start to do what you want your script to do So, for example, if you want to talk to an NPC, go to that NPC, and click them so that the first text comes up.
- Press F12, and type in a name that will remind you of what the text is, perhaps the first couple words. This is the name you will refer to in your script. Don't bother calling it FirstScreen, SecondScreen etc, because the script will give it a number (which will be 0 for the first one).
- Now a color picker will come up, click exactly on the text you are looking for. This will get the color of the text. 99% of the time it will be 0, but I wanted to give you the option of other colors.
- Another color picker! This time click to the top left of the text you are looking for. Next one, bottom right. This creates a rectangle around the text. Make the rectangle big enough to include enough letters so that no other screen will be like it. Smaller is faster, but it's already super fast, so don't worry about that.
- Next 2 color picks are going to be top left and bottom right of a MouseBox, for what you want to click. Sometimes this is the same as the text you are looking for, sometimes it will be ClickToContinue etc. Make this rectangle just within the acceptable area to click. Bigger means more randomness, but if you make it bigger than the text, then it will misclick. Now some of you are thinking, 'but sometimes, after confirming a certain text is there, I want to typsend a number instead of clicking something!'. Let's say the text you are looking for is 'Enter Amount', and you want to typesend 27. Make both color picks (your 4th and 5th color picks) at 27,27. When the text finding functions explained in the next section sees that both points are at the same place, and the rectangle is just a dot, it will typesend the number that is the x1,y1,x2, and y2. The functions explained below will either left click, or typesend a number. If you want right clicking, or typesending letters, then you need to modify them.
- Next, move your mouse to where it would be if your script was doing this (usually the last place it clicked). Then press F11. The script will now find all the pixels of the color you specified with the first color pick, within the rectangle you specified with the second and third color picks, and save them to an INI in your SCAR folder, with the name in step 2.
- Now actually click what you made a box for in step 7. Now you should be at the next text you want to check for. Repeat from step 4 for each screen. If you don't need to make another one, in step 4 type 'exit' without the quotes, or just stop the script.
How Can I Use a TPA Text INI File?
- First off, you (and the users of your script) need the INI file you created following the steps above to be in you SCAR folder.
- Next, you need to declare a variable to load the TPA Texts into.
var MyTPATexts: TTPATextArray; - In the beginning of your script, after SetupSRL;, call
MyTPATexts := LoadTPATextsFromINI('Name you gave in step 2 of How Can I Make a TPA Text INI File?'); - Then, when you want to find and click text, call
FindTPAText(MyTPATexts,'Name you gave in step 4 of How Can I Make a TPA Text INI File?');
A Few Points to Keep in Mind
If FindTPAText finds the TPAText, it will click or type, and result true, if it can't, it will result false.
repeat
wait(100);
Inc(counter);
if counter > 100 then
begin
result:=false;
exit;
end;
until FindTPAText(MyTPATexts,'HeyDer');If you forget what you called your TPATexts, just open the INI in notepad, and they will be in a list (in the order you made them).
The INI maker script is designed to make all the TPATexts for one script in one run (which means you have to run it while doing everything text-related in your script's loop). If you can't do it in one go, pause the script, not stop it. If you stop it and restart it, the list I just mentioned will be messed up, and LoadTPATextsFromINI won't load the ones from the first run. They will still be in the INI, but you will have to load each one using ReadINI.