Results 1 to 19 of 19

Thread: Boxes in Globals.scar

  1. #1
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default Boxes in Globals.scar

    SCAR Code:
    function MSBox: TBox;
    begin
      with Result do
      begin
        x1 := MSX1;
        y1 := MSY1;
        x2 := MSX2;
        y2 := MSY2;
      end;
    end;

    function MMBox: TBox;
    begin
      with Result do
      begin
        x1 := MMX1;
        y1 := MMY1;
        x2 := MMX2;
        y2 := MMY2;
      end;
    end;

    function MIBox: TBox;
    begin
      with Result do
      begin
        x1 := MIX1;
        y1 := MIY1;
        x2 := MIX2;
        y2 := MIY2;
      end;
    end;

    function MCBox: TBox;
    begin
      with Result do
      begin
        x1 := MCX1;
        y1 := MCY1;
        x2 := MCX2;
        y2 := MCY2;
      end;
    end;

    Very often I would rather pass a TBox to my functions than 4 coords, as I find it helps with readability and scripting speed. Which is why I suggest that these be added to globals.scar

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  2. #2
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Why not use IntToBox
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  3. #3
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    Why not use IntToBox
    Same shit?

    Actually, using the type is faster.
    SCAR Code:
    program new;

    function MSBox: TBox;
    begin
      with Result do
      begin
        x1 := 1;
        y1 := 2;
        x2 := 3;
        y2 := 4;
      end;
    end;

    function MSBox2: TBox;
    begin
      Result := IntToBox(1, 2, 3, 4);
    end;

    var i, t: integer;
    begin
      t := GetSystemTime;
      for i:= 0 to 10000 do
        MSBox;
      writeln(GetSystemTime - t);

      t := GetSystemTime;
      for i:= 0 to 10000 do
        MSBox2;
      writeln(GetSystemTime - t);
    end.

    Compiled succesfully in 62 ms.
    93
    140
    Successfully executed.
    I also find it more readable, using the type.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  4. #4
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Nava2 View Post
    Why not use IntToBox
    Stop trying to make common sense.

    Code:
    Function MSBox: TBox;
    begin
      Result := IntToBox(MSX1, MSY1, MSX2, MSY2);
    end;
    wat

    Edit: @RM
    Like your going to notice 0.0032ms...
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  5. #5
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Why not use vars if you want speed?

  6. #6
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    Why not use vars if you want speed?
    How so?

    Quote Originally Posted by Narcle View Post
    Edit: @RM
    Like your going to notice 0.0032ms...
    Like your going to care what it looks like. Might as well make it faster.
    Still find it more readable as a type.

    edit:
    Nielsie, did you mean:
    SCAR Code:
    function GetMSBox: TBox;
    begin
      with Result do
      begin
        x1 := MSX1;
        y1 := MSY1;
        x2 := MSX2;
        y2 := MSY2;
      end;
    end;

    function GetMMBox: TBox;
    begin
      with Result do
      begin
        x1 := MMX1;
        y1 := MMY1;
        x2 := MMX2;
        y2 := MMY2;
      end;
    end;

    function GetMIBox: TBox;
    begin
      with Result do
      begin
        x1 := MIX1;
        y1 := MIY1;
        x2 := MIX2;
        y2 := MIY2;
      end;
    end;

    function GetMCBox: TBox;
    begin
      with Result do
      begin
        x1 := MCX1;
        y1 := MCY1;
        x2 := MCX2;
        y2 := MCY2;
      end;
    end;

    var
      MSBox,
      MMBox,
      MIBox,
      MCBox: TBox;

    Procedure SetupBoxes;
    begin
      MSBox := GetMSBox;
      MMBox := GetMMBox;
      MIBox := GetMIBox;
      MCBox := GetMCBox;
    end;

    ~RM
    Last edited by Sir R. M8gic1an; 06-11-2010 at 01:02 PM.

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  7. #7
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    var MSBox: TBox;

    is a lot faster than calling a function. The downside is that it needs initializing.

  8. #8
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    var MSBox: TBox;

    is a lot faster than calling a function. The downside is that it needs initializing.
    yeah, I figured that's what you meant.
    I guess it could always be initialized in SetupSRL ?

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  9. #9
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Var MSBox: TBox;

    MSBox := IntToBox(MSX1, MSY1, MSX2, MSY2);

    Idk looks nicer imo... and would be faster.

    edit:
    This kinda ties into my post for SRL 5
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  10. #10
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    SCAR Code:
    { MainScreen, Minimap, Inventory, Chat, Bank boxes as TBox }
    var
      MSBox, MMBox, MIBox, MCBox, MBBox: TBox;

    {These next functions get the Boxes setup as consts into TBoxes}
    function GetMSBox: TBox;
    begin
      Result := IntToBox(MSX1, MSY1, MSX2, MSY2);
    end;

    function GetMMBox: TBox;
    begin
      Result := IntToBox(MMX1, MMY1, MMX2, MMY2);
    end;

    function GetMIBox: TBox;
    begin
      Result := IntToBox(MIX1, MIY1, MIX2, MIY2);
    end;

    function GetMCBox: TBox;
    begin
      Result := IntToBox(MCX1, MCY1, MCX2, MCY2);
    end;

    function GetMBBox: TBox;
    begin
      Result := IntToBox(MBX1, MBY1, MBX2, MBY2);
    end;

    Procedure SetupBoxes;
    begin
      MSBox := GetMSBox;
      MMBox := GetMMBox;
      MIBox := GetMIBox;
      MCBox := GetMCBox;
      MBBox := GetMBBox;
    end;

    commited. Post later. edited srl.scar accordingly.

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  11. #11
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Now to make all color searching functions accept TBoxes as params..

  12. #12
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    That doesn't make any sence, why not make it:
    SCAR Code:
    { MainScreen, Minimap, Inventory, Chat, Bank boxes as TBox }
    var
      MSBox, MMBox, MIBox, MCBox, MBBox: TBox;

    MSBox:=IntToBox(MSX1, MSY1, MSX2, MSY2);
    MMBox:=IntToBox(MMX1, MMY1, MMX2, MMY2);
    MIBox:= IntToBox(MIX1, MIY1, MIX2, MIY2);
    MCBox:= IntToBox(MCX1, MCY1, MCX2, MCY2);
    MBBox:= IntToBox(MBX1, MBY1, MBX2, MBY2);

  13. #13
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by MylesMadness View Post
    That doesn't make any sence, why not make it:
    SCAR Code:
    { MainScreen, Minimap, Inventory, Chat, Bank boxes as TBox }
    var
      MSBox, MMBox, MIBox, MCBox, MBBox: TBox;

    MSBox:=IntToBox(MSX1, MSY1, MSX2, MSY2);
    MMBox:=IntToBox(MMX1, MMY1, MMX2, MMY2);
    MIBox:= IntToBox(MIX1, MIY1, MIX2, MIY2);
    MCBox:= IntToBox(MCX1, MCY1, MCX2, MCY2);
    MBBox:= IntToBox(MBX1, MBY1, MBX2, MBY2);
    indeed

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  14. #14
    Join Date
    Dec 2009
    Location
    Newcastle, Australia
    Posts
    888
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    or why not constants? (Can you declare TBoxes as constants?)

    Current Script Project
    Pot of flour gatherer - 95% done

    Can't get Simba to work? Click here for a tutorial

  15. #15
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by EvilChicken! View Post
    Now to make all color searching functions accept TBoxes as params..
    or just use TBox.x1, TBox.y1 etc.?

    I like this addition.

  16. #16
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    I like this addition as well, but Myles definitely has it right

    I was curious why you had it as functions myself.

    I wish we could have a dynamically typed language where we could just have the same params and pass it.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  17. #17
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    or just use TBox.x1, TBox.y1 etc.?

    I like this addition.
    .. what is the real point of writing "FindColor(Tro, lolo, TBox.x1, TBox.y1, ect.." when that just extends the length of the code?
    Or am I missing something here?

    I like this update too, that's not it; I just think it'd be nice if such functions could accept TBoxes as well, would save some time writing those damn coords over and over again.

  18. #18
    Join Date
    Jul 2007
    Location
    Right now? Chair.
    Posts
    8,488
    Mentioned
    3 Post(s)
    Quoted
    12 Post(s)

    Default

    Quote Originally Posted by EvilChicken! View Post
    .. what is the real point of writing "FindColor(Tro, lolo, TBox.x1, TBox.y1, ect.." when that just extends the length of the code?
    Or am I missing something here?

    I like this update too, that's not it; I just think it'd be nice if such functions could accept TBoxes as well, would save some time writing those damn coords over and over again.
    Just wrap them.. that's what I do in my scripts...

    ~RM

    I & I know Zion. It is in the spirit, body and mind of every one of us
    RMouse(obj: TMSIObject): boolean;

  19. #19
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by EvilChicken! View Post
    .. what is the real point of writing "FindColor(Tro, lolo, TBox.x1, TBox.y1, ect.." when that just extends the length of the code?
    Or am I missing something here?

    I like this update too, that's not it; I just think it'd be nice if such functions could accept TBoxes as well, would save some time writing those damn coords over and over again.
    Yes that's fine, I just thought you were sarcastically saying we needed to make the params take TBoxes for this to work. My apologies.

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
  •