I just finished learning the bare basics of java scripting so I'm still pretty new to this and I'm more than willing to learn more.
And apologies if my code looks messy or wrong. I looked up a number plugins but I'm not actually sure how to integrate the code to be called from the game. I see Imported || Imported followed by var and (function () {} and I tried fiddling around with those but it hasn't been working. I might fare better it someone could point out how to do this. ^^;a
This is the code I written which works on console logs, it's a RNG dice roll script for practice.
There are two things I'm trying to do.
1. Make it possible using an option from the editor to change NumberOfDice to a different number via an event.
2. Run the Dice Rolling function when called from the game via script/plugin command and return the results so I can use them as variables for conditional branches. (The string doesn't have to stay colors, it can be numbers too as long as at the end I have a result to compare to.)
And apologies if my code looks messy or wrong. I looked up a number plugins but I'm not actually sure how to integrate the code to be called from the game. I see Imported || Imported followed by var and (function () {} and I tried fiddling around with those but it hasn't been working. I might fare better it someone could point out how to do this. ^^;a
This is the code I written which works on console logs, it's a RNG dice roll script for practice.
There are two things I'm trying to do.
1. Make it possible using an option from the editor to change NumberOfDice to a different number via an event.
2. Run the Dice Rolling function when called from the game via script/plugin command and return the results so I can use them as variables for conditional branches. (The string doesn't have to stay colors, it can be numbers too as long as at the end I have a result to compare to.)
//Dice Rolling Variables
var DiceType = ['Red','Yellow','Blue','Green'];
var NumberOfDice = 0 ;
//Dice Rolling function
var rollingDice = () => {
if (NumberOfDice === 4) {
var DiceRollA = DiceType[Math.floor(Math.random() * DiceType.length)];
var DiceRollB = DiceType[Math.floor(Math.random() * DiceType.length)];
var DiceRollC = DiceType[Math.floor(Math.random() * DiceType.length)];
var DiceRollD = DiceType[Math.floor(Math.random() * DiceType.length)];
} else if (NumberOfDice === 3) {
var DiceRollA = DiceType[Math.floor(Math.random() * DiceType.length)];
var DiceRollB = DiceType[Math.floor(Math.random() * DiceType.length)];
var DiceRollC = DiceType[Math.floor(Math.random() * DiceType.length)];
} else if (NumberOfDice === 2) {
var DiceRollA = DiceType[Math.floor(Math.random() * DiceType.length)];
var DiceRollB = DiceType[Math.floor(Math.random() * DiceType.length)];
} else if (NumberOfDice === 1) {
var DiceRollA = DiceType[Math.floor(Math.random() * DiceType.length)];
} else {
return 'You have no dice!';
}
};
//Die Rolling call
rollingDice();
