OsRound
From OpenSimulator
(Difference between revisions)
(Add exemple) |
m (Change integer to float) |
||
(2 intermediate revisions by one user not shown) | |||
Line 6: | Line 6: | ||
|ossl_example= | |ossl_example= | ||
<source lang = "lsl"> | <source lang = "lsl"> | ||
− | // | + | // |
+ | // osRound Script Exemple | ||
+ | // Author: djphil | ||
+ | // | ||
default | default | ||
Line 12: | Line 15: | ||
state_entry() | state_entry() | ||
{ | { | ||
− | llSay(PUBLIC_CHANNEL, "Touch | + | llSay(PUBLIC_CHANNEL, "Touch to see osRound usage."); |
} | } | ||
touch_start(integer n) | touch_start(integer n) | ||
{ | { | ||
− | float value = llFrand(1000); | + | float value = llFrand(1000.0); |
float round = osRound(value, 3); | float round = osRound(value, 3); | ||
− | llOwnerSay( "osRound(value, 3) of \"" + (string)value + "\" is \"" + (string)round + "\""); | + | llOwnerSay("osRound(value, 3) of \"" + (string)value + "\" is \"" + (string)round + "\""); |
} | } | ||
} | } |
Latest revision as of 08:57, 7 December 2020
float osRound(float value, integer ndigits)
| |
returns the value rounded to the number with a number if decimal places set by ndigits. ndigits = 0 is same as llRound(), max value is 15. | |
Threat Level | No threat level specified |
Permissions | No permissions specified |
Extra Delay | 0 seconds |
Example(s) | |
// // osRound Script Exemple // Author: djphil // default { state_entry() { llSay(PUBLIC_CHANNEL, "Touch to see osRound usage."); } touch_start(integer n) { float value = llFrand(1000.0); float round = osRound(value, 3); llOwnerSay("osRound(value, 3) of \"" + (string)value + "\" is \"" + (string)round + "\""); } } | |
Notes | |
note that ll*Say do llRound(value,6) by default so you can't test with them.. |