Results 1 to 6 of 6

Thread: Reading Text

  1. #1
    Join Date
    Nov 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Reading Text

    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.

    SCAR Code:
    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

  2. #2
    Join Date
    Sep 2006
    Posts
    45
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    I think you have to get rid of the StrToInt

    The get text is already int i think

  3. #3
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    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.

  4. #4
    Join Date
    Nov 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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

  5. #5
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    if text contains k then, make temptext=text-k then multiple that by 1000 ?

  6. #6
    Join Date
    Feb 2006
    Posts
    406
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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


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


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


    Code:
    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:


    Code:
    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:

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

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Grabbing or reading Text from a game text box
    By British in forum OSR Help
    Replies: 16
    Last Post: 02-27-2009, 08:02 AM
  2. Text Reading
    By noobmaster in forum OSR Help
    Replies: 7
    Last Post: 05-26-2008, 02:05 PM
  3. Reading text
    By aran armath in forum OSR Help
    Replies: 2
    Last Post: 12-31-2007, 07:12 PM
  4. Reading Text
    By jeremywilms in forum OSR Help
    Replies: 11
    Last Post: 04-30-2007, 12:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •