Results 1 to 7 of 7

Thread: Will this procedure work?

  1. #1
    Join Date
    Mar 2007
    Location
    Eugene, Oregon
    Posts
    195
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Will this procedure work?

    Simba Code:
    procedure SetupMineRocks;
     var
     X, Y, i: integer;
     RockColor: array[0..3] of integer;
      begin
       if (RockType = 'iron') then
        writeln('Mining iron ore.');
        RockColor[0]:=0;
        RockColor[1]:=0;
        RockColor[2]:=0;
        RockColor[3]:=0;
      else
       if (RockType = 'tin') then
       writeln('Mining tin ore.');
       RockColor[0]:=0;
       RockColor[1]:=0;
       RockColor[2]:=0;
       RockColor[3]:=0;
      else
        if (RockType = 'copper') then
       writeln('Mining copper ore.');
       RockColor[0]:=0;
       RockColor[1]:=0;
       RockColor[2]:=0;
       RockColor[3]:=0;
        begin
         if(not(LoggedIn)) then
         Exit;
         else
          For i:= 0 to 5 do
           if(FindObjCustom(x,y,['ine','in','ne','ocks','ock'],[RockColor[i]],6) then
            begin
             if IsUpText('ocks') then
              begin
               MineRocks;
              end;
            end;
         end;
       end;

    It doesn't compile right now because it says identifier expected. Can anyone tell me why? Also, is the RSS Channel accessible so I can ask quick question like this on there?

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

    Default

    For quick questions/answers, go to #srl.

  3. #3
    Join Date
    Mar 2007
    Location
    Eugene, Oregon
    Posts
    195
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Can you touch up on that a bit, I can't seem to find the thread that tells me how to join the IRC.

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

    Default

    Um, get an IRC client like mIRC xChat irssi or something. Then join the channel. Its #srl on irc.rizon.net.
    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"

  5. #5
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    i made it compile
    Simba Code:
    {$i SRL/SRL.scar}

    procedure MineRocks;
    begin
    end;

    procedure SetupMineRocks;
     var
     X, Y, i, ii: integer;  // ii added
     RockColor: array[0..3] of integer;
     RockType: String;

     begin
       if (RockType = 'iron') then
       begin // missing a begin here
         writeln('Mining iron ore.');
         RockColor[0]:=0;
         RockColor[1]:=0;
         RockColor[2]:=0;
         RockColor[3]:=0;
       end else  // need to use end else here
       if (RockType = 'tin') then
       begin
         writeln('Mining tin ore.');
         RockColor[0]:=0;
         RockColor[1]:=0;
         RockColor[2]:=0;
         RockColor[3]:=0;
       end else  // same as before
        if (RockType = 'copper') then
        begin
          writeln('Mining copper ore.');
         RockColor[0]:=0;
         RockColor[1]:=0;
         RockColor[2]:=0;
         RockColor[3]:=0;
       end;
       // begin  not needed
         if(not(LoggedIn)) then
         Exit;
        // else  not needed
          For i:= 0 to 5 do
            for ii:=0 to 3 do // this is needed to stop a out of range error as there are only 4 RockColors
           if(FindObjCustom(x,y,['ine','in','ne','ocks','ock'],[RockColor[ii]],6)) then // missing a closing bracket
            begin
             if IsUpText('ocks') then
              begin
               MineRocks;
              end;
            end;
     end;

     begin
       SetupMineRocks;
     end.

    i would suggest breaking it up into smaller procedures like a LoadRock, also learning about cases would help

    something like this
    Simba Code:
    procedure LoadRockRecord;
    var
      RockColor: array[0..3] of integer;

    begin
      case Lowercase(RockType) of
      //case Lowercase(Players[CurrentPlayer].Strings[0]) of // i would suggest uing something like this so you only have to use
                                                                                // this proc once at the beggining of your script
        'iron':
          begin
            RockColor := [0, 1, 2, 3];  // put rock colours here
          end;

        'tin':
          begin
            RockColor := [0, 1, 2, 3];
          end;


       // etc for each rock
      end;
    end;

    also your standards are a little bit off, its no big deal but it makes it alot easier to read and you can find little errors like an extra begin/end somewhere

    i hope this helps a little



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

    Default

    Or, if you want help from people on irc on how to get on irc, https://qchat.rizon.net, channel is #srl, choose whatever nick you want, and there's no auth/password. Once you're on, ask how to register a nick and blah blah blah, if you so please.

  7. #7
    Join Date
    Mar 2006
    Location
    Behind you
    Posts
    3,193
    Mentioned
    61 Post(s)
    Quoted
    63 Post(s)

    Default

    Some additional reading to improve on this would be a tutorial on Cases.

    ~BraK

    "Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."

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
  •