Commit Graph

16 Commits

Author SHA1 Message Date
Florian Rival 913e367f6f Allow to properly use variables/properties/parameters in brackets to access a structure variable (#5738)
* This means expressions like `MyStructure[SomeIndexVariable]` will work properly for a structure if `SomeIndexVariable` is a string variable. Gdevelop now properly uses the type of the variable/property/parameter (to avoid considering what's inside the brackets as a number if it's a string). Remember to declare your variables in the variables editor so that you can use them in expressions.
2023-10-09 18:21:49 +02:00
Florian Rival 8944df1831 Add support for writing parameter names directly in expressions (#5676) 2023-09-22 22:41:13 +02:00
Florian Rival a0925c79c3 Add a new simplified way to use variables in expressions, and automate renaming of variables in events (#5580)
* You can now simply write the name of the scene or global variable in an expression to use it: `1 + MyVariable` (instead of `1 + Variable(MyVariable)`).
* Objects can also have their variables accessed like this: `MyObject.MyVariable` (instead of `MyObject.Variable(MyVariable)`.
* This also works for properties inside functions of behaviors or custom objects. For example, you can write `Speed` instead of `Object.Behavior::PropertySpeed()`.
* This syntax will also handle all types of variables without the need to write ToString. For example, you can now write "Score: " + CoinsEarned instead of "Score: " + ToString(Variable(CoinsEarned)).
* This syntax will only work (and autocompletions will be shown) if you add the variable in the variables editor of the scene, the project or in the variables of the object. It's a good practice to always declare your variables here and give them a default value - do it to benefit from this new simplified syntax, which will make your formulas and expressions much more readable.
* When you rename a variable in an editor, it will now rename the variables everywhere in the events of the project. This makes it much easier to change the name of a variable if you find a better one. Note that this works for "rootæ variables, but not variables inside structures or arrays.
2023-09-21 18:56:12 +02:00
D8H 763aa0aa25 Show expression errors directly in the event sheet (#3823) 2022-06-03 23:02:51 +02:00
Florian Rival ca6f11b55a Support for describing completions to display for an expression (#1447) 2020-02-22 14:27:43 +00:00
Florian Rival 5add209ccf Improve naming in EventsContextAnalyzer 2019-04-13 10:09:43 +02:00
Florian Rival b313b12004 Improve group support in EventsFunctionExtractor
Only expand groups into objects if the events are referencing one of these objects.
2019-04-13 10:09:43 +02:00
Florian Rival 37a3cf96b4 Add support for groups with behaviors in EventsFunctionExtractor 2019-04-13 10:09:43 +02:00
Florian Rival 42cbe3534f Add support for behaviors in EventsFunctionExtractor 2019-04-13 10:09:43 +02:00
Florian Rival 9c6c8564fa Fix handling of object parameters in expressions 2019-01-28 23:16:20 +00:00
Florian Rival 7a87fd9924 Add support for unary operator in ExpressionParser2 2019-01-28 23:16:19 +00:00
Florian Rival dfe4a75fbd Use ExpressionParser2 for EventsContextAnalyzer 2019-01-28 23:16:19 +00:00
Florian Rival 0ec6ebad07 Add ExpressionParser2 and tests 2019-01-28 23:16:18 +00:00
Florian Rival dc27d5f962 Rename gd::ClassWithObjects to gd::ObjectsContainer 2018-09-09 21:28:26 +01:00
Florian Rival 326ec9cac0 Abstract gd::Project/gd::Layout out of code generation 2018-09-09 16:21:35 +01:00
Florian Rival 4ce2ba08ef Add EventsContextAnalyzer and EventsContextAnalyzerDialog to use it in newIDE 2018-06-25 21:15:12 +01:00