// SPDX-License-Identifier: MIT // Copyright (c) 2026 Incoprea // Distribute a fixed count by weights // Not compiled or tested in-world // Setup: Place in a spare owned prim. Set positive WEIGHTS and TOTAL0..1000. Touch to run; output is private to the owner. // Stop / restore: Disable/remove. No scene changes or external calls. // Notes: Ties go to earlier entries. This preserves the exact total while approximating relative weights. // License: see LICENSE in this distribution. // Original Incoprea. MIT. list WEIGHTS=[5.0,3.0,2.0]; integer TOTAL=17; default { touch_start(integer detectedCount) { if(llDetectedKey(0)!=llGetOwner())return; integer n=llGetListLength(WEIGHTS); if(n==0||n>20||TOTAL<0||TOTAL>1000) { llOwnerSay("Invalid size/total."); return; } float sum; integer i; for(i=0;illList2Float(remainders,best))best=i; counts=llListReplaceList(counts,[llList2Integer(counts,best)+1],best,best); remainders=llListReplaceList(remainders,[-1.0],best,best); ++assigned; } llOwnerSay("Allocated="+llDumpList2String(counts,",")); } }