Hello, i'm making a script but i'm having problems with the rand command
This is the error i have:
[Error]: buildin_rand: range (0) is too small. No randomness possible.
[Warning]: Script command 'rand' returned failure.
[Debug]: Source (NPC): test#thts at 1@thts (156,371)
[Debug]: Source (NPC): test#thts is located in: INSTANCING
The purpose of the code is to randomly shuffle and assign properties (map name, X-coordinate, and Y-coordinate) to a set of floors in a tower instance i'm making. Here's a breakdown of the code:
1. Initialize arrays for floors, map names, X-coordinates, and Y-coordinates.
2. Determine the number of floors in the tower.
3. Use a loop to randomly select a floor from the remaining options and assign its properties (map name, X-coordinate, and Y-coordinate).
4. Remove the selected floor and its associated properties from the available options to avoid repetition.
Possible reasons for issues in the code:
- The algorithm relies on the 'rand' function to generate random numbers.
- Confirm that the arrays are properly initialized and that the indices match between arrays.
Could anyone here help me? what i'm doing wrong? xD
Question
InfectedX
Hello, i'm making a script but i'm having problems with the rand command
This is the error i have:
[Error]: buildin_rand: range (0) is too small. No randomness possible. [Warning]: Script command 'rand' returned failure. [Debug]: Source (NPC): test#thts at 1@thts (156,371) [Debug]: Source (NPC): test#thts is located in: INSTANCING
And this is my script...
setarray 'floors[0],3,4,5,6; setarray 'maps$[0],instance_mapname("3@thts"),instance_mapname("4@thts"),instance_mapname("5@thts"),instance_mapname("6@thts"); setarray 'xs[0],27,18,155,50; setarray 'ys[0],44,97,100,18; .@loop = getarraysize('floors); for (.@i = 1; .@i <= .@loop ; .@i++) { .@r = rand(getarraysize('floors)); 'order[.@i] = 'floors[.@r]; deletearray 'floors[.@r],1; 'wm$[.@i] = 'maps$[.@r]; deletearray 'maps$[.@r],1; 'wx[.@i] = 'xs[.@r]; deletearray 'xs[.@r],1; 'wy[.@i] = 'ys[.@r]; deletearray 'ys[.@r],1; }
The purpose of the code is to randomly shuffle and assign properties (map name, X-coordinate, and Y-coordinate) to a set of floors in a tower instance i'm making. Here's a breakdown of the code:
1. Initialize arrays for floors, map names, X-coordinates, and Y-coordinates.
2. Determine the number of floors in the tower.
3. Use a loop to randomly select a floor from the remaining options and assign its properties (map name, X-coordinate, and Y-coordinate).
4. Remove the selected floor and its associated properties from the available options to avoid repetition.
Possible reasons for issues in the code:
- The algorithm relies on the 'rand' function to generate random numbers.
- Confirm that the arrays are properly initialized and that the indices match between arrays.
Could anyone here help me? what i'm doing wrong? xD
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.