This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
fuss:lsl [2019/11/12 16:46] – [Ternary Operator] office | fuss:lsl [2024/08/11 01:19] (current) – [Generic Notecard Reader] office | ||
---|---|---|---|
Line 180: | Line 180: | ||
====== Generic Notecard Reader ====== | ====== Generic Notecard Reader ====== | ||
- | This is a generic notecard loader. | + | This is a generic notecard loader. |
**Globals** | **Globals** | ||
Line 264: | Line 264: | ||
// Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // | // Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3 // | ||
/////////////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////////////// | ||
- | integer stringComparer(string a, string b) { | + | integer stringComparer(string a, string b, integer ASCENDING) { |
- | list alph = [ " | + | list alph = [ |
- | " | + | |
- | | + | " |
+ | | ||
+ | | ||
+ | integer l = llListFindList( | ||
+ | | ||
+ | [ llToLower(a) ] | ||
+ | ); | ||
+ | |||
+ | integer r = llListFindList( | ||
+ | | ||
+ | [ llToLower(b) ] | ||
+ | ); | ||
+ | |||
+ | if(ASCENDING) { | ||
+ | return l > r; | ||
+ | } | ||
+ | |||
+ | return l <= r; | ||
} | } | ||
Line 287: | Line 304: | ||
do { | do { | ||
- | if(stringComparer(llList2String(a, | + | if(stringComparer(llList2String(a, |
less += llList2List(a, | less += llList2List(a, | ||
less_b += llList2List(b, | less_b += llList2List(b, | ||
Line 298: | Line 315: | ||
b = llDeleteSubList(b, | b = llDeleteSubList(b, | ||
} while(llGetListLength(a)); | } while(llGetListLength(a)); | ||
- | return wasDualQuicksort(less, | + | |
+ | | ||
+ | | ||
+ | | ||
+ | | ||
} | } | ||
Line 805: | Line 826: | ||
====== TRNG ====== | ====== TRNG ====== | ||
- | True random-number generator, based on FPS fluctuations of region frame-rates | + | True random-number generator, based on FPS fluctuations of region frame-rates. |
<code lsl2> | <code lsl2> | ||
Line 856: | Line 877: | ||
====== Compute Capping System Delays ====== | ====== Compute Capping System Delays ====== | ||
- | A calculator to compute the random amount of time needed (in seconds) to wait between executing some capped action | + | A calculator to compute the random amount of time needed (in seconds) to wait between executing some capped action. |
<code lsl2> | <code lsl2> | ||
Line 2071: | Line 2092: | ||
which returns [↗] where ↗ is the next position of the arrow. | which returns [↗] where ↗ is the next position of the arrow. | ||
- | You can find some collected sets of spinners on the [[assets/ | + | You can find some collected sets of spinners on the [[/assets/ |
====== Decompose a Number into Prime Factors ====== | ====== Decompose a Number into Prime Factors ====== | ||
Line 4154: | Line 4175: | ||
Remarkably, the expression preserves the same type constraints that a ternary operator would have: the type of '' | Remarkably, the expression preserves the same type constraints that a ternary operator would have: the type of '' | ||
+ | ====== Clamping Vector Components ====== | ||
+ | |||
+ | '' | ||
+ | |||
+ | <code lsl2> | ||
+ | /////////////////////////////////////////////////////////////////////////// | ||
+ | // Copyright (C) 2022 Wizardry and Steamworks - License: GNU GPLv3 // | ||
+ | /////////////////////////////////////////////////////////////////////////// | ||
+ | vector wasVectorClamp(vector v, float min, float max) { | ||
+ | return | ||
+ | < | ||
+ | llListStatistics( | ||
+ | LIST_STAT_MAX, | ||
+ | [ | ||
+ | llListStatistics( | ||
+ | LIST_STAT_MIN, | ||
+ | [ | ||
+ | v.x, | ||
+ | max | ||
+ | ] | ||
+ | ), | ||
+ | min | ||
+ | ] | ||
+ | ), | ||
+ | llListStatistics( | ||
+ | LIST_STAT_MAX, | ||
+ | [ | ||
+ | llListStatistics( | ||
+ | LIST_STAT_MIN, | ||
+ | [ | ||
+ | v.y, | ||
+ | max | ||
+ | ] | ||
+ | ), | ||
+ | min | ||
+ | ] | ||
+ | ), | ||
+ | llListStatistics( | ||
+ | LIST_STAT_MAX, | ||
+ | [ | ||
+ | llListStatistics( | ||
+ | LIST_STAT_MIN, | ||
+ | [ | ||
+ | v.z, | ||
+ | max | ||
+ | ] | ||
+ | ), | ||
+ | min | ||
+ | ] | ||
+ | ) | ||
+ | >; | ||
+ | } | ||
+ | </ | ||
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.