Difference between revisions of "Min / Max"
Jump to navigation
Jump to search
imported>QQuix (A sample User Function page: Min) |
(No difference)
|
Revision as of 21:18, 30 July 2009
A User Function to use with Oblivion Script Extender
Syntax:
Min value1:float, value2:float Min3 value1:float, value2:float, value3:float
Returns the smallest number in a set of values.
Examples:
let MyNumber1 := 512 let MyNumber2 := 27.9 let Myval := Call Min MyNumber1 MyNumber2
let MyNumber1 := 512 let MyNumber2 := 0.001 let MyNumber3 := 27.9 let Myval := Call Min3 MyNumber1 MyNumber2 MyNumber3
Notes
- If an argument is not provided, it defaults to zero, e.g, Call Min3 1 2 will return zero as it returns the smallest of 1, 2 and zero (the missing third argument)
- Of course, new Min functions with more arguments can be created as needed
Code
ScriptName Min float arg1 float arg2 Begin Function {arg1, arg2} if arg1< arg2 SetFunctionValue arg2 else SetFunctionValue arg2 endif End
ScriptName Min3 float val1 float val2 float val3 Begin Function {val1, val2, val3} if val1< val2 if val1< val3 SetFunctionValue val1 else SetFunctionValue val3 endif else if val2< val3 SetFunctionValue val2 else SetFunctionValue val3 endif endif End
See Also