Ok so I thought there was an option for this in the normal event programming but there isn't.
You can set a variable to the value of another, and you can set a variable to a random between 2 constants, but I need to be able to set a variable to a value between 2 other variables.
I'm not going to reveal too much about the system that it's going to be used for, but i'll give a very brief outline of the situation...
variables used...
1 = player input
2 = buffer
3 = upper limit
4 = lower limt
Player enters a number between 1000-10000
There are 10 stages of difficultly
1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
Each stage can change by either + or - of the same value.
For example
1000 = 0 - 2000
2000 = 0 - 4000
3000 = 0 - 6000
4000 = 0 - 8000
5000 = 0 - 10000
6000 = 0 - 12000
7000 = 0 - 14000
8000 = 0 - 16000
9000 = 0 - 18000
10000 = 0 - 20000
So if the player enters 1267, the difference is 267 - 2267
5635 is 635 - 10635
I have already completed the coding to calculate the upper and lower limits of what the player enters, however now I need to be able to set a variable to a random number between the upper and lower limits.
For example, if the user enters 4964
I need to set a variable to a random number between 964 and 8964.
Entering every possible combination is not an option, it would take way too long.
My current thoughts would be to create something like the following:
set variable 2(buffer) to value of variable 1(player input)
if variable 2(buffer) bigger than 1000 & smaller than 1999
set variable 2(buffer) to a random number between 1 - 2999
if variable 2(buffer) is less than variable 4(lower limit of player input(calculated earlier))
set variable 2(buffer) to the value of variable 4(lower limit)
else
if variable 2(buffer) is greater than variable 3(upper limit of player input(calculated earlier))
set variable 2(buffer) to the value of variable 3(upper limit)
This is not what I wanted, but at the moment its the only option I can think of, it sets a random number, and check to makes sure its not lower or higher than the limits set.
This fails in the following method...
Player enters 1936
Limits calculated at 936 to 2936
Random number can be set anywhere from 1 - 2999
So there is an area from 1 - 936 where if the random number is chosen within here, it will be set as 936.
Anyone got any ideas? is it easy to set a variable to a random value between 2 variables in RGSS?
EDIT: Had an idea
I could set a label above random number select then, if the variable chosen is higher or lower than the lmits, I could return to the label, rather than setting it to the lmit.
This is better but still means processing more coding than nessecary, the code is huge already and branches are way off the visable area.
You can set a variable to the value of another, and you can set a variable to a random between 2 constants, but I need to be able to set a variable to a value between 2 other variables.
I'm not going to reveal too much about the system that it's going to be used for, but i'll give a very brief outline of the situation...
variables used...
1 = player input
2 = buffer
3 = upper limit
4 = lower limt
Player enters a number between 1000-10000
There are 10 stages of difficultly
1000 2000 3000 4000 5000 6000 7000 8000 9000 10000
Each stage can change by either + or - of the same value.
For example
1000 = 0 - 2000
2000 = 0 - 4000
3000 = 0 - 6000
4000 = 0 - 8000
5000 = 0 - 10000
6000 = 0 - 12000
7000 = 0 - 14000
8000 = 0 - 16000
9000 = 0 - 18000
10000 = 0 - 20000
So if the player enters 1267, the difference is 267 - 2267
5635 is 635 - 10635
I have already completed the coding to calculate the upper and lower limits of what the player enters, however now I need to be able to set a variable to a random number between the upper and lower limits.
For example, if the user enters 4964
I need to set a variable to a random number between 964 and 8964.
Entering every possible combination is not an option, it would take way too long.
My current thoughts would be to create something like the following:
set variable 2(buffer) to value of variable 1(player input)
if variable 2(buffer) bigger than 1000 & smaller than 1999
set variable 2(buffer) to a random number between 1 - 2999
if variable 2(buffer) is less than variable 4(lower limit of player input(calculated earlier))
set variable 2(buffer) to the value of variable 4(lower limit)
else
if variable 2(buffer) is greater than variable 3(upper limit of player input(calculated earlier))
set variable 2(buffer) to the value of variable 3(upper limit)
This is not what I wanted, but at the moment its the only option I can think of, it sets a random number, and check to makes sure its not lower or higher than the limits set.
This fails in the following method...
Player enters 1936
Limits calculated at 936 to 2936
Random number can be set anywhere from 1 - 2999
So there is an area from 1 - 936 where if the random number is chosen within here, it will be set as 936.
Anyone got any ideas? is it easy to set a variable to a random value between 2 variables in RGSS?
EDIT: Had an idea
I could set a label above random number select then, if the variable chosen is higher or lower than the lmits, I could return to the label, rather than setting it to the lmit.
This is better but still means processing more coding than nessecary, the code is huge already and branches are way off the visable area.