Results 1 to 12 of 12

Thread: if not [function] then, -- is the function called to run by that code?

  1. #1
    Join Date
    May 2007
    Location
    Everywhere
    Posts
    1,428
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default if not [function] then, -- is the function called to run by that code?

    If we have for example

    SCAR Code:
    if not Gametab(tab_Magic) then
        Exit;
        else
           begin
              writeln ('could not get to magic tab');
           end;

    Is my logic of this script correct?

    1. It looks to see if
    SCAR Code:
    Gametab(tab_Magic)
    is true or not, thus it executes the function to return a value
    2. In game, the command checks to see if it is on the mage tab, if so, returns true
    3. If in game, and it is not the magic tab, it clicks it, and returns true
    4. If not in game for example, it cannot find the magic tab and thus returns false, writing "could not get to the magic tab"

    Is my logic correct? Does that mean when you have

    if [not] (function) then
    It will call the function and try to match it to the desired boolean state?
    Just trying to make failsafes, thanks!

    PS: Is there any problem with that script? I just made it up now off the top of my head, if theres an error its a short circuit in my knowledge

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    SCAR Code:
    if not Gametab(tab_Magic) then
        Exit;
    writeln ('could get to magic tab');  // this line will only be executed if the exit is not called

    would be better I guess...

  3. #3
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    When you use any function anywhere it will be executed and will result in something(based on the type of the result it gives).

    Your logic is bad, masterBB is right.
    Just to correct things:
    SCAR Code:
    if not Gametab(tab_Magic) then
      Exit  // no ";" here as you are using an else
    else
      writeln('could not get to magic tab'); //no need for begin/end, only one line

    3. If in game, and it is not the magic tab, it clicks it, and returns true
    In game it will try to switch to the magic tab(if not already on it) and will result True if it succeeded. Everything can fail so it will result false then.
    Last edited by Sabzi; 07-01-2010 at 01:55 PM.

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by Sabzi View Post
    Your logic is bad, masterBB is right.
    Just to correct things:
    SCAR Code:
    if not Gametab(tab_Magic) then
      Exit  // no ";" here as you are using an else
    else
      writeln('could not get to magic tab'); //no need for begin/end, only one line
    .
    The else is not needed either, cause of the exit. And the text in the writeln is wrong to, it says "could not get to magic tab" if it can get to the magic tab.

  5. #5
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    The else is not needed either, cause of the exit. And the text in the writeln is wrong to, it says "could not get to magic tab" if it can get to the magic tab.
    Dude, that's why I said you are right and I only fixed non-logical problems ...

  6. #6
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Wink

    I thought you meant that I was right and you had an alternative solution. I was just wondering why the else. My wrong

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

    Default

    Your logic is slightly off. When you say
    SCAR Code:
    if (not GameTab(tab_Inv)) then
    that means that it will execute what's in the if..then statement if GameTab(tab_Inv) returns false. From the looks of things, you were thinking the opposite. What you want is
    SCAR Code:
    if (GameTab(tab_Inv)) then
      exit
    else
      writeln('Couldn''t change to inventory tab.');

    //OR

    if (not GameTab(tab_Inv)) then
      writeln('Couldn''t change to inventory tab.')
    else
      exit;
    Other than that, your logic was fine.

  8. #8
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Your logic is slightly off. When you say
    SCAR Code:
    if (not GameTab(tab_Inv)) then
    that means that it will execute what's in the if..then statement if GameTab(tab_Inv) returns false. From the looks of things, you were thinking the opposite. What you want is
    SCAR Code:
    if (GameTab(tab_Inv)) then
      exit
    else
      writeln('Couldn''t change to inventory tab.');

    //OR

    if (not GameTab(tab_Inv)) then
      writeln('Couldn''t change to inventory tab.')
    else
      exit;
    Other than that, your logic was fine.
    Quote Originally Posted by masterBB
    could get to magic tab
    .

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

    Default

    Quote Originally Posted by NCDS View Post
    .
    Umm no? I have it right...

  10. #10
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Umm no? I have it right...
    Yes, you got it right. I think NCDS was referring to that masterBB got it right too.

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

    Default

    Quote Originally Posted by Sabzi View Post
    Yes, you got it right. I think NCDS was referring to that masterBB got it right too.
    Ah, well I never said he didn't, I was just giving a little more explanation.

  12. #12
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    As long as you all know who answered this question first, I'm can life with it

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •