Page 9 of 12 FirstFirst ... 7891011 ... LastLast
Results 201 to 225 of 295

Thread: THE Beginner's Simba Tutorial

  1. #201
    Join Date
    Nov 2012
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Coh3n, thank you very much for writing this guide, really helped me understand the basics of scripting.

    I'd like to ask a question (may sound noobish)

    Say for example I was working on a combat script, would I add a constant so that the player's character eats every time its health falls below 300 lifepoints?

    Sorry if I didn't explain this right.

  2. #202
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    I'm assuming you mean to ask how you would do that? In this case, it's actually quite simple. All you would do is set a constant, check the HP level, and if it is below whatever the constant is set to, eat some food.
    Simba Code:
    program new;
    {$i srl/srl.simba}

    const
      MINIMUM_HP = 300;

    procedure eatFood();
    var
      col: string;
    begin
      if (getMMLevels('hp', col) <= MINIMUM_HP) then
      begin
        writeln('health is too low, we need to eat!');

        // here is where you would put your code of eating the food
      end;
    end;

    begin
    end.
    I'm not going to do the whole problem for you, but that's how you would use the constant. Hopefully that helps.

  3. #203
    Join Date
    Nov 2012
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    I'm assuming you mean to ask how you would do that? In this case, it's actually quite simple. All you would do is set a constant, check the HP level, and if it is below whatever the constant is set to, eat some food.
    Simba Code:
    program new;
    {$i srl/srl.simba}

    const
      MINIMUM_HP = 300;

    procedure eatFood();
    var
      col: string;
    begin
      if (getMMLevels('hp', col) <= MINIMUM_HP) then
      begin
        writeln('health is too low, we need to eat!');

        // here is where you would put your code of eating the food
      end;
    end;

    begin
    end.
    I'm not going to do the whole problem for you, but that's how you would use the constant. Hopefully that helps.
    Ah ok, thanks for writing that it helped, and I was asking if using a Constant would be appropriate in a script where you would need to heal.

  4. #204
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Using a constant is appropriate whenever you're using the same number twice, or you want the user to set something. So to answer your question, yes it would be appropriate.

  5. #205
    Join Date
    Feb 2012
    Posts
    179
    Mentioned
    0 Post(s)
    Quoted
    84 Post(s)

    Default

    Hey I'm trying to learn scripting from your guide. One of the simplest scripts didn't work for me:

    program HeyWorld;

    procedure WriteInDebugBox;

    begin
    WriteIn ('Hey world!');
    end;
    begin
    WriteInDebugBox;
    end.

    [Error] (6:1): Unknown identifier 'WriteIn' at line 6
    Compiling failed.

    Can anyone help me?

  6. #206
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Nufineek View Post
    Hey I'm trying to learn scripting from your guide. One of the simplest scripts didn't work for me:

    program HeyWorld;

    procedure WriteInDebugBox;

    begin
    WriteIn ('Hey world!');
    end;
    begin
    WriteInDebugBox;
    end.

    [Error] (6:1): Unknown identifier 'WriteIn' at line 6
    Compiling failed.

    Can anyone help me?
    The command is WriteLn, not WriteIn.

  7. #207
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    I made the same mistake, the font is misleading

  8. #208
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    I made the same mistake, the font is misleading
    I'll change all the lowercase l's to a capital, just for clarification.

    E: Done.

  9. #209
    Join Date
    Nov 2012
    Posts
    19
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Aw yes, high school java knowledge put to use * u *

    Thank you very very much for making this tutorial!
    now off I go to learn about all the pre-existing functions/procedures

  10. #210
    Join Date
    Dec 2011
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ah, thought that I would try teaching myself Pascal!

    At the end of the first few sections there is a program called "PuttingTogetherBasics"
    which I completed pretty quickly and thanks to your tutorial understand pretty well

    I keep getting the following error message though when I go to compile to program:
    [Error] C:\Users\takingoutmyuser\Desktop\SRL scripts\Playing With Constants.simba(14:1): Semicolon (';') expected at line 13
    Compiling failed.

    I've looked over it and it seems to be the same as the sample program, I'm sure I'm just missing something small though!

    It might not be clear here but line 13 is this:
    Code:
    procedure HowManyLogs;
    If someone could help me out so I can keep moving on that would be awesome.


    Code:
    program PuttingTogetherBasics;
    //declaring variables globally
    var
    Logs: Integer;
    Exp: Extended;
    
    //declaring constants
    const
    NUMBER_OF_LOGS = 500; //notice the integer
    TREE_TO_CUT = 'Magic' //notice the string
    
    //using a procedure
    procedure HowManyLogs;
    begin
    Logs :=250
    Exp :=195.5
    
    WriteLN('We have chopped' + IntToStr(Logs) + 'logs this session!'
    Wait(500);
    WriteLn('we want to chop' + IntToStr(NUMBER_OF_LOGS) + 'logs.');
    Wait(500);
    WriteLn('We are chopping' + TREE_TO_CUT + 'trees!');
    Wait(500);
    WriteLn('We have gained' + FloatToStr(Logs * Exp) + 'xp this session!');
    end;
    
    
    //float to str converts extended values to strings same as IntToStr
    
    function WeAreBored: string;
    var //declaring vars locally
    s: String;
    begin
    Result := 'what are we going to do now?';
    s := 'We are very bored chopping all these logs!';
    wait(500);
    WriteLn(s);
    end;
    
    begin
    ClearDebug //clears debug box
    HowManyLogs;
    WriteLn(WeAreBored);
    end.
    Last edited by lord victor; 12-01-2012 at 04:14 PM.

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

  12. #212
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    When you get that error message, check the line before the one the error gives you. That's usually the one that's missing a ;.

  13. #213
    Join Date
    Feb 2012
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thank you so much i'm learning alot I cant wait to make my first rs script

  14. #214
    Join Date
    Aug 2007
    Posts
    25
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Why is it that "We are very bored chopping all these logs!" gets displayed before "What are we going to do now?" in the debug log for this function:


    Code:
    function WeAreBored: string;
    var // Declareing variables locally
      s: String;
    begin
      Result := 'What are we going to do now?'; // Notice that "Result" is a string because the function returns a string
      s := 'We are very bored chopping all these logs!';
      Wait(500);
      WriteLn(s); // Notice no "IntToStr" because the variable "s" is already a string
    end;
    Last edited by tvain; 12-30-2012 at 06:52 PM.

  15. #215
    Join Date
    Jan 2012
    Location
    Calgary, AB, Canada
    Posts
    1,819
    Mentioned
    5 Post(s)
    Quoted
    120 Post(s)

    Default

    Quote Originally Posted by tvain View Post
    Why is it that "We are very bored chopping all these logs!" gets displayed before "What are we going to do now?" in the debug log for this function:


    Code:
    function WeAreBored: string;
    var // Declareing variables locally
      s: String;
    begin
      Result := 'What are we going to do now?'; // Notice that "Result" is a string because the function returns a string
      s := 'We are very bored chopping all these logs!';
      Wait(500);
      WriteLn(s); // Notice no "IntToStr" because the variable "s" is already a string
    end;
    I believe it's because the WriteLn(s) is called before the function ends and therefore displays s before it displays the functions result
    Current Project: Retired

  16. #216
    Join Date
    Dec 2012
    Posts
    57
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the tutorial! (: shall get scritoing

  17. #217
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by tvain View Post
    Why is it that "We are very bored chopping all these logs!" gets displayed before "What are we going to do now?" in the debug log for this function:


    Code:
    function WeAreBored: string;
    var // Declareing variables locally
      s: String;
    begin
      Result := 'What are we going to do now?'; // Notice that "Result" is a string because the function returns a string
      s := 'We are very bored chopping all these logs!';
      Wait(500);
      WriteLn(s); // Notice no "IntToStr" because the variable "s" is already a string
    end;
    Quote Originally Posted by Gucci View Post
    I believe it's because the WriteLn(s) is called before the function ends and therefore displays s before it displays the functions result
    Yes. When Writeln(WeAreBored); is called, it executes WeAreBored first, then it executes the Writeln. Since Writeln(s) is called in WeAreBored, it is called before the original Writeln. I hope that makes sense.

  18. #218
    Join Date
    Jan 2013
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    7 Post(s)

    Default

    Im currently halfway trough the tutorial and I must say it has been a very pleasant read so far!

  19. #219
    Join Date
    Feb 2013
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Thanks so much for writing this tutorial. I took 6 pages of notes on it and am looking forward to actually writing a script. A little disappointed that I still can't write even a noob script, but I can't wait until I can. I'll post the first thing I make!

  20. #220
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Xeronate View Post
    Thanks so much for writing this tutorial. I took 6 pages of notes on it and am looking forward to actually writing a script. A little disappointed that I still can't write even a noob script, but I can't wait until I can. I'll post the first thing I make!
    Don't worry, the first script is always hard, remember to ask if you get stuck on something

  21. #221
    Join Date
    Feb 2013
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    Don't worry, the first script is always hard, remember to ask if you get stuck on something
    I'm getting mixed stimuli from you XD. Well thanks for being willing to help. I'll make sure to keep that in mind. Moving on to YoHoJo's tut right now and then I'll try my own.

  22. #222
    Join Date
    Jan 2013
    Posts
    146
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    very helpful, between this tut and yohojo's i can cut down an entire inv of trees

  23. #223
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by Xeronate View Post
    I'm getting mixed stimuli from you XD. Well thanks for being willing to help. I'll make sure to keep that in mind. Moving on to YoHoJo's tut right now and then I'll try my own.
    Sorry if I sent the wrong message earlier, I'm all for people learning to script

  24. #224
    Join Date
    Feb 2013
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Hey, thanks for making this tutorial, I'm working my way through it. Will this work for the '07 release currently? I'm at the first stage of learning how to make an actual script for RS, implementing DeclarePlayers and SMART. When I try to launch to check if it'll log a character in I get this error:

    [Error] (21:3): Unknown identifier 'Smart_Server' at line 20
    Compiling failed.

    This is the Smart_Server line. I've tried changing the servers around, etc. Still to no avail. Any help would be appreciated, I'd like to get working on some scripts and get into the member area. I've got 3 years of experience with C# but none with Pascal apart from this tutorial.

    Thanks!

    EDIT: Just read a few topics, I see that a VM is easy to run at the moment than getting SMART to work. I'll just use a VM until SMART is available again.

    If anyone has any useful tips for me though in regards to programming in Pascal (specifically for RS scripts) please feel free to send me a PM, I'm incredibly interesting in learning more and want to become a contributing member of this community for high quality scripts. It may take me a while but I'll get there.
    Last edited by Fishh; 02-25-2013 at 07:02 PM.

  25. #225
    Join Date
    Jul 2012
    Posts
    437
    Mentioned
    10 Post(s)
    Quoted
    165 Post(s)

    Default

    Quote Originally Posted by Fishh View Post
    Hey, thanks for making this tutorial, I'm working my way through it. Will this work for the '07 release currently? I'm at the first stage of learning how to make an actual script for RS, implementing DeclarePlayers and SMART. When I try to launch to check if it'll log a character in I get this error:

    [Error] (21:3): Unknown identifier 'Smart_Server' at line 20
    Compiling failed.

    This is the Smart_Server line. I've tried changing the servers around, etc. Still to no avail. Any help would be appreciated, I'd like to get working on some scripts and get into the member area. I've got 3 years of experience with C# but none with Pascal apart from this tutorial.

    Thanks!
    Code:
     //SMART_SERVER := 10;
        //SMART_MEMBERS := TRUE;
       // SMART_SIGNED := TRUE;
       // SMART_SUPERDETAIL := FALSE;
    
        SRL_SIXHOURFIX := TRUE;
        SMART_FIXSPEED := TRUE;
    I believe smart server, members, super detail and signed are for an older version. Just comment it out and add the two lines above. Some functions won't work for '07 check out this thread for the unofficial '07 include http://villavu.com/forum/showthread.php?t=96863.

Page 9 of 12 FirstFirst ... 7891011 ... LastLast

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
  •