Talk:Set

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

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

Division by zero isn't the only such issue, the game shuts down the script whenever it stumbles upon an illegal command that wasn't caught by the construction set. Another example is this:

if < 2
endif

The IF-statement compiles fine, but once it is executed, the script stops completely.

Open Oblivion.ini and set bDisableWarning=0 and you'll get an error message that tells you that the script will be stopped.--JOG 16:48, 23 June 2006 (EDT)

That sounds like a valuable tool! --Omzy 16:57, 23 June 2006 (EDT)
Dragoon Wraith TALK 22:39, 23 June 2006 (EDT): Indeed it does, thank you JOG!

Line limit[edit source]

Set seems to have a line limit of 73 bytes.

Weird behavior from the “Set” function.[edit source]

Hi! I am not sure here is the correct place to put this question, but it looks like it has to do with the “Set” function The code is as follows:

;Status at this point-  ContainerA has ItemA – ContainerB has ItemB
	
set ContainerA to 0    ;  result is the same with/without this line
set ContainerA to ContainerB

set item to ContainerA.GetInventoryObject 0
PrintToConsole "Cont A – Item 0= %n"  Item	;Prints: “Cont A – Item 0 = ItemA” << Wrong

set item to ContainerA.GetInventoryObject 0
PrintToConsole "Cont A - Item 0= %n"  Item	;Prints: “Cont A – Item 0 = ItemA” << Wrong

set item to ContainerB.GetInventoryObject 0	; (*)	
PrintToConsole "Cont B – Item 0= %n"  Item	;Prints: “Cont B – Item 0 = ItemB”

set item to ContainerA.GetInventoryObject 0
PrintToConsole "Cont A – Item 0= %n"  Item	;Prints: “Cont A – Item 0 = ItemB” << Now OK!!!

(*) – could be any other reference to ContainerB, like “set NumItems to ContainerB.getnumitems”

It looks that the “set ContainerA to ContainerB” does not set ContainerA until I explicitly ref ContainerB

I have some complex code before that (and may be doing something wrong there) but, even so, this behavior doesn’t look right.

Does anybody have any reasonable explanation? Or any hint on what may be causing this?

Thanks in advance. --QQuix 16:00, 24 May 2008 (EDT)

Quest Variables[edit source]

Trying to use set on (or with; they don't necessarily have to be the subject) Quest Variables whose Quest ID starts with a number (such a 1MyQuest) seems to give an error when trying to save the script, treating the Quest ID as part of the variable instead of the quest associated with it (Unknown Variable: 1MyQuest.test). -Doopliss 01:13, 31 December 2008 (EST)

There's nothing that can be done about that. Avoid starting IDs with numbers.
--Qazaaq 06:16, 31 December 2008 (EST)
The same goes for pretty much all EditorIDs. Just don't start them with numbers.--Speedo 17:36, 31 December 2008 (EST)