Can't use number in variables

I make websites and applications for a living... Therefor I have a certain logic in coding, which I understand myself.
Now my issue is this:

I first declare a variable in a COMMON EVENT.
Make sure it is set to zero.
Then I add +1 .. which would make it an integer with 1.

I run it, the game bugs out, shows an empty text box.
Whatever I try, I am unable to use a variable to return a number, and my logical brain is absolutely baffled.

upload_2019-11-23_14-50-8.png


So here is how I reproduce, after picking up an amethyst, I can break it down into its core elements with a common event as shown above. I use the item:
upload_2019-11-23_14-47-13.png


And it crashes.. it shows some weird jumping black bar, or sometimes a empty textbar
upload_2019-11-23_14-47-29.png

Now if I remove the variables from the event, I do get this (as expected):"
upload_2019-11-23_14-50-22.png

upload_2019-11-23_14-49-0.png


Help me understand, I beg you.

So this works:
upload_2019-11-23_15-7-4.png

upload_2019-11-23_15-6-40.png


But adding this crashes it:
upload_2019-11-23_15-8-20.png

upload_2019-11-23_15-7-59.png

I've moved this thread to VXAce Support. Thank you.

Do you have any custom scripts installed? It's possible your var22 is assigned to something that influences your GUI.

Also, if you want a variable as a specific value, you don't need to make it 0 first and then add whatever needed, you can set it as that value right off the bat and reduce the CPU cycle. With enough calls you'd otherwise slowly but surely bog the system down.
Thanks You are a hero.. .21 was corrupted, 22 actually stretched my textbox.. I cannot find where it assigned .. but .. those both were broken.
Some things you should always keep in mind:
When you add new scripts, make a search with CTRL+Shift+F (global search) or CTRL+F (search in that slot) and then type in $game_switches or $game_variables to see if there are any references in the new scripts. Most scripters also make it so that adjustable switches and variables are in a block section near the top for easy changing.
DO NOT just paste a script in and expect it to work, always check the settings and asign new switches/variables to the script as needed because it's always possible they will by default refer to a switch/variable that you already use.
And make sure that script-asigned variables are named properly so you don't accidentally use them later wrongly.

In your case, I assume you used YEA - Ace Message System without doing that, hence why var22 bugs it out.
Haha, thanks.. I normally name all my vars and switches... I first used a loop, but thought that was causing the bug.. so now I did it like this..

I assumed setting any variable to zero at script head would suffice.

This was a project I worked on a few years back and recently restarted it, so maybe that's why I lost some ins and outs
upload_2019-11-23_16-7-30.png
@Orifiael just remember, you dont need to declair a variable = 0
because all variables start at 0 at all times.

in case of need, you can create a conditional branch to check IF the variable = 0 or > 0 (bigger)
than add + x to th variable. if it = 0 or >0 you can do somthing else, like less add or add nothing.

all variables start out on ZERO and switches always OFF. unless you declare it other wise.
either with + on the start up or in a conditional branch like the following example:

if Variable #0032 name >= 0
variable #0032 name = 0
end

so you know than avoid bugss as well =)
@Orifiael your problem is that you're not the only one using variables in your game - you have scripts that also use variables (and those scripts NEED to use the variables to work).
But the scripts can't name a variable, so you have to do that for them to keep yourself from using such variables.

Every script that uses variables has a configuration section where you tell it which variables it can use and where you learn what will happen if you place a number into that variable.
For example the message script has two variables telling it how wide and how high the text boxes should be. In your first screenshots the game did not crash - it did exactly what you told it to do. It reduced the text box width to zero letter width after you placed a zero into the variable assigned to hold the text bos width.

Because of this you need to check all your scripts to what other variable configurations you might have missed, name those variables in your project to prevent yourself fromd using it for something else and then get your event working with variables exclusive to itself instead of variables that are used two or three times for different things in your project.

Original thread: https://forums.rpgmakerweb.com/threads/cant-use-number-in-variables.115530/