Commit Graph

20 Commits

Author SHA1 Message Date
Clément Pasteau 920d0b86c1 Fix default variable string value being empty instead of 0 (#8473)
* Before, this was set as 0 even though displaying as empty in the
variablesList.
* Projects created before 5.6.267 will keep the same behavior (0 as default value for string variables) with an option to move to the new behavior (empty as default value) in the project properties dialog.
* Projects created from 5.6.267 will use the new default behavior (empty as default value)



https://github.com/user-attachments/assets/0d885c70-b68a-431f-8dcb-08e4e193b8a1
2026-04-27 09:37:45 +02:00
D8H 7d73f58bc4 Fix a crash when renaming a child variable (#6839) 2024-08-01 16:13:51 +02:00
D8H b7a5122b07 Add a variable editor for object groups (#6781) 2024-07-25 17:21:05 +02:00
D8H 1917d5aedd Rename child-variable occurencies in events (#6602) 2024-06-03 13:26:18 +02:00
D8H 75bfa5cb45 Unify variable instructions and handle local variables (#6459)
- Global or scene variables can be used with a unique action and condition.
- Object variables can be used with a unique action and condition.
- Variables need to be declared following the same logic as the new expression syntax.
- Local variable can be declared on events
- Extensions have their own variables
- Show a diagnostic report when a preview is launched and there are missing scene variables, object variables or behaviors.
  - This is especially useful if external events are shared between several scenes.
2024-05-20 23:14:07 +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
AlexandreS 3356400026 Redesign of the variables editor
* Each row should be easier to read in a glance
* You can now collapse collection variables for a better readability
* Reorder and move of variables is now available with drag n drop
* You can now undo and redo changes
* Paste one or more variables at any level of depth you want
* Search in the names and values of each variables with a filter effect
2022-05-18 15:18:54 +02:00
Arthur Pacaud d5039b5b51 Prevent variable value to be set to an invalid number ("NaN" ) in the variables editor 2021-08-17 12:19:08 +02:00
Arthur Pacaud afa9b2a2ae Fix invalid values ("NaN") being potentially stored in variables and corrupting the project files (#2568) 2021-04-20 16:47:20 +01:00
Arthur Pacaud 4ec14ed498 Add Array and Boolean variables (#2137)
* In the list of variables (of the scene, of an object or global variables), you can now specify the type of the variable: number, text, boolean, array or structure.
* Boolean variables can be "true" or "false. They can have their values checked with conditions, and updated with actions. They are a good way to store information about if something is enabled or not (is an item equipped, is something selected, etc...).
* Array variables can contain multiple values, indexed by a number. New values, including any kind of variables, can be appended to an array during the game. Arrays can also have a value removed, and using the event "For each child variable", you can run conditions and actions for each value that is present in the array.
* Boolean and arrays are also supported when you transform a variable from or to the JSON format - which is ideal to send web requests, read configuration files or store any kind of arbitrary data.
* Finally, note that array values can themselves be arrays, structures or any variable. This can be useful to construct advanced logic. You can also access arrays (as well as any variable) from JavaScript code block events.
2021-03-07 21:53:12 +00:00
Florian Rival c57e172299 Fix crash when removing all the child variables of a structure variable
Fix #1789
2020-06-04 19:56:11 +02:00
Quarkstar bfef000cc6 Change a structure back to a number/string when its last child is removed (#1677) 2020-04-20 18:09:59 +02:00
Florian Rival a8559bfbbc Add clang-format to format (C++) source files automatically (#491)
* Update all CMakeLists of extensions to use clang-format
* Run clang-format on all Extensions
* Update GDCore CMakeLists.txt to add clang-format
* Run clang-format on GDCore files
* Update GDJS and GDCpp CMakeLists.txt to add clang-format
* Run clang-format on GDCpp and GDJS files
2018-05-09 15:57:38 -07:00
Florian Rival 443c49f83e Fix regression due to broken Variable and VariablesContainer copy ctor and assignement operator 2018-04-04 15:10:08 +02:00
Florian Rival e70021d0dd Refactor Variable/VariablesContainer and add copy/paste/delete to VariablesList in newIDE 2018-04-01 23:42:52 +02:00
Florian Rival 10833aa45d [WIP] Add copy/paste/delete in VariablesList in newIDE 2018-04-01 19:44:22 +02:00
Lizard-13 6223fbb792 Add JSON conversion for all variable types and clear structure action (#391) 2017-09-30 19:18:56 +02:00
Florian Rival cc127ff5ba [WIP] Add VariablesList editor to newIDE to edit instances variables 2017-03-13 22:22:19 +01:00
Florian Rival e444e80493 Update copyrights year 2016-01-14 19:46:56 +01:00
Florian Rival 63cb853d72 Change file organization (Events, Extensions + more folders) 2015-11-01 11:26:40 +01:00