Difference between revisions of "Talk:Set"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>DragoonWraith
(more about /0)
imported>Omzy
Line 16: Line 16:
  endif
  endif
:::In other situations, though, that may be more difficult to do.
:::In other situations, though, that may be more difficult to do.
::I have it set up so that
<pre>
if y == 0
  Set y to y + .001
endif
</pre>
::That makes it still approximate the calculation, even if it isn't perfect. --[[User:Omzy|Omzy]] 16:44, 23 June 2006 (EDT)

Revision as of 15:44, 23 June 2006

-- Grey: Doesn't the negative factor in the given example need to be in brackets?

--JOG 03:38, 17 April 2006 (EDT) No, you just need NO space between minus and variable. You need the space when you use the minus as operator, though. ("b+a" compiles, "b-a" doesn't, you need "b - a".)

What happens to the rest of the script when you divide by 0; does it continue processing or stop completely? --Omzy 01:42, 23 June 2006 (EDT)

Just found out that if you divide by zero in any script, the game will never run that script again. So, if I had two variables, x and y, and they constantly change and I want to find the ratio x / y, if y is 0 at any point, the script stops and never runs again (even in GameMode and ScriptEffectUpdate blocks). --Omzy 01:49, 23 June 2006 (EDT)
The reason for this is that anything divided by zero is (infinite/impossible?). If you've ever tried dividing any number by zero, the calculator displays ERROR.
When you think about it, it really is a mind-boggling question. How many times can nothing go into one, or one hundred? The Imperial Dragon 12:20, 23 June 2006 (EDT)
Dragoon Wraith TALK 15:49, 23 June 2006 (EDT): It makes sense that x/y wouldn't work so long as y==0, but as soon as y!=0, it should work again. The fact that it does not is quite serious, though also fairly simple to fix, at least in this relatively simple example:
if ( y != 0 )
  set z to x/y
endif
In other situations, though, that may be more difficult to do.
I have it set up so that
if y == 0
   Set y to y + .001
endif
That makes it still approximate the calculation, even if it isn't perfect. --Omzy 16:44, 23 June 2006 (EDT)