Recommendations for the Variables and Comment box

Hi. I would just like to recommend some minor changes, if possible, to the next release. I had trouble checking for the initial values of string variables. They still have 0 values so checking if they have “” doesn’t work. If I check if the variables have 0 values (initial), then put a string value to the variable, it can “somehow” read both the value and string because conditions checking for those values are executed. So my suggestion is to have a control to determine whether a variable is a string ("") or integer (0) type in its initialization. Then, conditions checking for the strings of variables will only be able to choose string variables and those checking for the values will only be able to choose integer variables.

Also, though not important, after typing in a comment box and pressing ok, I have to move the mouse in order to see the changes. I think it would be nice to have it to reflect the changes right away even without doing anything. :smiley: Thank you.

You are right, GD variables store both a numeric and a string value. But if you set the initial value of a variable = Raziel and use variable-string related conditions, for example:

String of variable PlayerName is = "Raziel"

GDevelop will check this initial string only (not the number), then this condition will return true :slight_smile:

The comments added in the event lists? Wich OS do you use?

Hi Lizard. Thank you for the reply. In the game I am making, I can’t set the initial value of the global variable (e.g. difficulty) to “” at the start of the scene because the difficulty variable will be changed in the other scenes. Then when I get back to the first scene, I need the value of the difficulty variable.

The first thing I did was to check if the string of difficulty is “”. If it is, change the string to “normal”. I was thinking that if I return from the other scene, it will not change the string of difficulty to normal since it does not meet the condition (difficulty is “”). But it does since the initial value of the difficulty variable is 0, not “”. So I tried checking if the value of difficulty is 0 and if it is, change the string to normal. It did not run the action at all maybe because GD was confused as to what type of variable I’m using.

What I did then was to make another global variable “GameStarted”. If its value is 0 (initial), change its value to 1 then change the string of difficulty to normal. It will only be change once since the value of GameStarted will not be changed anymore.

That’s why I think it might be helpful if the variable type can be specified and screened by GD when choosing the conditions and actions.

Yes, the comment box in the events list. I’m using Win7.

You can set the initial value of global variables in the “Global Variables” window, through the project right-click-menu. Yes, you need things like difficult to be global variables, to keep the value through scenes :slight_smile:

Checking the numerical value of a variable with a current string value will always return 0, that surely causes the problem :wink:

I’m sorry if it caused confusion. What I mean is i can’t set the initial value of the global variable not because it can’t be set, but because in the game I’m making, setting the initial value to “normal” at the start of the scene, would cause it to “set the value to normal everytime it enters the scene”, be it a global or scene variable. That’s why I used another global variable “GameStarted” to track whether the game has been run the first time(0 value) or not (1 value). :smiley:

But since you mentioned, I should try checking if I could change the value of the variable to “” through the Project right click. If it can be, maybe there’s no need to have the GameStarted variable. Thank you very much for your help. :smiley:

Update:

I tried changing the value through the Project, right-click menu to “”. It does not run the actions if I use the condition

if the text of the variable is = ""

But it does run when I “force” the condition to check for the value. When I choose

"check for the value"

then I put “” in the value, it produces syntax error. Obviously because it’s looking for a number. But if I continue, it does run the actions. I said “force” because it produces a syntax error but still allow the actions to be run. In short:

“check for the string (”")" does not run even if the initial value is “”
“check for the value (”")" does run with the initial value “” even with a syntax error

I just used another variable as mentioned in the previous post just to be sure. Thank you again for all the help. :smiley:

In this variables window, if you want to set a void string (“”), you don’t have to put the "s, just leave it empty (I mean totally empty) and test. Oh, I see it works on native only… I’ll check it later :slight_smile:

1 - The first problem, read above.
2 - This is a good one, you set a string as a numeric parameter (syntax error) so GD converts this parameter to the default number → 0, then you try to read a number from a current string variable, so GD get the variable default number → 0, finally 0 = 0 so the condition is met. It’s funny not because you, but because the things that GD winds up doing in exceptions and generate odd behaviors, but it works and doesn’t crash, is not great? :smiley:

Thank you very much for the explanations. Yes its great. Its cool. I really appreciate GD. I hope I will know how to program in c++ and be able to help in GD’s development someday. I believe and see that it has a lot of potentials, being open source at that. Thank you very much Lizard.

Just want to note that this bug is already fixed (not loading empty string variables in web), and not recenlty but 3 months ago!, you can check it here: Fix loading stored values set to 0/empty string in HTML5 games :smiley:
It was 3 weeks after the last release, and will be available in the new version that should be released this week :slight_smile:

Then why there is a number type and a text type? Won’t it be simpler to add a typeof check like in JavaScript?

Another thing which might be related is when you get a point from a sprite, it always return a valid number even if the point doesn’t exist. It would be great if we have undefined or NaN.

Wow! A new version will be released this week. Cool.