Fix these code problems

After some GD updates, I started to have initialization problems, such as loading delays and problems with variables. But using the development tool (CRTL+Shitf+I) I managed to solve several problems with variables, mainly objects, which were set to String instead of number.
However, there are still some problems that I haven’t been able to solve. These issues do not directly affect the game, but I can see that some things are not entirely correct.

For example these errors here:

Error: bad behavior "" requested for object 'obj_player_platform" (action: Simulate jump key )
Error: "You must enter a variable name." in: "" (scenevar)
Error: "You must enter a text (between quotes) or a valid expression call." in: "" (string)
Error: "You must enter a number or a valid expression call." in: "" (number)

This error

Error: bad behavior "" requested for object 'obj_player_platform" (action: Simulate jump key )

on the other hand, I even understood why it’s there, but I don’t know how to fix it! Because the only “jump” I use is for the hero’s Knockback and the jumps of course!

See the example:

I wanted help to solve these problems, since they are the only ones that remain.

Full log

“Error: bad behavior “” requested for object 'obj_player_platform” (action: Simulate jump key )"

I’ve only seen this when some instance of “Simulate jump key” is not properly detecting your player’s behavior. It could mean that it was created at such a time that behaviors weren’t being added correctly (Sometime in the late b90 early b100 era) or somehow autocomplete didn’t fully activate correctly.

Your easiest bet is to delete all instances of “Simulate Jump key” actions, and re-add them manually using the full action/condition editor (not right-click editor) since that will show if any behaviors aren’t being added right.

Note: When this bug was ongoing, even if you pulled up the existing action it would not show any errors. You had to delete the action and manually re-add it to fix it. I thought they did some stuff to fully fix it, but this seems similar to what you’re having.

Indeed, reinserting the behavior worked and no more errors. Now I need to find these variables errors. I believe something has changed with the quotes, dots and commas.

One of the errors I found, but I can’t solve, which is with:
Error: "You must enter a number or a valid expression call." in: "" (number)

which matches this part of the code

Even, deleting and reinserting the same code the error happens.

I found the problem in this case. Changing from “Instant” to “Permanent” and back to “instant” the errors disappear. But the problem is that this error always happens, even if you reset the action again.

I did a test with a new project, just an object on the screen and a force action, if this action is placed as “instant” it gives an error, but when changing to “permanent” and back to “instant” the error ends!

What I noticed, when putting a kind of force, that even though its pattern is “instant” it doesn’t seem to recognize giving the error. But if you click on “instant” or “permanent” it works 100%. I made a comparison video for you to see!

Well I solved my problem, but I believe it is something internal to GDevelop. And why does it bother me? Due to the fact that if there are many errors appearing in the debug, it takes several seconds for the game to start. Before fixing these errors my game took about 30 seconds to start, now it doesn’t take 8.

Wow that’s a lot. Is this the case even if you close the JavaScript debugger?

What I noticed, when putting a kind of force, that even though its pattern is “instant” it doesn’t seem to recognize giving the error

Indeed, I think we need to set a proper default value internally. Thanks for reporting.

I think the real problem here might be how we are printing to the console in real time. Instead we should probably queue logs and only print them all after having launched the preview, since logging to the JavaScript console is a quite expensive operation. Otherwise those error do not really matter a lot.

Yes, I was having this problem of the delay in starting the game, and by the GD debug these errors did not appear. Then I remembered the development tool, and it showed all the errors. And since my project is big, it took me a while to fix everything.

:slight_smile:

There are these other problems that I can’t solve. Like the one in the image.
Screenshot_20220627_104045

I noticed that GD does not ignore the error and tries to “go around” until it can “compile” the game and run. And that also makes the game take time to run.

Thanks for explaining!

There are these other problems that I can’t solve. Like the one in the image

Don’t worry about these, I fixed these for the next GDevelop version.

I think the real problem here might be how we are printing to the console in real time. Instead we should probably queue logs and only print them all after having launched the preview, since logging to the JavaScript console is a quite expensive operation. Otherwise those error do not really matter a lot.

Yes I think so, and errors/warnings in the export/preview anyway should be outputted somewhere where we can display them in a user friendly manner in the editor.

1 Like