Results 1 to 8 of 8

Thread: Changing DTM back to a string

  1. #1
    Join Date
    Dec 2011
    Location
    Holland
    Posts
    545
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default Changing DTM back to a string

    Hello SRL!
    I need your help, I'm trying to do "StringFromDTM();" but that function doesn't exist and I don't think it is possible to create one (at least not in a script).
    Does anyone know how to do this? Otherwise could it be build into Simba?

    This is my script:

    Simba Code:
    program DTMTool;

    var
      BMP, DTM: Integer;

    procedure setBMPString;
    begin
      BMP := BitmapFromString(23, 28, 'meJyN1dtrHFUYAPChaZJmLQFLjL' +
            'tsSKxasUXr7aEVQ63GoE2TTZPNXHezs3M7M7Nz3Z3Z2fs1F7dtwIq' +
            'KhYBQ0HffBf+APlSUIIVWa33wQUSpIio+6De7oCdvWQ7DgZnvt+e7' +
            'MEPyGiUYVDZHZhAl5GjRoCWTUxwWORxy05qb1vO84fNmUbADwS2Jb' +
            'kXx6ihoquWWVmnr1Y5e74JAiyYrWyCwis0pdgo5fM5L64V0rpAxB+' +
            'ElwS5LbkUu1JDf0Esdo9LVYVW7VuNtp9NjRIuRQoSRLQ45KRWEomi' +
            'V4ZqBA1hBKDhlOIDs1fVSCxWbKGjp5bZR6+ZqG06r53aucLIDi5Es' +
            'TrZZxSWFEi3WGbG7xm8mM9tJ/spKeudS6t0E+16C+XCJ2V2kPrpI3' +
            'bhAfkxK13P1DafdK2zsgMACIkMizplXPyGIfw64Tj73pd/dyXevFr' +
            'feIaGkvEby+mpaeenl3YMjT5/e87o7dvMyOK+8foH4/8ccHDlx6mu' +
            'zvm03e277yrn5RQxZ3f/krwRxmyC+IohbBHFzZPSLaPx+fPqbqeN3' +
            'Z564c/b850Zty21dBmR2bgFDEvuRT7FbxPTjJ1S/pQVtrdTRgg4IR' +
            'nXThhY3e+fmE9iDCzgyPPLZxKOxydhUbGomPn38hTOzyKurxabiNa' +
            'DRueomIGZtK1fdeG1hFUPewJHY1O2sWRLCmQnEcNiqSqEBAswM8pt' +
            '6uWvWts3qplpqzy0kMeQ8jkxM3ltme8vM1WXmWoJ5f5H6YGHtejgn' +
            '5I2V9K5e6hqVTUgNFVtzC2sYMnvA1kTj30FZwFGLbdlrzF0kMeTsA' +
            'ZHJ2Peo2FaDjhqE1/klGkNePCAyMfkD8lsDB87z5gqHIaf3P/xnf0' +
            '72YE6Ghm49Er0/GbsXjd+Nz9x55vmbyGsqfhP5/ZMssxhyaj+y99+' +
            'N8YePZa2qYNd4swwtk926nK/LBUBaatB9a3UdQ57CkUOHvu3PSTwa' +
            'n37y5LMQ3hcq2XATOkoeOt4CZ5HMYshjOBI5+hMj2Wndzxil9VwAa' +
            '+BkYG/Ae6YqOlVUaEKDlmgBQ6ZwZCzyCyVatGSlUAGElOalNH89V+' +
            'yzQdaqZO2ynG8gr73ESBgSxZEjYw/gNUVJ8NJzQEhrPoSnQ8qDjES' +
            'nLjo1ya1L+UaClTHkGI6MjP7GKnkOFTiUZxSXRXlO9Ti1AJrk1ACB' +
            'OsMVnGVWwZBxHDk8/AcjuRm9mFI90MKF8pAaIJlcKSyyXR04l1Iqh' +
            'kRwZGjoLwiEXGjRpgSTUeAjUgBkcDyodr/pVcGpraY1DBnZ3+K/GR' +
            'kSgRCvH+v2w/tHUlze6HfcqohuPZnRDw8PD4+Mjh6JjEUeIogHI6O' +
            '/Q0nHIj8fHf8RBFqGakB3wqT6YB423CA11eMNeFdUkhmDEhxKsMIl' +
            'uvDX61pAClaSN0jRZhEEurTkUJCRaNPwaVDcPhVWhgtLHeZF8mZK8' +
            'dd4Y2Vdo6U8LblrWRMECIENI7swGynVh0BYFNQHHFRgBmfTvLBKmv' +
            'cv5tN+3Q==');
    end;

    function MakeDTM(BMP: Integer): Integer;
    var
      DtmMainPoint: TSDTMPointDef;
      DtmPoints: array of TSDTMPointDef;
      TempTDTM: TSDTM;
      TPA: TPointArray;
      i, idx, BMPW, BMPH: Integer;
    begin
      Result := 0;
      GetBitmapSize(BMP, BMPW, BMPH);
      Writeln('Making DDTM');
      idx := SetTargetBitmap(BMP);
      if not FindColors(TPA, 255, 0, 0, BMPW - 1, BMPH - 1) then
        TerminateScript;
      FreeTarget(idx);
      FreeBitmap(BMP);

      DtmMainPoint.x := TPA[0].x;
      DtmMainPoint.y := TPA[0].y;
      DtmMainPoint.AreaSize := 1;
      DtmMainPoint.AreaShape := 0;
      DtmMainPoint.Color := 255;
      DtmMainPoint.Tolerance := 0;

      SetLength(DtmPoints, Length(TPA));
      for i := 1 to High(TPA) do
      begin
        DtmPoints[i].x := TPA[i].x;
        DtmPoints[i].y := TPA[i].y;
        DtmPoints[i].AreaSize := 0;
        DtmPoints[i].AreaShape := 0;
        DtmPoints[i].Color := 255;
        DtmPoints[i].Tolerance := 0;
      end;

      TempTDTM.MainPoint := DtmMainPoint;
      TempTDTM.SubPoints := DtmPoints;
      Result := AddSDTM(TempTDTM);
    end;

    begin
      SetBMPString;
      DTM := MakeDTM(BMP);
      // Writeln(StringFromDTM(DTM))?
      FreeDTM(DTM);
    end.

    Thanks for even looking at this thread

  2. #2
    Join Date
    Dec 2011
    Location
    Nj
    Posts
    2,341
    Mentioned
    1 Post(s)
    Quoted
    18 Post(s)

    Default

    Im a bit slow in the morning, but if you have the points, or know where it goes, or have the DTM, then couldn't you just use the tool?

    Like give an example of when you would need it.
    ~Rez

    For the basics of the basics of pascal, try my TuT. ||Photoshop Editing ||MapleResourceDung Script || Book a flight! BuySellTrip

  3. #3
    Join Date
    Dec 2011
    Location
    Holland
    Posts
    545
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by Rezozo View Post
    Im a bit slow in the morning, but if you have the points, or know where it goes, or have the DTM, then couldn't you just use the tool?

    Like give an example of when you would need it.
    ~Rez
    Yes. I could save the TPA and use that in my script to assemble the DTM. Though it should be possible to print the DTM as a string imo. (That will be faster in run-time)

  4. #4
    Join Date
    Nov 2010
    Location
    Australia
    Posts
    1,472
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

  5. #5
    Join Date
    Dec 2011
    Location
    Holland
    Posts
    545
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by KingKong View Post
    dtmtostring?
    Doesn't exist..

  6. #6
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    Is the code for DTMFromString available anywhere? I can't find it, but if it's somewhere out there, it shouldn't be too difficult to just reverse engineer it and write your own DTMToString function.

  7. #7
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Hey Chris,

    I did some research and it is possible I have never seen someone using it though but it does work.

    Example:
    Simba Code:
    program Test;
    {$i srl/srl.simba}


    function DTMToString(DTM: Integer): String;
    begin
      Result := GetDTM(DTM).ToString;
      writeln('Result: ' + Result);
    end;

    procedure DTMTest;
    var
      DTM: Integer;
      Test: TMDTM;

    begin
      DTM := DTMFromString('mWAAAAHicY2FgYOhgZGDIBOKzQDwFiI8Cxb4C8T8gfg3E////R8HogBENgwAAsaUR9g==');
      DTMToString(DTM);
      FreeDTM(DTM);
    end;

    begin
      SetupSRL;
      DTMTest;
    end.

    After running:
    SRL Compiled in 16 msec
    Result: mWAAAAHicY2GAgIf///93BdI8UL4BEFsCsRoQA6VQMDpgRMMgAACE7xC7
    Successfully executed.

    You convert the DTM to a TMDTM. That is a type like a DTM but you can do some fun stuff with it such as converting it to a String.

    EDIT: We might have overlooked something in the documents, but I don't think this existed yet. Might be nice to add to SRL.

    Script source code available here: Github

  8. #8
    Join Date
    Dec 2011
    Location
    Holland
    Posts
    545
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default

    Thanks J J, that's exactly what I need!

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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