Results 1 to 6 of 6

Thread: Error in Function

  1. #1
    Join Date
    Mar 2012
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Error in Function

    I am trying to learn how to script, I had this simple script working before my pc crashed and I can't seeme to find the problem. Not using SMART, using browser rs

    Code:
    program PowerChoper;
    //{$DEFINE SMART}
    {$i SRL\SRL.simba}
    
    Const
    BreakEvery= 120; // How many minutes to break after.
    BreakFor= '5'; // How long to break for.
    
    Function Woodcutter;
    Var
      x, y:Integer;
    Begin
      //FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5;
      If FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30) Then
      WriteLn('Found Tree');
    End;     
    begin
    SetupSRL:
    Smart_Members := False;
    Smart_Server := 0;
    Smart_Signed := True;
    Smart_SuperDetail := False;
    Woodcutter;
    end.

  2. #2
    Join Date
    Dec 2011
    Location
    Hyrule
    Posts
    8,662
    Mentioned
    179 Post(s)
    Quoted
    1870 Post(s)

  3. #3
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Take out SMART stuff, drag the crosshairs over your runescape browser.
    And here.
    Simba Code:
    Function Woodcutter;
    Var
      x, y:Integer;
    Begin
      //FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5;
      If FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30) Then
      WriteLn('Found Tree');
    End;

    You have it set to a function, so you need to assign it a type of variable.
    For you, you want it like this.
    Simba Code:
    Procedure Woodcutter;
    Var
      x, y:Integer;
    Begin
      //FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5;
      If FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30) Then
      WriteLn('Found Tree');
    End;

    That way, as a procedure, you don't have to set it to something like: Function Woodcutter: Boolean;.

  4. #4
    Join Date
    Mar 2012
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow, thanks. It works. Am I getting Function and Procedure mixed up then?

  5. #5
    Join Date
    Mar 2012
    Location
    127.0.0.1
    Posts
    3,383
    Mentioned
    95 Post(s)
    Quoted
    717 Post(s)

    Default

    Yeah.
    A function should be like this:
    Simba Code:
    function Namehere:TypeOfVariable;
    The variable can be: Integer,String,Boolean, and others.
    A procedure is like this:
    Simba Code:
    Procedure Namehere;

  6. #6
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Instead of making it a procedure, you should make it a function that returns a boolean. You should do this whenever you can so that you can check if it was successful finding the tree.

    Your procedure in function form:
    Simba Code:
    function Woodcutter : boolean;
    begin
      result := FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30);
      if result then
        WriteLn('Found Tree');
    end;
    Etc.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

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
  •