Difference between revisions of "Script Compiler Override"

m
imported>Odessa
(→‎Example #3: link to AV codes)
imported>Odessa
Line 1: Line 1:
==Overview==
==Overview==
If using [[Let]], [[Eval|if eval]], [[While]], and some other new NVSE functions, it is permitted to pass [[Array Variable|array elements]], [[String Variable|string variables]] and [[User Defined Function|(perhaps user defined)]] nested function calls directly as parameters. However, the vanilla script compiler will prohibit direct passage to vanilla and older NVSE functions, complaining that the paramater type is invalid (it isn't sure what type the array element or function return will be, since it could potentially be any). Typically, this forces you to use an intermediary variable. Alternatively, the script compiler override (CO) allows you to ignore these 'misgivings', and assuming that you know the types are safe, compile scripts that will work correctly.  
If using [[Let]], [[Eval|if eval]], [[While]], [[Print]] and some other new NVSE functions, it is permitted to pass [[Array Variable|array elements]], [[String Variable|string variables]] and [[User Defined Function|(perhaps user defined)]] nested function calls directly as parameters. However, the vanilla script compiler will prohibit direct passage to vanilla and older NVSE functions, complaining that the paramater type is invalid (it isn't sure what type the array element or function return will be, since it could potentially be any). Typically, this forces you to use an intermediary variable. Alternatively, the script compiler override (CO) allows you to ignore these 'misgivings', and assuming that you know the types are safe, compile scripts that will work correctly.  


To use the CO, you prefix a script block type with an underscore (eg: <b>Begin _GameMode</b>). See the following examples for further details, and also the warning at the end of this article.
To use the CO, you prefix a script block type with an underscore (eg: <b>Begin _GameMode</b>). See the following examples for further details, and also the warning at the end of this article.
 
==Example #1==
==Example #1==
Let's say we have a number that we want to get the [[Floor]] of, the nearest whole number lower than the float. The vanilla compiler will know what we want to do if we specify it as a float variable that we pass to the floor function as a parameter:
Let's say we have a number that we want to get the [[Floor]] of, the nearest whole number lower than the float. The vanilla compiler will know what we want to do if we specify it as a float variable that we pass to the floor function as a parameter:
Anonymous user