Page 5 of 5 FirstFirst ... 345
Results 101 to 105 of 105

Thread: TMufasaLayer - Draw on any window!

  1. #101
    Join Date
    Jan 2013
    Posts
    86
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    The startup issue seems fixed, good job.

    Any idea on how to put AeroLibs MsToTime(GetTimeRunning...) on a GUI, or even make it writeln the time running? Every time I try to do that it crashes Simba. Weird thing is,
    Code:
    MsToTime(Timer.TimeElapsed, 3)
    works perfectly, and as long as it isn't on a layer MsToTime(GetTimeRunning, 3); works fine.

    No rush, loving the include btw. <3


    Crash:
    Code:
    {$i Aerolib/AeroLib.simba}
    {$i Layer/Layer.simba}
    var
      T : Timer;
    
    procedure OnClick(X, Y: Int32; var Block: Boolean);
    begin
      //Client.WriteLn(MsToTime(T.TimeElapsed, 3));
      Client.Writeln(MsToTime(GetTimeRunning, 3));
      Client.WriteLn('Click @ ' + IntToStr(X) + ', ' + IntToStr(Y));
    end;
    
    begin
      T.Start();
      Layer.OnClick(@OnClick);
      Layer.Bitmap.Rectangle(IntToBox(50, 50, 250, 250), 255);
      Layer.Paint();
    
      while True do Continue;
    end.

    No crash:
    Code:
    {$i Aerolib/AeroLib.simba}
    {$i Layer/Layer.simba}
    var
      T : Timer;
    
    procedure OnClick(X, Y: Int32; var Block: Boolean);
    begin
      Client.WriteLn(MsToTime(T.TimeElapsed, 3));
      //Client.Writeln(MsToTime(GetTimeRunning, 3));
      Client.WriteLn('Click @ ' + IntToStr(X) + ', ' + IntToStr(Y));
    end;
    
    begin
      T.Start();
      Layer.OnClick(@OnClick);
      Layer.Bitmap.Rectangle(IntToBox(50, 50, 250, 250), 255);
      Layer.Paint();
    
      while True do Continue;
    end.

  2. #102
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by deejaay View Post
    Any idea on how to put AeroLibs MsToTime(GetTimeRunning...) on a GUI, or even make it writeln the time running? Every time I try to do that it crashes Simba. Weird thing is,
    Code:
    MsToTime(Timer.TimeElapsed, 3)
    works perfectly, and as long as it isn't on a layer MsToTime(GetTimeRunning, 3); works fine.
    This is a Simba limitation. As the callback is executed on a separate thread, while GetTimeRunning is being executed on the main thread, and you can't reach that method through "client" to solve it.
    In short, it can't be done with GetTimeRunning.

    What I think you can do is:
    Simba Code:
    var SCRIPT_START:Int64 := GetTickCount();

    function GetTimeRunning(): LongWord; override; //override the original GetTimeRunning
    begin
      Result := GetTickCount() - SCRIPT_START;
    end;
    I think that should do the trick, as GetTickCount should support threading.
    !No priv. messages please

  3. #103
    Join Date
    Jan 2013
    Posts
    86
    Mentioned
    0 Post(s)
    Quoted
    25 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    This is a Simba limitation. As the callback is executed on a separate thread, while GetTimeRunning is being executed on the main thread, and you can't reach that method through "client" to solve it.
    In short, it can't be done with GetTimeRunning.

    What I think you can do is:
    Simba Code:
    var SCRIPT_START:Int64 := GetTickCount();

    function GetTimeRunning(): LongWord; override; //override the original GetTimeRunning
    begin
      Result := GetTickCount() - SCRIPT_START;
    end;
    I think that should do the trick, as GetTickCount should support threading.
    That did work, thanks for the information!

  4. #104
    Join Date
    Oct 2017
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    13 Post(s)

    Default

    when i try to compile my script i get this error. error: Duplicate declaration "Layer" at line 12. the line is var
    Layer : TMufasaLayer;

  5. #105
    Join Date
    Dec 2011
    Location
    East Coast, USA
    Posts
    4,231
    Mentioned
    112 Post(s)
    Quoted
    1869 Post(s)

    Default

    Quote Originally Posted by rishula View Post
    when i try to compile my script i get this error. error: Duplicate declaration "Layer" at line 12. the line is var
    Layer : TMufasaLayer;
    We would have to see the whole script to fix the error, you've got something else in there called "Layer"
    GitLab projects | Simba 1.4 | Find me on IRC or Discord | ScapeRune scripts | Come play bot ScapeRune!

    <BenLand100> we're just in the transitional phase where society reclassifies guns as Badâ„¢ before everyone gets laser pistols

Page 5 of 5 FirstFirst ... 345

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
  •