SRL Archive - OSR Help

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


Cstrike

2010-07-01 09:17:34

If we have for example

 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
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

masterBB

2010-07-01 09:26:32

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…

Sabzi

2010-07-01 09:50:48

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:

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.

masterBB

2010-07-01 10:11:02

From: Sabzi
Your logic is bad, masterBB is right.
Just to correct things:

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.

Sabzi

2010-07-01 10:44:34

From: masterBB
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 …

masterBB

2010-07-01 10:49:18

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

Coh3n

2010-07-02 00:18:52

Your logic is slightly off. When you say

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

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. :)

NCDS

2010-07-02 00:38:38

From: Coh3n
Your logic is slightly off. When you say

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

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. :)


From: masterBB

could get to magic tab

;).

Coh3n

2010-07-02 07:48:47

From: NCDS
;).

Umm no? I have it right…

Sabzi

2010-07-02 08:04:56

From: Coh3n
Umm no? I have it right…


Yes, you got it right. I think NCDS was referring to that masterBB got it right too.

Coh3n

2010-07-02 08:11:45

From: Sabzi
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. :p

masterBB

2010-07-02 09:12:52

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