Talk:Return

From the Oblivion ConstructionSet Wiki
Revision as of 05:19, 6 February 2007 by imported>J.O.D.
Jump to navigation Jump to search

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

--J.O.D. 05:19, 6 February 2007 (EST)I think that DoOnce may actually be needed to do anything just on the first OnLoad at all - otherwise the action would take place on every load.