rnd(-1) (or any negative number) seems to yield a random number from -32768 to 32767.
also rnd() seems to yield a random number between 0 and 1
not sure if those are intended features, but they surely aren't documented.
I think rnd() -> (-32768,32767) and maybe rnd(x) -> sgn(x)*rnd(abs(x)) would make more sense.
edit: plus srand() doing something to the effect of srand(time()) would be nicer than defaulting to srand(0)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
Yes, I found this by accident... ie: I had a CRAZY bug.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
32768 is the max value of an int in pico, so that's interesting maybe that trick will come in handy some day. Also, if you're looking for better documentation: https://neko250.github.io/pico8-api/
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
@scottyelish:
ouch!
@orangecode:
yes, that's a full 32 random bits (16 integer part + 16 mantissa) and that's definitely useful. having that on rnd() (no parameter) and rnd(x) returning a number between 0 and x (or x and 0) would be slick.
yes, I know that doc, it's nicer but not much more thorough. (at this point, maybe there's a full book that needs to be written?)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
ultra ... I was doing something that ended up like rnd(10-level) ... which worked great until level 11 :-)
anyway, take a look ... let me know what you think:
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
The wiki intends to be more thorough than the official docs. Specifically, the API reference is intended to be a place where we can accrue detailed info on each function.
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
@scottyelish: had a look and commented there :)
@dddaaannn: I have a silly problem with the wiki: I just can't read that red on grey...
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
I can try to tweak the colors more. The original goal was to pick from the Pico-8 palette, and the current pick is the least offensive choice in that regard. I've seen it look worse on some monitors than others for reasons I don't understand.
(Ctrl-reload to see an update, lmkwyt.)
![](/gfx/set_like0.png)
![](/gfx/top_drop.png)
hey, that salmon/peach color looks a whole lot better, thanks! bookmarked :)
the red text here on the bbs is also hard to read but far less prominent (few people bother with a title in their post). the current top banner is painful though (red glyphs on grey)
[Please log in to post a comment]