Page 1 of 2 12 LastLast
Results 1 to 25 of 37

Thread: Recreate Procedures - Forum game

  1. #1
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default Recreate Procedures - Forum game

    The aim of this game is to recreate procedures/functions already in SCAR

    This thread has no use except to have fun

    rules :
    1. All procedures/functions must have the same number of parimeters and must do exactly the same thing
    2. all procedures/functions must be called the same thing with a 2 added , e.g. function pos2(substr,str:string):integer;

    this is an example

    SCAR Code:
    function pos2(substr,str:string):integer;
    var f:integer;
    begin
    for f:=1 to length(str) do
     begin
     if(copy(str,f,length(substr))=substr)then
      begin
      result:=f
      break
      end
     end
    end;

    post away!
    Join the Official SRL IRC channel. Learn how to Here.

  2. #2
    Join Date
    Feb 2006
    Posts
    241
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    Function LowerCase2(Text : String) : String;
     Var
       I : Integer;
       Char : String;
     Begin
       For I := 1 To Length(Text) Do
        Begin
          Char := Copy(Text, I, 1);
          Case Char Of
            'A' : Char := 'a';
            'B' : Char := 'b';
            'C' : Char := 'c';
            'D' : Char := 'd';
            'E' : Char := 'e';
            'F' : Char := 'f';
            'G' : Char := 'g';
            'H' : Char := 'h';
            'I' : Char := 'i';
            'J' : Char := 'j';
            'K' : Char := 'k';
            'L' : Char := 'l';
            'M' : Char := 'm';
            'N' : Char := 'n';
            'O' : Char := 'o';
            'P' : Char := 'p';
            'Q' : Char := 'q';
            'R' : Char := 'r';
            'S' : Char := 's';
            'T' : Char := 't';
            'U' : Char := 'u';
            'V' : Char := 'v';
            'W' : Char := 'w';
            'X' : Char := 'x';
            'Y' : Char := 'w';
            'Z' : Char := 'z';
          End;
          Result := Result + Char;
        End;
     End;

  3. #3
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    lowercase, intresting

    heres an easy one, although its probably cheating a little bit

    SCAR Code:
    function pi2:extended;
    begin
    result:=3.14159265358979
    end;
    Join the Official SRL IRC channel. Learn how to Here.

  4. #4
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Here you go

    Code:
    procedure ClickMouse2(x, y: integer; Left: boolean);
    begin
      holdmouse(x, y, Left)
      releasemouse(x, y, Left)
    end;
    Or better one...

    Code:
    procedure ClickMouse2(x, y: integer; Left: boolean);
    begin
      holdmouse(x, y, Left)
      wait(20 + random(15))
      releasemouse(x, y, Left)
    end;
    Nice game

  5. #5
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    nice one LaBo, it gave me some inspiration

    SCAR Code:
    procedure sendkeys2(s:string);
    var f:integer;
    begin
    for f:=1 to length(s) do
     begin
     keydown(getkeycode(s[f]))
     keyup(getkeycode(s[f]))
     end
    end;

    [annoying]also i dont mean to be annoying but your second "clickmouse2" doesnt count because it breaks rule 1, the real procedure doesnt have the wait[/annoying]
    Join the Official SRL IRC channel. Learn how to Here.

  6. #6
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    this is my attempt at something more ambitious, didnt work
    the difference between the real result and my result was always different
    good luck if you want to try something similar

    SCAR Code:
    function detectrs2minimapcompassangle2:extended;
    var cdtm,xk,yk:integer;
    begin
    cdtm:= DTMFromString('78DA6334676260106140038C482490D605AA1' +
           '14455218DA212483B02D5881250630954C385AAC61E5D8D29508D' +
           '1C7E7300C565021B');
    if(not FindDTMRotated(cdtm,xk,yk,535,0,586,30,0,pi*2,0.0001,result))then
     result:=-1
     else
     result:=result-5.93750444015012
    end;      //my attempt the callibrate
    Join the Official SRL IRC channel. Learn how to Here.

  7. #7
    Join Date
    Feb 2006
    Location
    Helsinki, Finland
    Posts
    1,395
    Mentioned
    30 Post(s)
    Quoted
    107 Post(s)

    Default

    Nice nice

    By the way, I even had to check if that ''detectrs2mini...'' is even added to SCAR, and oh hell yeah it is. (I don't use SCAR for RuneScape, that's why I didn't know about it. )

  8. #8
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    heres another one, i acctualy already invented something like this called savescreenshotarea and put it in SRL functions, i just changed some things and put it in this thread. enjoy

    SCAR Code:
    procedure savescreenshot2(path:string);
    var bmp,w,h:integer;
    begin
    GetClientDimensions(w,h)
    bmp:=bitmapfromstring(w,h,'')
    safecopycanvas(getclientcanvas,getbitmapcanvas(bmp),0,0,w,h,0,0,w,h)
    savebitmap(bmp,path)
    freebitmap(bmp)
    end;
    Join the Official SRL IRC channel. Learn how to Here.

  9. #9
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    I like this thread

    SCAR Code:
    function Abs2(e: extended): extended;
    begin
      result := e;
      if(result < 0) then
        result := -e;
    end;

    function AMax2(Data: TIntegerArray): Integer;
    var
      i, hi: integer;
    begin
      hi := High(Data);
      result := Data[0];
      if(hi = 0) then //Array of length 1
        Exit;
       
      for i := 1 to hi do
        if(Data[i] > result) then
          result := Data[i];
    end;

    function AMaxE2(Data: TExtendedArray): Extended;
    var
      i, hi: integer;
    begin
      hi := High(Data);
      result := Data[0];
      if(hi = 0) then //Array of length 1
        Exit;

      for i := 1 to hi do
        if(Data[i] > result) then
          result := Data[i];
    end;
    Interested in C# and Electrical Engineering? This might interest you.

  10. #10
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function Between2(s1, s2, s: String): String;
    begin
      Result := Copy(s, Pos(s1, s) + 1, (Pos(s2, s) - Pos(s1, s)) - 1);
    end;

    function GetNumbers2(Text: String): String;
    var
      i: Integer;
     
    begin
      for i := 1 to Length(Text) do
       try Result := Result + IntToStr(StrToInt(Text[i])) except end;
    end;
    lol

  11. #11
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    NICE BUMP, Smartzkid


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  12. #12
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    so what? fun thread...
    SCAR Code:
    procedure Inc2( e : integer);
    begin
      e := e + 1;
    end;

    procedure IncEx2( e, addvalue : integer);
    begin
      e := e + addvalue;
    end;

    procedure Dec2( e : integer);
    begin
      e := e - 1;
    end;

    procedure DecEx2( e, decvalue : integer);
    begin
      e := e - decvalue;
    end;

    Trains scripting skills... the above states that I am a 1337 script0r xD
    There is nothing right in my left brain and there is nothing left in my right brain.

  13. #13
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function Padr2(s : AnyString; i : integer) : AnyString;
    begin
      result := s + Replicate(' ', i - length(s));
    end;
    (h)

  14. #14
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Pure1993 View Post
    so what? fun thread...
    SCAR Code:
    procedure Inc2( e : integer);
    begin
      e := e + 1;
    end;

    procedure IncEx2( e, addvalue : integer);
    begin
      e := e + addvalue;
    end;

    procedure Dec2( e : integer);
    begin
      e := e - 1;
    end;

    procedure DecEx2( e, decvalue : integer);
    begin
      e := e - decvalue;
    end;

    Trains scripting skills... the above states that I am a 1337 script0r xD
    There needs to be var before the e param.
    lol

  15. #15
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Or else they are useless because it is just modifying the local variable.

  16. #16
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    function sec2(X: extended): extended;
    begin
      result := 1/cos(x);
    end;

    function cos2(X: extended): extended;
    begin
      result := 1/sec(x);
    end;

    function sin2(X: extended): extended;
    begin
      result := 1/csc(x);
    end;

    function csc2(X: extended): extended;
    begin
      result := 1/sin(x);
    end;

    function tan2(X: extended): extended;
    begin
      result := 1/cot(x);
    end;

    function cot2(X: extended): extended;
    begin
      result := 1/tan(x);
    end;
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  17. #17
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You could recreate the ones you did with the other ones you did lmao .

  18. #18
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Haha. Dan Cardin you cheater!
    Interested in C# and Electrical Engineering? This might interest you.

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

    Default

    SCAR Code:
    program New;

    function InRange(Value, Min, Max: Integer): Boolean;
    begin
      Result := (Value >= Min) and (Value <= Max);
    end;

    function UpperCase(c: string): string;
    var
      i, t: Integer;
    begin
      Result := c;
      for i := 1 to Length(c) do
      begin
        t := Ord(c[i]);
        if InRange(t, 97, 122) then
          Result[i] := Chr(t - 32);
      end;
    end;

    function LowerCase(c: string): string;
    var
      i, t: Integer;
    begin
      Result := c;
      for i := 1 to Length(c) do
      begin
        t := Ord(c[i]);
        if InRange(t, 65, 90) then
          Result[i] := Chr(t + 32);
      end;
    end;

    function GetLetters(s: string): string;
    var
      i: Integer;
    begin
      Result := '';
      for i := 1 to Length(s) do
        case s[i] of
          'a'..'z', 'A'..'Z': Result := Result + s[i];
        end;
    end;

    function GetNumbers(s: string): string;
    var
      i: Integer;
    begin
      Result := '';
      for i := 1 to Length(s) do
        case s[i] of
          '0'..'9': Result := Result + s[i];
        end;
    end;

    function GetOthers(s: string): string;
    var
      i: Integer;
    begin
      Result := '';
      for i := 1 to Length(s) do
      begin
        case s[i] of
          '0'..'9', 'a'..'z', 'A'..'Z': Continue;
        end;
        Result := Result + s[i];
      end;
    end;

    function TrimLetters(s: string): string;
    var
      i: Integer;
    begin
      Result := '';
      for i := 1 to Length(s) do
      begin
        case s[i] of
          'a'..'z', 'A'..'Z': Continue;
        end;
        Result := Result + s[i];
      end;
    end;

    function TrimNumbers(s: string): string;
    var
      i: Integer;
    begin
      Result := '';
      for i := 1 to Length(s) do
      begin
        case s[i] of
          '0'..'9': Continue;
        end;
        Result := Result + s[i];
      end;
    end;

    function TrimOthers(s: string): string;
    var
      i: Integer;
    begin
      Result := '';
      for i := 1 to Length(s) do
        case s[i] of
          '0'..'9', 'a'..'z', 'A'..'Z': Result := Result + s[i];
        end;
    end;

    begin
      WriteLn(BoolToStr(InRange(10, 5, 15)));
      WriteLn(LowerCase('HaI!@#'));
      WriteLn(UpperCase('HaI!@#'));
      WriteLn(GetLetters('ohai123!@#'));
      WriteLn(GetNumbers('ohai123!@#'));
      WriteLn(GetOthers('ohai123!@#'));
      WriteLn(TrimLetters('ohai123!@#'));
      WriteLn(TrimNumbers('ohai123!@#'));
      WriteLn(TrimOthers('ohai123!@#'));
    end.

  20. #20
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    So, which programming language can these functions/procedures be in? Pascal (SCAR), Delphi or C++? Or all?

    pascal Code:
    type
      Float = Extended;
      TFloatArray = array of Float;

    function Average(TFP: TFloatArray): Extended;
    var
      i, bI: Integer;
    begin
      Result := 0.0;
      bI := High(TFP);
      for i := 0 to bI do
        Result := Result + TFP[i];
      Result := Result / bI + 1.0;
    end;

    function Abs(i: Integer): Integer;
    begin
      Result := i * -1;
    end;

    procedure Swap(var A, B: Integer);
    var
      I: Integer;
    begin
      I := A;
      A := B;
      B := I;
    end;

    function Pow(I, Exponent: Integer): Integer;
    var
      D: Integer;
    begin
      Result := I;
      for D := 1 to Exponent do
        Result := Result * I;
    end;

    function InRange(V: Integer; Min: Integer; Max: Integer): Boolean;
    begin
      Result := ((V >= Min) and (V <= Max));
    end;

    function PadR(S: String; I: Integer): String;
    var
      D, bI: Integer;
    begin
      bI := Length(S);
      Result := S;
      if(bI >= I) then
        Exit;
      for D := 1 to I - bI do
        Result := Result + ' ';
    end;

    function PadL(S: String; I: Integer): String;
    var
      D, bI: Integer;
    begin
      bI := Length(S);
      if(bI >= I) then
      begin
        Result := S;
        Exit;
      end;
      for D := 1 to I - bI do
        Result := Result + ' ';
      Result := Result + S;
    end;

    function PadZ(S: String; I: Integer): String;
    var
      D, bI: Integer;
    begin
      bI := Length(S);
      if(bI >= I) then
      begin
        Result := S;
        Exit;
      end;
      for D := 1 to I - bI do
        Result := Result + '0';
      Result := Result + S;
    end;

    function GetNumbers(Text: String): String;
    var
      i, BI, sI, nBI: Integer;
    const
      Numbers = '0123456789';
    begin
      BI := Length(Text);
      for i:=1 to BI do
        for sI:=1 to 10 do
          if(Text[i] = Numbers[sI]) then
          begin
            Result := Result + Numbers[sI];
            Break;
          end;
    end;

    function GetLetters(Text: String): String;
    var
      i, BI, sI, nBI: Integer;
    const
      Letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    begin
      BI := Length(Text);
      nbI := Length(Letters);
      for i:=1 to BI do
        for sI:=1 to nbI do
          if(Text[i] = Letters[sI]) then
          begin
            Result := Result + Letters[sI];
            Break;
          end;
    end;

    function GetOthers(Text: String): String;
    var
      i, bI, sI, nBI: Integer;
    const
      NumLet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    begin
      bI := Length(Text);
      nbI := Length(NumLet);
      for i:=1 to bI do
        for sI:=1 to nbI do
          if(not(Text[i] = NumLet[sI])) then
          begin
            Result := Result + Text[i];
            Break;
          end;
    end;

    Last edited by Daniel; 06-11-2009 at 06:14 PM.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  21. #21
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Talking

    Quote Originally Posted by Dan's The Man View Post
    So, which programming language can these functions/procedures be in? Pascal (SCAR), Delphi or C++? Or all?

    pascal Code:
    type
      Float = Extended;
      TFloatArray = array of Float;

    function Average(TFP: TFloatArray): Extended;
    var
      i, bI: Integer;
    begin
      Result := 0.0;
      bI := High(TFP);
      for i := 0 to bI do
        Result := Result + TFP[i];
      Result := Result / bI + 1.0;
    end;

    function Abs(i: Integer): Integer;
    begin
      Result := i * -1;
    end;

    procedure Swap(var A, B: Integer);
    var
      I: Integer;
    begin
      I := A;
      A := B;
      B := I;
    end;

    function Pow(I, Exponent: Integer): Integer;
    var
      D: Integer;
    begin
      Result := I;
      for D := 1 to Exponent do
        Result := Result * I;
    end;

    function InRange(V: Integer; Min: Integer; Max: Integer): Boolean;
    begin
      Result := ((V >= Min) and (V <= Max));
    end;

    function PadR(S: String; I: Integer): String;
    var
      D, bI: Integer;
    begin
      bI := Length(S);
      Result := S;
      if(bI >= I) then
        Exit;
      for D := 1 to I - bI do
        Result := Result + ' ';
    end;

    function PadL(S: String; I: Integer): String;
    var
      D, bI: Integer;
    begin
      bI := Length(S);
      if(bI >= I) then
      begin
        Result := S;
        Exit;
      end;
      for D := 1 to I - bI do
        Result := Result + ' ';
      Result := Result + S;
    end;

    function PadZ(S: String; I: Integer): String;
    var
      D, bI: Integer;
    begin
      bI := Length(S);
      if(bI >= I) then
      begin
        Result := S;
        Exit;
      end;
      for D := 1 to I - bI do
        Result := Result + '0';
      Result := Result + S;
    end;

    function GetNumbers(Text: String): String;
    var
      i, BI, sI, nBI: Integer;
    const
      Numbers = '0123456789';
    begin
      BI := Length(Text);
      for i:=1 to BI do
        for sI:=1 to 10 do
          if(Text[i] = Numbers[sI]) then
          begin
            Result := Result + Numbers[sI];
            Break;
          end;
    end;

    function GetLetters(Text: String): String;
    var
      i, BI, sI, nBI: Integer;
    const
      Letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    begin
      BI := Length(Text);
      nbI := Length(Letters);
      for i:=1 to BI do
        for sI:=1 to nbI do
          if(Text[i] = Letters[sI]) then
          begin
            Result := Result + Letters[sI];
            Break;
          end;
    end;

    function GetOthers(Text: String): String;
    var
      i, bI, sI, nBI: Integer;
    const
      NumLet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    begin
      bI := Length(Text);
      nbI := Length(NumLet);
      for i:=1 to bI do
        for sI:=1 to nbI do
          if(not(Text[i] = NumLet[sI])) then
          begin
            Result := Result + Text[i];
            Break;
          end;
    end;

    Your cheated on your Pow, and your Abs is incorrect
    Verrekte Koekwous

  22. #22
    Join Date
    Jan 2007
    Location
    Tennessee
    Posts
    642
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    SCAR Code:
    function Abs2(x: extended): extended;
    begin
      Result:= x;
      if (Result < 0) then
      Result:= Result + ((Result * -1) * 2);
    end;
    There it is.
    I used to have a load of these that weren't in SCAR, but when they come out I usually get rid of them.

  23. #23
    Join Date
    Apr 2007
    Posts
    3,152
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    i was trying to get a real sin2 working, but i wrote the whole thing before i tested and i cant get it to work any more accurately. So i have this

    SCAR Code:
    function sin2(X: extended): extended;
    var i,a,e,r,m: integer;
        s: string;
    begin
      x := Radians(x);
      i := 1;
      repeat
        i := i + 2;
        if a mod 2 <> 0 then
          m := 1
        else
          m := -1;
        x := x + m*(pow(x, i)/fract(i));
        writeln(x);
        a := a + 1;
      until a >= 10;
      result := x;
    end;
    SCAR Tutorials: The Form Tutorial | Types, Arrays, and Classes
    Programming Projects: NotePad | Tetris | Chess


  24. #24
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function PadR(S: String; I: Integer): String;
    var
      D, bI: Integer;
    begin
      bI := Length(S);
      Result := S;
      if(bI >= I) then
        Exit;
      for D := 1 to I - bI do
        Result := Result + ' ';
    end;
    Hmm, you could use my one liner, right?
    SCAR Code:
    function Padr2(s : AnyString; i : integer) : AnyString;
    begin
      result := s + Replicate(' ', i - length(s));
    end;

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

    Default

    Quote Originally Posted by almost View Post
    SCAR Code:
    function Abs2(x: extended): extended;
    begin
      Result:= x;
      if (Result < 0) then
      Result:= Result + ((Result * -1) * 2);
    end;
    There it is.
    I used to have a load of these that weren't in SCAR, but when they come out I usually get rid of them.
    if (x < 0) then
    Result := -x
    else
    Result := x;

    Would do?

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. procedures
    By elobire in forum OSR Help
    Replies: 4
    Last Post: 12-24-2008, 02:35 PM
  2. my first Java game (shooter game)
    By Lorax in forum Java Help and Tutorials
    Replies: 19
    Last Post: 08-18-2008, 10:48 PM
  3. The Word Game Game
    By Putnam in forum The Bashing Club / BBQ Pit
    Replies: 5
    Last Post: 04-02-2008, 03:07 AM

Posting Permissions

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