Content deleted Content added
→Setting random seed: is the logic reversed? |
reply |
||
Line 3:
:Actually, sometimes generating the same number is necessary, as some wikicode assumes that {{tl|rand}} generates the same number every time it is called on the same page. (This can now be done with the {{para|same}} parameter.) But I think you do have a point - it was messy code to call setRandomSeed so many times. I've reworked the module so that it is only called once. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 07:26, 2 December 2013 (UTC)
::Just out of curiosity, could you point me to one of the examples where it is expected that {{tl|rand}} will produce the same number? Having a common entry point function for each of the generated wrapper function is a nice way to set the seed once. However, regarding the logic: is the logic reversed for the low traffic check? In the case where using the same seed is desired and the site is not low traffic, then stats.edit may change rapidly, so you should instead use os.time() rounded to the seed refresh rate? [[User:Isaacl|isaacl]] ([[User talk:Isaacl|talk]]) 07:42, 2 December 2013 (UTC)
:::Sure - the one I found was [https://en.wikipedia.org/w/index.php?title=Template:Random_portal_component&oldid=534588943 Template:Random portal component] (before I converted it to Lua). And no, the logic is the right way round, as mw.site.stats.edits etc. are only loaded once per page, so they are always the same. On the other hand, <code>math.floor(os.time()/60)</code> will produce different results if the time you run your module happens to coincide with a minute boundary. — '''''[[User:Mr. Stradivarius|<span style="color: #194D00; font-family: Palatino, Times, serif">Mr. Stradivarius</span>]]''''' <sup>[[User talk:Mr. Stradivarius|♪ talk ♪]]</sup> 08:08, 2 December 2013 (UTC)
|