Reading from array doesn't work

Klunky2

Veteran
Veteran
Joined
Jul 2, 2017
Messages
117
Reaction score
4
First Language
german
Primarily Uses
RMMV
Hello i'm new to arrays in RPG-Maker MV.
I was trying the most basic things out, to see if arrays really work. Turns out, even that doesn't work.

Here is my code:

arrays.png
Shouldn't really pose a problem right? But it does.

When I try to show the value of variable 250 in a message box. It still says the value of the variable is "0"

Why?
 

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
681
Reaction score
393
First Language
English
Primarily Uses
RMMV
Your third line should be $gameVariables.setValue(250, $gameVariables.value(212)[0]).

Otherwise, this should work fine when you make that adjustment.
 

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,712
Reaction score
1,162
First Language
EN
Primarily Uses
RMMV
As Ramza said, this line of your code is the problem:
JavaScript:
$gameVariables.value(250)=$gameVariables.value(212)[0];
That's because the value method returns an object/value, not a reference to the original property of $gameVariables. :)

Put another way: let's say variable 250 is zero at the time of assignment. The code then reads "set 0 equal to the first entry in variable 212's array". The value 0 here is without context; you can't change the value of 0 like that (it's a constant!), so nothing happens. :kaophew:
 

Klunky2

Veteran
Veteran
Joined
Jul 2, 2017
Messages
117
Reaction score
4
First Language
german
Primarily Uses
RMMV
Thanks got it now, but unfortunelately, a whole now problems has opend up, so I will open up a new thread as well. D:
 

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

Latest Threads

Latest Profile Posts

I'm sure this question's been asked before, but I can't find an answer: is there any way to run the Steam version of RPGMaker *without* being logged into Steam? It's a frustrating extra step sometimes.
Been seeing bright flashes in the sky for a while, and thought it was my eyes playing tricks on me. Nope! Lightning. Now it's raining heavily. Seeing lightning, but not hearing thunder, is weird.
Small Update for myself:
>Two Dungeon maps are done, Dungeon 3 is in progress. Dungeon 4 needs work.
>4 characters set up out of a possible 6 but those come later.
>Hub area needs work.
>Game completion..., 20-25% maybe?
Does anyone else find writing dialogue hard?
You guys want more tutorials? Well not only are we doing new video tutorials with Driftwood, we've also brought in two contributing authors for the blog to get a new tutorial every week! First one here from @Avery
https://blog.rpgmakerweb.com/tutorials/tutorial-mapping-interior/

Next week we'll get something from @hiddenone

Forum statistics

Threads
100,713
Messages
978,646
Members
132,325
Latest member
ighjku
Top