Results 1 to 14 of 14

Thread: Creating Your VERY Own Includes!

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

    Default Creating Your VERY Own Includes!

    This tutorial is still under development. It is noted so you understand.


    Creating your own includes
    ~~By Dan's The Man~~

    This tutorial is detailed (has a lot of lines) and is used for beginner scripters to creating their own include. For a list of requirements, please see the requirements for more information.

    Table Of Contents:
    1:......Introduction.
    2:......Requirements.
    3:......Creating a function/procedure.
    4:......Adding Brackets.
    5:......Testing that function/procedure.
    6:......Adding information.
    7:......Including an include.
    8:......Distributing To Public.

    Introduction:
    This tutorial is basically all about creating your very own includes. Some includes can contain a lot of space and they always contain functions/procedures. An include never contains a main loop, and always contains information on what that certain function/procedure does above it.

    Requirements:
    - Basic Knowledge of SCAR
    - Knowledge of Loops
    - Knowledge of Variables/Arrays (Either one does not matter).
    - What is a string. What is an integer. What is a boolean.
    - Knowledge of Procedures

    Creating a function/procedure:
    For an include to work, you require some functions or procedures. A function always returns a value, whether it is a boolean (True or False), a string (Words) or a integer (Numbers). A procedure does not return a value but is a joint of functions together.

    Now, first you'll be learning how to create a function. Creating a function is very simple if you know how to make procedures. It is practically the same but adding a little more information/stuff into them. So, instead of adding Procedure before a name of a procedure, i add Function instead. In this example, i'll name my function NewFunction
    SCAR Code:
    function NewFunction;
    Now that will not work because i have not set whether the function will return a string, integer or boolean. In this example, i will be showing you how to include a boolean. So, i would add ": Boolean" after the script name. Now i would add a begin and an end, just like a procedure. So now my NewFunction would look like this:
    SCAR Code:
    function NewFunction: Boolean;
    begin
    end;
    Similar to a procedure, isn't it? Now, in this example, the NewFunction function will try to find a colour then return a true or false statement. So, if i wanted it to find red (255) i would add an if(...) then statement. You should know how to do this if you have a basic knowledge of SCAR. I want my function to search for the colour in a specified box from x:500 y:500 to x:600 y:600. I would also need to declare x and y as a variable, you declare variables above the begin. My new function should look like this so far
    SCAR Code:
    Function NewFunction: Boolean;
    Var x : boolean;
    Var y : integer;
    Begin
        If(FindColor(x,y,255,500,500,600,600)) Then Result:=True;
    End;
    That will only search for the colour once and then return true or false. Now, i want my function to keep repeating the if(...) then statement until it has found a colour. So, basically i add a loop, which is repeat and to end the loop i would put Until(...);. So, for my new function to keep repeating until it has found the colour, i would have to add "Result=True" in the Until bracket area. So my new function should look like this now:
    SCAR Code:
    Function NewFunction: Boolean;
    Var x : boolean;
    Var y : integer;
    Begin
      Repeat
        If(FindColor(x,y,255,500,500,600,600)) Then Result:=True;
      Until(result=True);
    End;
    Finally, my function is ready for use.

    Now onto the procedure's part. A procedure is part of a script that does a lot of functions. Whether you set which functions to be in a procedure or not. To create a procedure, you would have to add procedure instead of function because it is not a function is it? It does not return a value so it cannot be a function.

    Now, i want my procedure to do the NewFunction then move my mouse to that spot. So, you should know how to set-up a procedure, it should look like this:
    SCAR Code:
    procedure NewProcedure;
    begin
    end;
    My new procedure is called NewProcedure in this example. Ok, so now i will add NewFunction a line after the begin so it will do the function we made before, NewFunction. Which is an if(...) then statement which will search for red and repeat until it has found it. Ok, so i want to move my mouse to the area where that red colour is found. So, i will add MoveMouse after NewFunction. Ok, so my updated procedure should look like this:
    SCAR Code:
    procedure NewProcedure;
    begin
      NewFunction;
      MoveMouse(x,y);
    end;
    Now, it will move the mouse to where i found the red colour. But i want it to write in the debug box if it has actually found it. So now i will have to add Writeln('Has found colour'); after MoveMouse. So i will do that. That is all i want to do. So, that is my new procedure done.

    Adding Brackets:
    In some functions/procedures, it allows you to add your own information. For a user to input data, you'll need to put brackets after the procedure/function name. In this example, i will be modifying my function so a user can input data. For example, the SendKeys function has brackets to allow the user to input what to say. SendKeys('Hello'); would type the text hello. You can change hello to whatever you want. So, in this brackets example, i will be changing my NewFunction so the user can choose what colour to press. Ok, so now i add brackets after the name, like so:
    SCAR Code:
    Function NewFunction(): Boolean;
    Var x : boolean;
    Var y : integer;
    Begin
      Repeat
        If(FindColor(x,y,255,500,500,600,600)) Then Result:=True;
      Until(result=True);
    End;
    So now we have the brackets ready, i will put the word colour and declare colour as an integer, because it requires a user to input a number. So, my new function now looks like this:
    SCAR Code:
    Function NewFunction(colour: integer): Boolean;
    Var x : boolean;
    Var y : integer;
    Begin
      Repeat
        If(FindColor(x,y,255,500,500,600,600)) Then Result:=True;
      Until(result=True);
    End;
    But that is not just finished yet because it will still find the colour red. You see in the if(...) then statement it will still search for the colour 255. So i replace 255 with colour, in this case colour is kind of like a constant. Well, my new function will now look like this:
    SCAR Code:
    Function NewFunction(colour: integer): Boolean;
    Var x : boolean;
    Var y : integer;
    Begin
      Repeat
        If(FindColor(x,y,colour,500,500,600,600)) Then Result:=True;
      Until(result=True);
    End;

    Testing that function/procedure:
    To test a function/procedure, is very simple. Before you release your include, you should always test out your function to see if it actually works instead of compiling. Ok, just add a main loop at the end of your include, like this:
    SCAR Code:
    begin
    end.
    Now implement your include into the main line. Like, i will for my NewFunction:
    SCAR Code:
    begin
      NewFunction;
    end.
    Ok, that will not work because i did not input entries, which are the bracket. So i'll do so like this:
    SCAR Code:
    begin
      NewFunction(0);
    end.
    More Coming Soon...


    Adding Information:
    Information is basically information about your function or procedure so others can understand it. Most include has it, especially SRL, above every function/procedure. This can be the description of that new procedure/function (What it does), the author and the name of it (procedure BlahBlah. It is commented so the script will not return errors when you run it. To add a comment, just add a { to start it and an } to end it.

    Including an Include:
    So, now that you have saved your include inside the includes folder, you might want to have that procedure or function in your own separate script. Now, since you saved the include as "testinclude.scar" (or whatever the name is) you'll need to add it into your own script. Ok, so click on New Script button and a new script will be made.
    More Information Coming Soon (Tomorrow)...

    Distributing to the Public:
    Coming Soon (Tomorrow)...
    Last edited by Daniel; 07-06-2010 at 07:10 AM.
    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 |

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Good work. Add some more to it and a rep++ comming your way :0:0

  3. #3
    Join Date
    Nov 2006
    Posts
    1,103
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    your examples wouldnt compile^^
    Infractions, reputation, reflection, the dark side of scripting, they are.

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

    Default

    Quote Originally Posted by NaumanAkhlaq View Post
    Good work. Add some more to it and a rep++ comming your way :0:0
    I am going to add some more tomorrow. Right now i am tired and just waking up for some unknown reason, so i check the comp. Lol, fell asleep about 15 mins ago and woke back up :'(

    Besides, my mind isn't straight at the moment.
    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 |

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

    Default

    OMFG

    Fricking Firefox crashed and i lost all my data. God Damn It!!!

    I'll continue this tomorrow because my head is exploding
    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 |

  6. #6
    Join Date
    Jan 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So if i was missing an include in a script i downloaded off this site, could i make my own include for it?

  7. #7
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Good tutorial. + Rep.

    Only one little problem- put in a fail-safe in the loop:

    SCAR Code:
    Var y, c : integer;
    Begin
      Repeat
        If(FindColor(x,y,255,500,500,600,600)) Then Result:=True;
        c:=c+1;
      Until(result=True or c=10);

    The only reason that I'm putting that in there is to teach new scripters to put in things to break a loop.

    Once again, good guide though
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  8. #8
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by skillsman View Post
    So if i was missing an include in a script i downloaded off this site, could i make my own include for it?
    Well the point of an include is so that more than one script can access the same functions/procedures/types, etc. with out having to copy the whole code into the script. So yes if you are missing an include you could make your own but it would need to be exactly the same as the original include. It would be better to get the original.

    @IP, your guide is good and explains your ideas well.

  9. #9
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Instand of
    SCAR Code:
    until(Result = True);

    you could also use
    SCAR Code:
    until(Result);

  10. #10
    Join Date
    Jul 2007
    Location
    Mo-Town
    Posts
    259
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice. Don't think I will be making my own includes any time soon but that helps me understand the SRL includes a bit more.
    Quote Originally Posted by Napolean
    In Politics, Stupidity is Not a Handicap
    Quote Originally Posted by Unknown
    Marriage is like a bank. You put it in, Pull it out, then lose interest.

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

    Default

    Quote Originally Posted by ZephyrsFury View Post
    @IP, your guide is good and explains your ideas well.
    Thanks and i am discontinuing this project as when ever i press the save button it downloads a file called newthread.php and new tabs keep opening up on blank pages. So, Mods/Admins feel free to edit, change any data and most importantly add the rest.

    Thanks!
    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 |

  12. #12
    Join Date
    May 2008
    Location
    Here :p
    Posts
    194
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    noone else notice you declered x as boolean? i think tahts suppost to be an integer.

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

    Default

    Quote Originally Posted by BazzBarrett View Post
    noone else notice you declered x as boolean? i think tahts suppost to be an integer.
    I think it's supposed to be too <_>
    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 |

  14. #14
    Join Date
    Jan 2010
    Posts
    5,227
    Mentioned
    6 Post(s)
    Quoted
    60 Post(s)

    Default

    Also, update/add this.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Creating a Game
    By D1zl3 in forum C/C++ Help and Tutorials
    Replies: 12
    Last Post: 01-27-2009, 06:46 PM
  2. Creating a VM {Vid}
    By Dark_Sniper in forum Computer Help and Tutorials
    Replies: 50
    Last Post: 05-16-2008, 09:51 PM
  3. Help with creating procedures.
    By lordsaturn in forum OSR Help
    Replies: 5
    Last Post: 04-19-2007, 04:05 PM
  4. Creating FIles
    By pwnaz0r in forum OSR Help
    Replies: 6
    Last Post: 03-03-2007, 05:21 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
  •