-
Hi, I'm not sure whether this is actually an issue with either Dialogic or Godot (or whether I'm simply an idiot), but after toying with the "set variable to be a random number from x to y" parameter, it seems that the 'y' number is never selected. Of course, a simple fix is to simply increase 'y' by 1 so that I get the number spread that I would like, but it struck me as odd that the number spread would include 'x' but not 'y'. Is this simply a misunderstanding of how this is supposed to work on my part, or a legitimate issue of either Dialogic or Godot? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Randomisation in computer science is often exclusive of the range's upper number. What number generation do you use? |
Beta Was this translation helpful? Give feedback.
-
@CakeVR , thanks for your response. To go a bit in-depth on my end, the 'code' I was using for that test was just a single line within Dialogic (which I seem to remember finding somewhere in the documentation, though I can't find it now). Mine was nested inside of a variable to set its value: Taking a quick peek through Dialogic's code, the only place where I'm seeing 'pick_random()' called out within Dialogic's own code is in lines 104-115 of event_variable.gd, and if this is what I'm calling with the previous code, I would assume that the 'random_max' number should be inclusive, rather than exclusive:
Otherwise, I'm not really sure off-hand just which method is being utilized. |
Beta Was this translation helpful? Give feedback.
The
range
function is part of Godot.This will explain how it works: https://docs.godotengine.org/en/stable/classes/[email protected]#class-gdscript-method-range
As I mentioned, it's common that integer ranges are exclusive of their upper bound's number.