Difference between revisions of "Talk:Return"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Dejunai
m
 
imported>GreyWanderer
Line 1: Line 1:


-------------------------------------------------------
-------------------------------------------------------
Line 31: Line 29:
Just thought I would add this bit of business so others would not make the same mistake I did. I hope it helps.
Just thought I would add this bit of business so others would not make the same mistake I did. I hope it helps.
-Dejunai
-Dejunai
-- [[User:GreyWanderer|Grey]]: Although this is valueable information and exactly what I was looking for, let me note that in your example, DoOnce isn't needed as OnLoad Blocks are only executed once at a time.

Revision as of 18:05, 16 April 2006


( never used a Wiki before, hope I do this right )


I had a glitch in a script, and careful debugging has taught me that RETURN is a little more powerful than first suspected.

The scripts are designed with the BEGIN <event> syntax. I was considering these independednt functions called seperately. However if within the same frame execution you have more than one <event> expected to be processed, and use RETURN in the first <event> for any reason. No other <event>s will be processed.

The clear example I discovered, was using RETURN within an OnLoad event. Which ultimately glitched the necessary OnReset event. Because OnLoad and OnReset are processed at the same frame during a cell load the OnLoad event exited the script before the OnReset had a chance to process.

Begin OnLoad

 If doOnce == 1
   Return
 Endif
 ; Stuff to do once

End

Begin OnReset

 ; Stuff to do every Reset

End

The "stuff to do every reset" will only process the one time OnLoad processes.

RETURN as clearly stated in the Wiki exits the script, not the OnLoad function.

Just thought I would add this bit of business so others would not make the same mistake I did. I hope it helps. -Dejunai

-- Grey: Although this is valueable information and exactly what I was looking for, let me note that in your example, DoOnce isn't needed as OnLoad Blocks are only executed once at a time.