Advice for a script call

bvlgari

Villager
Member
Joined
Jan 14, 2018
Messages
29
Reaction score
4
First Language
english
Primarily Uses
RMMV
I was wondering if someone could help me with this:

You can imagine this like prize pools.
Im rolling a variable to get random numbers, for multiple purposes. Lets suppose i want to get a number between 1-5
So first i create the following array into the variable #1:
Code:
$gameVariables.setValue(1,[1,2,3,4,5])
After that, i need to pick one of those numbers randomly and set it as value of the variable #2; with this one i do some conditional branching. At the end, i need to remove that number from the array, since it was used; so, what im needing advice with is the following:

-Getting a value from one of the numbers within the array, setting it as value of certain variable, in this case, variable #2
- After using it to whatever, remove it from the array, to prevent getting the same number again ( thats the full purpose of this, otherwise i would just roll one variable between the numbers..)

Thanks in advance.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,421
Reaction score
596
First Language
Italian
Primarily Uses
RMVXA
You might want to use
Code:
$gameVariables(1).splice(index, 1)
index is the index of the element you just found. If you want to know more about arrays splice you can take a look at this.
 

bvlgari

Villager
Member
Joined
Jan 14, 2018
Messages
29
Reaction score
4
First Language
english
Primarily Uses
RMMV
Incredibly, i have solved it. I used the splice method, thanks for your advice. I managed to remove the items from the array at the time i want by the "specific" splice method, but actually used a prev. declared variable, connected at the same time with a random roll. Cheers to you.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top