- Joined
- Jan 26, 2014
- Messages
- 1,281
- Reaction score
- 106
- First Language
- Irish
- Primarily Uses
- N/A
I have been reading a lot about arrays lately which were mainly from Stack Overflow and Ruby docs, however I seem not to be able to produce what I wanted in a script in RGSS3. Mainly the following:
1. How can I access ANY elements of the array?
Let's say I am checking an array of numbers, how can I check if anything from the array may contain what I am checking?
ex:
foods = ["Bacon", "CheeseBurger", "Ham", "Hotdog"]from this array named foods, I wanted to check if the foods array contains "Bacon". Sure enough, I can say it like:
if foods.first == "Bacon"however, I wanted a way to check everything from the array. More like checking what's inside the array that I wanted to check.
Another reason why I want this is if I am checking a bunch of array elements. Say for example I made an array of Equipment or Item Ids, and I wanted to check if that equipment or item array has "Potion" in it, how can I implement this?
2. How can I shortcut adding arrays?
I have a plan of making bunch of array elements, may it be 10s or 20's. However, you'll probably ends up making bunch of script codes to call elements of an array.
My question is this: Is there a way to add an array from 1 element to 30 elements?
for example I have an array:
bunch_of_arrays = [[1], [2], [3]]now, instead of adding [4], [5], [6] inside the array, is there a more easier way to add 4 to 190?
Thanks in advance for those who would answer.
1. How can I access ANY elements of the array?
Let's say I am checking an array of numbers, how can I check if anything from the array may contain what I am checking?
ex:
foods = ["Bacon", "CheeseBurger", "Ham", "Hotdog"]from this array named foods, I wanted to check if the foods array contains "Bacon". Sure enough, I can say it like:
if foods.first == "Bacon"however, I wanted a way to check everything from the array. More like checking what's inside the array that I wanted to check.
Another reason why I want this is if I am checking a bunch of array elements. Say for example I made an array of Equipment or Item Ids, and I wanted to check if that equipment or item array has "Potion" in it, how can I implement this?
2. How can I shortcut adding arrays?
I have a plan of making bunch of array elements, may it be 10s or 20's. However, you'll probably ends up making bunch of script codes to call elements of an array.
My question is this: Is there a way to add an array from 1 element to 30 elements?
for example I have an array:
bunch_of_arrays = [[1], [2], [3]]now, instead of adding [4], [5], [6] inside the array, is there a more easier way to add 4 to 190?
Thanks in advance for those who would answer.
Last edited by a moderator: