Need help turning Array into Integer.

I'm altering Yanfly's Poaching script to work as a pseudo Steal script (Yanfly's Steal/Snatch plugin doesn't work with the TBS I'm using, but Poaching does).

In short, I'm trying to use an array as an integer for adding items to a global pool:

pool1.push($dataItems[Set1]);

Yanfly's lunatic script works by adding items one by one individually:

pool.push($dataItems[1]);
pool.push($dataItems[2);
pool.push($dataItems[3]);
etc...

I'm worried doing this for every item I want to include will lead to bloat (feel free to correct me if I'm wrong!) so I was hoping I could make it more efficient.

I found a post pertaining to what I'm looking for, but I don't understand what it's doing: https://forums.rpgmakerweb.com/index.php?threads/gaining-items-via-array-instead-of-integers.24092/

I'm not fluent in .js but I can usually use context to understand what to do. Any help is greatly appreciated!
Something like this?
JavaScript:
var pool = Array.from([1,22,33,14,5], function(n) { return $dataItems[n]; });
Something like this?
JavaScript:
var pool = Array.from([1,22,33,14,5], function(n) { return $dataItems[n]; });
Well I'll be, it worked! I've no idea how it works, but I'm thankful for the help!
I'm worried doing this for every item I want to include will lead to bloat (feel free to correct me if I'm wrong!)
You are 😉

I'm not clear what you think would get bloated from it, as the end result can only be formatted in one way in order for Yanfly's code to work correctly...so no matter how you add the items, the final product must be the same 🙂

It doesn't help that the post you're trying to learn from uses incorrect terminology. You can't "turn" an array into an integer or vice versa. An array is just a list of things. In your case, it's a list of Items.

You're taking each Item from another list (the $dataItems array), and referencing which one you want with its ID is the only place in here where an integer value is used for anything.

So the code @caethyril provided is absolutely more efficient in terms of your typing, but it produces the same thing - the only thing that would be bloated is the text field you're typing all of those lines into. That would make, like, kilobytes of difference in your game files.
You are 😉

I'm not clear what you think would get bloated from it, as the end result can only be formatted in one way in order for Yanfly's code to work correctly...so no matter how you add the items, the final product must be the same 🙂

It doesn't help that the post you're trying to learn from uses incorrect terminology. You can't "turn" an array into an integer or vice versa. An array is just a list of things. In your case, it's a list of Items.

You're taking each Item from another list (the $dataItems array), and referencing which one you want with its ID is the only place in here where an integer value is used for anything.

So the code @caethyril provided is absolutely more efficient in terms of your typing, but it produces the same thing - the only thing that would be bloated is the text field you're typing all of those lines into. That would make, like, kilobytes of difference in your game files.
Hah, good to know! As it were I have a small bit of experience with scripting from modding Skyrim, and save bloat from inefficient scripting is a very real thing. So much so that I make a conscious effort to avoid it whenever possible.

That being said, this new code will help cut down on repetitive copy/pasting greatly, which is always a win in my book. It'll also help with making my pools more modular in nature.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-turning-array-into-integer.163698/