Results 1 to 6 of 6

Thread: CoinAmount Broken

  1. #1
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default CoinAmount Broken

    In the amount include the function CoinAmount and FindCoins does not work. I have tried with coins in bank/inventory neither of which work so I am assuming trades wont work either. I have prior programming knowledge but I'm new to SRL scripting so I can't debug the function myself to fix it.

    Simba Code:
    function FindCoins(var X, Y: Integer; Area: string): Boolean;
    var
      B: TBox;
      CTS, I, J, H, L: Integer;
      Pts, tPts: TPointArray;
      ATPA: T2DPointArray;
      V: array [0..1] of TVariantArray;
    begin
      case Lowercase(Area) of
        'inv', 'inventory': B := IntToBox(MIX1, MIY1, MIX2, MIY2);
        'bank': B := IntToBox(MBx1, MBy1, MBx2, MBy2);
        'trade': B := IntToBox(323, 73, 509, 302);
        'your trade': B := IntToBox(9, 73, 196, 302);
      end;
      V[0] := [1479346, 1, 0.00, 0.00]; //Darker colour (top of coins)
      V[1] := [3722229, 7, 0.05, 0.86]; //Lighter colour (rest of the coins)
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetLength(tPts, 0);
      try
        for I := 0 to 1 do
        begin
          SetColorSpeed2Modifiers(V[I][2], V[I][3]);
          FindColorsTolerance(Pts, V[I][0], B.X1, B.Y1, B.X2, B.Y2, V[I][1]);
          if (Length(Pts) < 10) then Exit;
          ATPA := SplitTPAEx(Pts, 10, 10);
          h := High(ATPA);
          L := High(tPts) + 1;
          SetLength(tPts, L + h + 1);
          for J := 0 to H do
            tPts[L + j] := MiddleTPA(ATPA[J]);
        end;
        ATPA := SplitTPAEx(tPts, 20, 20);
        H := High(ATPA);
        for I := 0 to H do
          if (High(ATPA[I]) = 1) then
            Break;
        if (I > H) then Exit;
        Result := True;
        MiddleTPAEx(ATPA[I], X, Y);
      finally
        ColorToleranceSpeed(CTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
      end;
    end;

    Thanks. The line of code I am using to test this is as shown below.

    Simba Code:
    WriteLn('Coins found: '+toStr(CoinAmount('inv')));

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Could you post a .png picture of the coin amounts/coin stack?

  3. #3
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default PNG of Coins

    To my knowledge the function is supposed to detect the amount of coins (1 coin to 10,000+ coins) so I will upload pngs of all different coin stacks. Unfortunately this will take two posts as I am only allotted 5 pics per post.
    Attached Images Attached Images

  4. #4
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default PNG of Coins Continued

    More stacks of coins in PNG format. The function is supposed to detect all amounts of coins but ten thousand plus is the main one I need.
    Attached Images Attached Images

  5. #5
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    https://github.com/SRL/SRL-OSR/pull/124

    Don't forget to make sure you're up to date too (with the latest OSR-SRL includes).

    *(Either add the function in the pull request I linked manually, or wait until it's added to the includes and then re-download the new .zip of the includes (after the function is committed to the master SRL-OSR), extract, replace, etc.)

    Cheers
    LJ

  6. #6
    Join Date
    Apr 2013
    Location
    Las Vegas
    Posts
    111
    Mentioned
    1 Post(s)
    Quoted
    35 Post(s)

    Default

    Thanks for the help. While waiting I did devise my own function to handle the task. I am debating whether or not to release my autoSeller (to other players, not shops) but I will be using this function instead.

    Simba Code:
    function Cash(area: string): Integer;
    Var
      amount, i: integer;
      coinsDTM: TIntegerArray;
    begin
    coinsDTM := [
    DTMFromString('mbQAAAHicY2VgYHBiYmDwgWJrILYDYl1GCDYDYmMg1gbiB9ulGc6tlGA4sUSCYdNEUTAfG2DEgsEAAIpTCio='),                  // > 10,000
    DTMFromString('mbQAAAHicY2VgYHBkYmDwAWJvIDYHYmsgfg4UfwfEj4H4GZT9+bgcw7GFEgznVkow3N0qzfD+sBwDNsCIBYMBALteDk4='),          // 1,000-10,000
    DTMFromString('mggAAAHicY2NgYHBkYmBwA2IvJgjbCoitgfgFUO4REL8B4g9Q+gkQP90tzbBpoijD453SDJ+Py4HZh+dLMOACjDgwBAAAMbMQig=='),  // 250-1,000
    DTMFromString('mWAAAAHicY2FgYLBmYmAwh2I7IH4BFHsFxM+B+BkQb5ooyvD7sh+YBmF0wIiGQQAAQ7oKuw==')];                             // < 250

      for i := 0 to (length(coinsDTM) - 1) do
      begin
      amount := ItemAmount(area, 'dtm', coinsDTM[i], []);

        if (amount > 0) then
        begin
        freeDTMs(coinsDTM);
        Result := amount;
        break;
        end;

      end;

      freeDTMs(coinsDTM);

    end;
    Last edited by bob_dole; 04-24-2013 at 06:18 AM.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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