Difference between revisions of "Talk:If"
imported>JOG m |
imported>JOG (Moved to discussion unless someone comes up with a concrete example. Professional wording and layout might help too...) |
||
Line 39: | Line 39: | ||
<pre>if (angleA >= 0 && angleA <= 90) || (angleA >= 180 && < 270)</pre> | <pre>if (angleA >= 0 && angleA <= 90) || (angleA >= 180 && < 270)</pre> | ||
Once my script hit this line, it stopped working completely. No indication that anything was wrong. --[[User:Mrflippy|Mrflippy]] 21:06, 15 April 2006 (EDT) | Once my script hit this line, it stopped working completely. No indication that anything was wrong. --[[User:Mrflippy|Mrflippy]] 21:06, 15 April 2006 (EDT) | ||
---- | |||
Also, | |||
Sometimes a runtime error will occur where: | |||
<pre> if cond1 && cond2 | |||
;code | |||
endif</pre> is not evaluated correctly in scripts. If you find a similar conditional statement is not functioning correctly, try: | |||
<pre> if cond1 | |||
if cond2 | |||
;code | |||
endif | |||
endif</pre> | |||
The reason for this anomaly is currently unknown. |
Revision as of 12:28, 15 June 2006
Do brackets help in logical operations?
IE: elseif Random > 75 && ( LilRandom == 4 || LilRandom2 == 4 )
That should be if Random is over 75, and LilRandom or LilRandom2 equals 4, but what I gather is that Oblivion will interpret it as:
if Random is over 75 and LilRandom is equal to 4, OR LilRandom equals 4.
Logically it should interpret it the prior, but with Oblivion, I'm not so sure. --MaXiMiUS 21:42, 9 April 2006 (EDT)
--JOG 15:21, 14 April 2006 (EDT)Doesn't help as far as I've tested it.
--JOG 04:51, 17 April 2006 (EDT) Didn't really read and thought you asked about AND/OR as bitwise operators. Of course brackets work but since OR always has priority over AND you need to include the AND part.
tabs and spaces
I just spent an hour searching for a bug in a script using &&:
Apparently certain combination of tabs and spaces between the two parameters cause the IF-Block to break processing of the script. No commands within the IF-Block or after the IF-Block are executed.
Here is an example:
http://home.tiscali.de/jo.ge1/tabs_working.txt
This one works fine: for each of the three objects you get a Journal entry when you activate it and can activate it as often as you like.
http://home.tiscali.de/jo.ge1/tabs_not_working.txt
The second one doesn't work: You just get the journal entry when you activate the first object, no activation, And the second and third object can't be activated at all.
--JOG 15:27, 14 April 2006 (EDT)
Gotchas
The following if condition compiled (I forgot to type the last angleA):
if (angleA >= 0 && angleA <= 90) || (angleA >= 180 && < 270)
Once my script hit this line, it stopped working completely. No indication that anything was wrong. --Mrflippy 21:06, 15 April 2006 (EDT)
Also,
Sometimes a runtime error will occur where:
if cond1 && cond2 ;code endif
is not evaluated correctly in scripts. If you find a similar conditional statement is not functioning correctly, try:
if cond1 if cond2 ;code endif endif
The reason for this anomaly is currently unknown.