More advanced scripting capability with tokens like "wait X"


It is great to see that the “wait” X seconds command has been added to the right side of Gdevelop.
Maybe, a few more of these scripting functions can be implemented, on the right hand, in order to make it easier for people to program, more complicated functions, that could be 20 or 30 lines long.

In order to implement a fully working script language. It would require the right hand side of the code IDE. to also Jump to various statements, using Jump points. Like Goto: Start, or Goto: loop 1.

A few more tokens like the Wait X seconds, could be added, in some small library.
Here is an example:

Set variables:
Variable A: 10
Variable B: 1
Variable C: 100

:start // this is the first GOTO point, where the code will loop and jump after a check.
Increase variable B: by 1 // The variable is increased by 1 on each loop
Wait 0.1 // Wait 0.1 seconds each time the variable is increased. which allows for clock synced, actions.
Set text box to: Text of Variable B // The variable is displayed as increasing when you run the game.
---- If Variable B is < than Variable A, go to :start //If the variable is smaller than Variable A, which is 10, go to the :start point. At this point, the code will jump to the :start section, 10 times, each time increasing the variable B by one, with a delay of 0.1 seconds on each increase. When the value is 10 or equal, the code will go to the next section (since right side code will be read downwards)

:Loop2 (if you are at loop2 , it means that the Variable B is now 10. So the goto :start check is skipped.)
Increase Variable B by Variable A. // will increase the Variable B which is 1, by 10 each time.
If variable B is = 90 , display: “nearly there” // if B has been increased 9 times, it will be 90. So a message will appear. This statement is above the Goto below, so it can check before ending the code.
If variable B is < than Variable C, goto :loop2 // if variable B is smaller than 100, which is var C, then go to Loop2. To increase it by 10 again.
If variable B is equal to Variable C , Go to :end // If Variable B reaches 100, which is Variable C, end script.
halt. (ends the script, stops the processing of the panel that is running it).

This coding structure is similar to MIRC scripting for example. Which would parse commands from the top to the bottom, allowing for complicated scripts were variables are changing other variables. And constants and everything declared at the beginning, but also allowed to be changed in the loop. Simple tokens like:

setting variable values:

Var_B = Var_B + 1 , or Var_B + Var_C , can be used, to change the variables.
or Var_B += 1 , or Var_B -=1 , to decrease a variable.
or Var_b = +1 , or Var_B = -1
even better: var_b = (Var_B - 1) , and Var_b = (var_b + 1) , so that way you can read what is happening as well. like:
Set Var_B to (Var_B - 1) , 1 could also be another variable, which could change in the loop.

This would possibly allow developers to free their creativity, and make more complex scripts, for dialogue, animation, and other things. It is very simple after you see it working downards, and jumping to loop points. Even allowing the entire animation of a character, and frames and collisions, to be controlled within one “right side” panel. in gdevelop. (or in rpg’s where characters speak to each other, and move around.)

Also MIRC uses some tokens. for example $1 is the first word typed. $2 is the second.
$2- , is all words after the second word typed. $char($1, 2), could be the second text character of
the word Hello, which would be “e”. If a few of these scripting thigs were added to Gdevelop, in the right side, it would make things, a lot easier to code, and create even complicated graphics and movement systems.
So you could have something like “The hero is approaching the castle” , $shake($6), which would shake the word Castle. or some other implementation.
the % symbol, is used for declaring Variables. like set %a to 5 , or
if $current_frame = 3 , enable the collision for the attack of a character (so it would
remove hitpoints, only when the sword is extented in an animation for example.

finally, this would allow complex character scripting, for all the characters in a game, with timers, variables and everything.

That’s about it.

all the best