by Enjay » Mon Dec 10, 2018 2:53 pm
Graf Zahl wrote:I find it astounding how many people made this mistake with the random() function
I can easily understand how that happened though. I think that the reason is that, to a layman/non-programmer, "random" sounds exactly like what they want. Many of the people dabbling in DECORATE or ACS have minimal or no programming background and rely on looking at examples or figuring stuff out as they go - so when something seems to work, that's good enough.
So they type in something like random(1.0, 3.0) [perhaps having copied/pasted the code from another mod or example] to try to get any fractional value between 1.0 and 3.0 or maybe just think that writing it like that is correct to get either 1, 2 or 3 generated. The layman may not ever really appreciate that 1 and 1.0 carry a different data-type meaning.
With the incorrect format, earlier versions of (G)ZDoom would not spit out an error and the modder may simply have been unaware that "random" was not doing what they thought; perhaps because it was probably doing something close enough to what they wanted (and possibly did for a very long time). Our layman had also probably never heard of frandom [because, unlike random, it's not a real word, and even looks like a typo] and never seen it in an example - because so many examples and other sources of code were also wrong.
I'm not saying that the warning should not exist; it most certainly should. I'm saying that I completely understand how the "random()" mistake became so common. Even taking all that into account, I do still agree that just how ubiquitous it became is quite amazing.
[quote="Graf Zahl"]I find it astounding how many people made this mistake with the random() function[/quote]
I can easily understand how that happened though. I think that the reason is that, to a layman/non-programmer, "random" sounds exactly like what they want. Many of the people dabbling in DECORATE or ACS have minimal or no programming background and rely on looking at examples or figuring stuff out as they go - so when something seems to work, that's good enough.
So they type in something like random(1.0, 3.0) [perhaps having copied/pasted the code from another mod or example] to try to get any fractional value between 1.0 and 3.0 or maybe just think that writing it like that is correct to get either 1, 2 or 3 generated. The layman may not ever really appreciate that 1 and 1.0 carry a different data-type meaning.
With the incorrect format, earlier versions of (G)ZDoom would not spit out an error and the modder may simply have been unaware that "random" was not doing what they thought; perhaps because it was probably doing something close enough to what they wanted (and possibly did for a very long time). Our layman had also probably never heard of frandom [because, unlike random, it's not a real word, and even looks like a typo] and never seen it in an example - because so many examples and other sources of code were also wrong.
I'm not saying that the warning should not exist; it most certainly should. I'm saying that I completely understand how the "random()" mistake became so common. Even taking all that into account, I do still agree that just how ubiquitous it became is quite amazing.