[TUT] Cases, What are they? [TUT]

Discussion in 'Scar/Simba Help' started by ashur2good, Mar 13, 2008.

?

Do you like this script?

  1. Yes!!! Best Fighting script in da world!

    2 vote(s)
    100.0%
  2. Nah, Ashur keep trying.

    0 vote(s)
    0.0%
[TUT] Cases, What are they? [TUT]
  1. Unread #1 - Mar 13, 2008 at 8:18 AM
  2. ashur2good
    Joined:
    Mar 3, 2007
    Posts:
    359
    Referrals:
    0
    Sythe Gold:
    0

    ashur2good Forum Addict
    Banned

    [TUT] Cases, What are they? [TUT]

    Well, many people don't know what cases are. Which is a real shame, cause they are VERY useful.


    Contents:

    1. Introduction
    I: Why should i learn this?
    II: What will i learn after this?
    III: What is a case?
    2. Learning time
    I: Basic procedure
    II: Different types of cases
    III: When to use cases
    3. Ending
    I: Final comments
    II: Good bye's





    Introduction



    I: Why should i learn this?



    Well, cases are a very important part in making good scripts. And everyone wants to make a good script...Right? Well, they are very useful in every way you use them, as you will see after :D


    II: What will i learn after this?



    At the end of this tutorial, you will learn how to use cases in both ways (Just wait and see!) and how to PROPERLY use them.


    III: What is a case?


    A case is a simple function that does whatever functions/procedures you tell it to do in order. But, the other way to use a case
    is to make it choose a RANDOM function/procedure. Cases are effective in either way.


    Learning time!

    I: Basic procedure



    Here is a basic procedure showing a case being used:

    [SCAR]
    program Casez;
    {.include SRL/SRL.scar}


    var
    x, y, i : integer;

    procedure NormalCase;
    begin
    for i := 0 to 3 do //The i is just a normal integer, nothing special :p(Remember to include in var!)
    case i of //with 4, it will only do the things you say to do from 0-3, Not 4!
    1: Writeln('Ashurs cases tutorial!'); //You can use 0: as a case as well!
    2: Writeln('You will learn how to use cases,');
    3: Writeln('In both ways!');

    end;
    end;


    procedure RandomCase;
    begin
    case random(4) of //Remember how 0 was included, it might randomly pick 0 and not do anything! :eek:
    1: Writeln('Ashurs cases tutorial!');
    2: Wait(20);
    3: Mouse(x, y, 0, 0, true);
    {4: WriteIn('It isnt very hard to do! GL!'); //This procedure will not be used! as it is in 4.
    //That is why i have made it a comment :p }
    end;
    end;


    begin
    NormalCase;
    RandomCase;
    end.
    [/SCAR]


    Now, let's go into detail shall we.


    [SCAR]procedure NormalCase;
    begin
    for i := 0 to 3 do //The i is just a normal integer, nothing special :p(Remember to include in var!)
    case i of //with 4, it will only do the things you say to do from 0-3, Not 4!
    1: Writeln('Ashurs cases tutorial!'); //You can use 0: as a case as well!
    2: Writeln('You will learn how to use cases,');
    3: Writeln('In both ways!');

    end;
    end;
    [/SCAR]

    Now, with a case we put it IN the procedure obviously :p
    Next is the begin for the procedure. Now we are up to the case bit.
    "case" will start the case bit. Then we will tell it that it will do everything from 1-3. Wow, now you're starting to get it, aren't you? :p
    Then we write "of" :p. After that we start of with what we want it to do.
    First thing is we want it to Writeln, then it will do all of those from 1-3. Simple? Yes!
    If anyone has any questions about this part, just ask. ;)

    Now, the next procedure is a RANDOM case, it do the same thing as the other procedure,
    except RANDOMLY choose thing to do from the list of whatever you assign it to do. Now, the (4) Will be how many things you want it to go thru. BUT, the thing with that is for e.g.
    If i choose (4) it will do a random thing i tell it from 0-3, NOT 4. So if it was 5 then it would be 0-5. Get it? Good.
    So, if i choose "case RANDOM (2) of....0: Writein... 1: Mouse...."
    It will pick a random one, so it will either Writeln one message, or the other message! But remember, it's all chance(random)!



    II: Different types of cases


    There are two diffrent types of cases (As mentioned before) Order or Random ones.




    Here is a Order case:

    [SCAR]procedure NormalCase;
    begin
    case (4) of //with 4, it will only do the things you say to do from 0-3, Not 4!
    1: Writeln('Ashurs cases tutorial!'); //You can use 0: as a case as well!
    2: Writeln('You will learn how to use cases,');
    3: Writeln('In both ways!');
    end;[/SCAR]


    And here is a random case:

    [SCAR]procedure RandomCase;
    begin
    case random(4) of //Remember how 0 was included, it might randomly pick 0 and not do anything! :eek:
    1: Writeln('Ashurs cases tutorial!');
    2: Wait(20);
    3: Mouse(x, y, 0, 0, true);
    {4: WriteIn('It isnt very hard to do! GL!'); //This procedure will not be used! as it is in 4.
    //That is why i have made it a comment :p }
    end;
    end;
    [/SCAR]


    III: When to use cases


    You can use cases when you have a long list of things to do, OR when you need SCAR to randomly pick a function out of whatever choices you choose.



    Ending



    I: Final comments


    Please reply with any rants/compliments and most importantly, Improvments!


    II: Good Byes

    Thanks for reading this, i hope your journey with SCAR improves from here, and i wish you luck on your ride.

    P.S: I also attached the simple case script. For anyone that wants it :p


    Cheers
    -Ashur
     
  3. Unread #2 - Mar 16, 2008 at 9:01 PM
  4. b1b
    Joined:
    Apr 15, 2007
    Posts:
    1,915
    Referrals:
    1
    Sythe Gold:
    116
    M
    Rust Player Christmas 2018 Toast Wallet User I'm LAAAAAAAME ???

    b1b Guru

    [TUT] Cases, What are they? [TUT]

    1.try
    Code:
    tags 
    2.Wow this is helpful for beginners like me..
    3. thanks
     
< Help running scar | Oh hai.... Click help Pl34s3? >

Users viewing this thread
1 guest


 
 
Adblock breaks this site