Variable not defined? How do I fix this?

akuakudac

Veteran
Veteran
Joined
Jun 25, 2022
Messages
41
Reaction score
24
First Language
english
Primarily Uses
RMMZ
When I load my variables, this pops up, what am I doing wrong?

I'm trying to ass 10808 to the 7th variable in my database
I've tried using [] to refer to my variable, as well as referencing my variable as 0007, still not sure where I'm wrong at.
($gameVariable.value(7)+10808)
If anyone would help, that would be great! :D
image.jpg
 

Attachments

  • image.jpg
    image.jpg
    936.1 KB · Views: 2

Ahuramazda

The Last Elementalist
Veteran
Joined
Nov 9, 2012
Messages
344
Reaction score
240
First Language
English
Primarily Uses
RMMZ
Try this maybe?

Code:
$gameVariables.setValue(7, $gameVariables.value(7) + 10808)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,728
Reaction score
9,882
First Language
German
Primarily Uses
RMMV
First
my variable as 0007
NEVER use leading zeroes for any ID.
Those zeroes are only there due to the formatting of the editor, but they should never be used when in aprogramming language, because a leading zero tells the computer to use a different number system, like 0x means a hexadecimal value, and 00 is an octal value.

Second
You don't need a script for simply adding a number to a variable.
And you should try to use script commands only where absolutely neccessary, using the regular event command where possible.

yes, that sometimes means you need two or three event commands instead of one - but the event commands are protected and can't crash your game. Script boxes on the other hand can do anything.
That can be an advantage if you know what you're doing, but it also means that you have to know what you're doing or you risk much more than just crashing your game.
 

myenemy

Veteran
Veteran
Joined
Jan 17, 2014
Messages
131
Reaction score
63
First Language
Spanish
Primarily Uses
RMMZ
Set the variable with the editor to 0 in the editor before operating with the script.
Plus, wasn't it $gameVariables?
[Edit] The right way to set a variable is the one Ahuramazda said.

Try this maybe?

Code:
$gameVariables.setValue(7, $gameVariables.value(7) + 10808)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,728
Reaction score
9,882
First Language
German
Primarily Uses
RMMV
Set the variable with the editor to 0 in the editor before operating with the script.
the variables are already defined, the OP had a typo in his command
 

Latest Threads

Latest Profile Posts

Variation two of my nameless protagonist- now with color!!
WIN_20220815_21_48_46_Pro.jpg
thoughts?
Fun question - how do you manage the scope of your projects? All of my projects seem to balloon until they pop and they are suddenly nonexistent!
no I did not just have to write a song three different times because my music software doesn't support tempo changes!!
I WILL defeat this demonic USB connection notification bug
ScreenShot_8_15_2022_6_22_24.png
Mike trying to dodge the Memory Pawns invading Bantam Street. I like how the filters I used on the map almost make it look like the street is wet in a sense.

Forum statistics

Threads
124,568
Messages
1,164,455
Members
163,386
Latest member
MallowMal
Top