Note that this has the same effect in-game as using Control Variables -> Script:
[1,2,3,4,5,6], with the disadvantage that the editor's Event Searcher tool will not see that variable being used.
This Control Variables -> Script command sets the chosen variable to an array of numbers:
[1, 2, 3, 4, ...etc..., 139, 140]. It does this by:
- Starting with a new array of
140 blank entries (new Array(140)); then
- Mapping each entry to the number
1 + n...
- ...where
n is the index of the entry (0 for first entry, 1 for second, etc)
Technical details here:
The Array.from() static method creates a new, shallow-copied Array instance from an iterable or array-like object.
developer.mozilla.org
To generate an array of integers from 1501~1634 inclusive, you could use this instead:
JavaScript:
Array.from(new Array(1 + 1634 - 1501), function(_, n) { return 1501 + n; })
(The
1 + at the start is because we're including both 1501 and 1634.)
😅 Oof. Variables are typically for things that change during a playthrough, not static data. It's a waste to store the joke text like that, and it will bloat save files a bit, but like you say, it is workable.
Perhaps you accidentally reset the array every time before picking a new value?
My example specifically checks the
length of the array (i.e. the number of remaining entries in it) so the list only gets initialised if it's empty (or doesn't have a
length property):
You could reset it in a separate event (e.g. on new game) if you prefer that. In that case, though, you should still check to see if the array's
length is more than 0 before splicing a value out of it.
Like Turan says, don't take anything that ChatGPT says seriously. As its name suggests, it's a chat bot first and foremost: it cannot distinguish fact from fiction and is prone to making things up. Can be helpful for creative inspiration, but for reliable technical results, definitely look elsewhere.
I was going to get all philosophical here, then thought better of it.
@caethyril you have the patience of Buddha, thank you so much for helping guide me through this. We're almost there!

And
@ATT_Turan thank you so much for sticking around as well.
I've been working on this for a couple of hours and I have things
mostly working, and I THINK I understand what's going on. But it's not quite working as intended yet, and I'm curious to understand what's going wrong. I've done everything I can do by way of troubleshooting.
For now, jokes are stored in variables 1801-1934 (I've moved them since last post since I realized there was a conflict). More on storing strings to vars later
😳
In my test event, this is what I have so far:
It's very inefficient, and I apologize for how bad I am at this, but I'm just trying to get things to function properly at this point! I have a switch that gets set if the array is empty. That part works fine.
For ease of testing I'm just choosing from the first few jokes.
I have the show text telling me both variable number and the string it's storing, and the reason I'm doing that is because no matter what I do, the lowest number variable I have stored always echoes as "0". So in the present case, if var 1801 is chosen, it produces a 0. This was the case also back when the variables were in a different range, so that suggests I don't have any other competing issues complicating the variable.
To be sure, variable 1801 is initiatlized with a joke string just like the others.
Otherwise it does work -- the other jokes print as intended, they don't repeat, and once they're exhausted, it says there's no more.
I've done a whole bunch of testing into what might be causing the lowest variable to produce 0, including the "I don't know what I'm doing but let's just change numbers and move things around" brute force method, which has its uses
On the subject of storing strings to variables tho -- I had NO IDEA that this created a bigger save file, or that variables were generally best reserved for non-static information, tho of course this all makes perfect sense when I think about it for a second lol. The thing is, it's not just 130 jokes that are stored to variables ... there's hundreds upon hundreds of non-changing strings stored to variables in my (gigantic, unwieldy) project, all of them initialized on a single autoload common event when the game begins. What might be the real-world hazards of this? Should I be concerned for real about bloated save files, or can I rest a bit easy knowing that I'm misusing variables with consequences that are confined to the realm of the theoretical?
And either way, I'm super curious to know what would be the optimal way to store tons and tons of static strings at a game's initialization. Back in the day when I coded for a MUD, people smarter than me advised me to set up all these strings at the very beginning, so I've sort of coasted on that general knowledge, but I have no idea how to best implement this sort of thing in RPGMV. Very much interested though, I'm happy to rearrange things if it means faster loads or smaller saves.
In any case, thanks to all for the guidance. To say it's appreciated would be an enormous understatement, and to call it an enormous understatement would be an incredible oversimplification!
-c


