Using math.random with another variable instead of a number
Posted: Fri Nov 13, 2020 5:49 pm
Hey guys. We are trying to make a randomized character creator, but running into some problems. It is set up as follows.
We begin with a starting variable: StatBudget, which begins at 30. The aim is to have 3 stats that all together add up to 30.
STR is generated using math.random(1,20).
StatBudget is then set to StatBudget - STR.
WIS should be generated by picking a random number between 1 and StatBudget.
StatBudget is then set to StatBudget - WIS.
CHA will then be set to the remaining StatBudget number.
However, our code for generating WIS is not working. This is what we have currently in the script field:
Variable["Wisdom"] = math.random(1, (Variable["StatBudget"]));
Is it possible to use math.random in this way, by replacing a number with another variable? Hopefully we are just doing it wrong.
We begin with a starting variable: StatBudget, which begins at 30. The aim is to have 3 stats that all together add up to 30.
STR is generated using math.random(1,20).
StatBudget is then set to StatBudget - STR.
WIS should be generated by picking a random number between 1 and StatBudget.
StatBudget is then set to StatBudget - WIS.
CHA will then be set to the remaining StatBudget number.
However, our code for generating WIS is not working. This is what we have currently in the script field:
Variable["Wisdom"] = math.random(1, (Variable["StatBudget"]));
Is it possible to use math.random in this way, by replacing a number with another variable? Hopefully we are just doing it wrong.