djdiskmachine [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=52866 Cart that loads another cart and saves an index of previously loaded carts. <p>I've made a couple of carts that I plan to use as a visual installation.<br /> My setup is this:<br /> One loader cart that selects a random number as index.<br /> The loader cart uses the random number to index and load one of the visualiser carts.<br /> When the visualiser cart has run for some time, it loads the loader cart again.<br /> Repeat infinitely</p> <p>The setup works pretty decent, but I have two issues:<br /> Often the same visualiser cart gets selected several times in a row.<br /> The random number generator tends to select some of the carts far more often than others.</p> <p>My idea was to create an array that saves the indices in the loader cart. If the index is in the array, it should select a new number.<br /> The issue is that the array in the loader cart doesn't seem to persist in between loads.<br /> I tried passing the array to the visualiser cart but stat(6) doesn't seem to accept arrays.</p> <p>Am I overcomplicating things and there's a simpler way to do it?</p> https://www.lexaloffle.com/bbs/?tid=44858 https://www.lexaloffle.com/bbs/?tid=44858 Sun, 03 Oct 2021 13:58:55 UTC Select random index from array <p>I'm trying to randomly select a value from an array.<br /> I expected this to get me a random index in the array, but I'm getting the same every time.</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre> stmp={-130,50,500,1000,1500,2000,3000,3500} strt=rnd(#stmp) t=stmp[ceil(strt)] print(#stmp) print(strt) print(t)</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Always prints:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>8 0.5174 -130 4.3404</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>I've used rnd() in other carts but I've never encountered this behavior before, please advice.</p> https://www.lexaloffle.com/bbs/?tid=42287 https://www.lexaloffle.com/bbs/?tid=42287 Sun, 04 Apr 2021 00:04:05 UTC