Results 1 to 6 of 6

Thread: Need Help With Boolean Function

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

    Default Need Help With Boolean Function

    Help! Im a total nub and I'm trying to use the CantLightCheck function for Firemaking, but I'm not sure how to set it up, or at least I've tried and it wont work

    here's the function from SRL/Skills/Firemaking.scar:

    Code:
    {*******************************************************************************
    function CantLightCheck: Boolean;
    By: Dankness
    Description: Results True if able to light logs
    *******************************************************************************} 
    
    function CantLightCheck: Boolean;
    begin
      Result := False;
      if InChatMulti('can', 'ere', 'here') then
      begin
        Wait(250 + Random(250));
        Result := InChatMulti('can', 'ere', 'here');
      end;
    end;
    and I'm trying to set it up as


    Code:
     if (CantLightCheck = true) then
     begin
      repeat
       LightALog;
       until
       WhenToFinish = true;
      end else
      begin
      Exit; 
      end;
     end;
    end.
    I want it to repeat the log burning process until CantLightCheck = false, and then I want it to terminate. If i haven't provided enough info please let me know. Be nice haha I'm new to all of this! Thanks!

  2. #2
    Join Date
    Dec 2006
    Location
    .̿̂̔͋͗̎̆ͥ̍̒ͤ͂̾̌̀̅
    Posts
    3,012
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    I'm not 100% sure but the result is false at start and if it finds text in the messagebox then it'll result true.. Maybe you should use it in the loop.. Not sure if you want to use it this way but anyway...

    SCAR Code:
    repeat
      if not CantLightCheck then
        LightALog
      else
        TerminateScript; //or Exit or whatever..
    until (Parameter)

    that simple Just remove the "not" from there if it works the opposite way .. And include the firemaking.scar too.

  3. #3
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I figured it out! Because I'm new, I misunderstood what Exit does, but thanks to SRL wiki I learned it just exits procedure/function , and I wanted it to terminate the script, so here's what I ended up with:

    Code:
    begin
     repeat
     if CantLightCheck then
       begin
       TerminateScript;
       end else
       LightALog;
       until
       WhenToFinish = true;
      end;
    end.
    Voila! Lights logs until I run out OR until it says 'You cant light a fire here'

  4. #4
    Join Date
    Dec 2006
    Location
    .̿̂̔͋͗̎̆ͥ̍̒ͤ͂̾̌̀̅
    Posts
    3,012
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Good job

  5. #5
    Join Date
    May 2006
    Posts
    1,230
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Exit; exits the whole procedure/function =p
    Break; exits a loop

  6. #6
    Join Date
    Oct 2006
    Posts
    1,071
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    oops thanks

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
  •