PDA

View Full Version : Reading Text



Ransom
11-16-2006, 07:28 PM
Ok i'm making a handy dandy merchant script to buy and sell stuff for you to other players so you can avoind the boring nights of typing the same old message over and over and sitting there with a calculator figuring out how much you owe or need to receive.

ANYWAY that aside

I have this handy dandy procedure to find out how many of an item they put up in a trade. That way i can put up the correct amount of gold.

Procedure FindItemsInTrade;
var FX, FY : Integer;
begin
repeat
Wait(1000);
Until(FindBitMapTol(FX,FY,Coal,320,70,365,105) = True);
writeln('I MADE IT HERE');
Wait(700);
Items := StrToInt(GetTextAtEx(FX-18, FY-18, 50, TradeChars, False, True, 0, 3, 65535, 5, False, tr_Digits));
Wait(700);
end;

The problem I run into is this

SRL Compiled in 156msec.
I MADE IT HERE
[Runtime Error] : Exception: ' ' is not a valid integer value in line 48 in script C:\Program Files\SCAR 2.03\Scripts\Merchant.scar

So i'm assuming the gettxt procedure has gone kaput on me and can't find what i want it to. Basically i'm asking anyone who knows about this stuff to tell me what i'm doing wrong or a better way to do it. I was using the built in GetAmount() and AmountDTM/Bmp etc... Those didn't work for me at all.....i'm not really sure why either... but i decided to just go ahead and try this myself. So far i'm failing... any ideas?

Once i get a few more procedure to finish off the trade done i'll post what i have so people can critique it. It's rough and dirty, I tend to brute force a problem. And my standard are a bit lower than what they should be. But if i do make a formal release i'll try to clean it up and comment a bunch.

Anyway i hope you can help me. Thanks!

Ransom

Tonekray
11-16-2006, 07:42 PM
I think you have to get rid of the StrToInt

The get text is already int i think

Boreas
11-16-2006, 07:54 PM
I think there's already something like this in amount.scar, I'll check. Yea there's some stuff in amount and trade, but more methods is always good. Good job. Useful for my W16 air crafter( if I ever get around to finishing it lol).

I think the problem may be that is trying to read nothing. So you either want to add trimming in there or change the coords.

Ransom
11-16-2006, 10:40 PM
Thanks you guys you have been a big help. Just one more thing. for now ;-)

I did end up using the procedures in amount.scar. My problem was a repeat loop that was had nothing to slow it down so it would lag and make the rest of it hang.

I do have a functioning Coal buyer now. While adding some useful tweaks i felt that i should have the script termintate if you don't have enough money to buy even 1 of the item.

I found the procedure CountInvSlot() and it looked like just my cup of tea. My problem was that if i had 180K gold..... it would translate into 180 making it useless. Any ideas on how to fix this?

Thanks! Almost posting time!

Ransom

Boreas
11-16-2006, 10:59 PM
if text contains k then, make temptext=text-k then multiple that by 1000 ?

masquerader
11-17-2006, 04:38 AM
i'd love to see you make a merchanter :)
a few have already been made, but id like to see how you make yours

heres a lil tut i prepared earlier

Amount.scar is made of extended inventory functions, especially related to the amount/number of items.
Dont forget to include setupsrl somewhere in your script so the trade font is loaded

The area parameter in almost all of the functions consists of the string: 'inv'/'inventory','shop','bank','trade',or 'your trade'. This is pretty simple, in that this is just the interface in which you are looking.

Amount.scar is very flexible in that it works with colors, dtms, or bitmaps, in any of the above areas.

to simply find the amount at a given position, use



function amount(area: String; i: Integer): Integer;



To find item amount using colors,dtms, or bitmaps, use:



function amountcolor(area: String; color, tol: Integer): Integer;
function amountbmp(area: String; itembmp, tol: Integer): Integer;
function amountdtm(area: String; dtm: Integer): Integer;



this will total everything everything in your inventory (ex a stack of notes + loose items if the color is the same)

to find the amount of inventory spaces taken up (not counting notes or anything) use:



function countitems(area: String): Integer;
function countitemscolor(area: String; color, tol: Integer): Integer;
function countitemsbmp(area: String; bmp, tol: Integer): Integer;
function countitemsdtm(area: String; dtm: Integer): Integer;



I also made a couple higher level functions for you guys:



function coinamount(area: String): Integer;
function runeamount(area, runetype: String): Integer;


if you want me to make a guide for trade.scar, just ask