Modulo works . I did 10 % 3 and got 1. 99 % 13 and got 8. Math checks out. Also you can use conditionals by using Ternary-If expressions. Like so: "Hello" if my_bool else "Goodbye" You can even use a conditional like this: ["Goodbye", "Hello"][int(my_bool)] But that creates an array and evaluates all the elements so you should probably use it responsibly.
I don't understand where one would use this practically, in a real project. The only thing I can think of is mods, but at that point might as well allow full GDScript to make it easier for modders.
Even if it weren't for security reasons, I would avoid programming with it. It looks like a very fast way to write code that is very hard to read and maintain. This kind of idea has come up in other languages and even in styles ( CSS 3 ). It was never a good idea. Another similar case showed up in Java: the code was stored and later read in without any validation. This was a nightmare. Remember: On Windows, your game has admin rights most of the time!
This is pretty neat, but I don't see much value in doing this, particularly with all of its contrivances, than just writing the code in the script that you're already having to build to interpret the expression. That being said, while I can't think of anything at this time I could see it potentially being made use of in a modular skill system where effects could be determined based on properties. Like say, skill gems from Path of Exile might benefit from this. But I'd still rather build a system that didn't use these expressions because they don't seem easy to maintain or bugfix, even compared to other modular systems. I do like seeing your videos on these little overlooked topics though. I actually was wondering about this when you went over it in the exports video so I'm glad you took the time to make this video. You wouldn't happen to have any 'advanced' examples of what this could be used for? Since I know that you try to keep your videos relatively simple so that they're more accessible.
Yeah for sure! And I wouldn't recommend using this in most integral game systems, since it's obviously more difficult to work with than simply creating a script. A good place to used expressions though, is when creating development console tools (allowing you to quickly execute functions while playtesting your game). Personally I usually use PankuConsole, but it's still nice to know that expressions are an option if you're looking to create a more custom (or your own) version :) Lastly, I will say that I'm currently playing around with using expressions for a type of item effect in my current project. Depending on the scale of things, it could be extremely useful, but I'll continue weighing the pros and cons during development
Isn't it a dangerous thing to have? Especially if your plan to get custom expressions outside the executable, anyone could easily inject malicious code and this will be executed within a game.
Well for a standard usecase (using expressions to help with development tools and internal code), I don't see this being an issue. Apart from that, technically yes. If your game allowed players to create their own expressions for the game to run, then they could inject malicious code into their own computer, or "hack" their own system. The only time I could see this being a problem in a real world settings is if: A. You created a mutliplayer game that would allow players to send code snippets (expressions) to eachother for execution. (this would essentially be a "let's hack eachother" game though, and is kind of a silly idea. B. You utilized the Steam workshop system (or similar) to send files to others users that would run in-game. This is a really bad place to use expressions though, so it's recommended to just use more static data for things like this. C. The player downloaded a sketchy file or save from another user. (This would be an issue on the users end, since it's always bad practice to download sketchy files from the web, and anything could infect your computer; not just a GDScript snippet). So basically, no this isn't anything to be concerned about. And realistically, you're just going to be using expressions for development consoles or internal tools, so the player won't even be able to interact with those features in the first place :)
@@AgriasOaks99 Yes, if we 'strip' the expression Queble did, it's basically asking "if error == 0:" where error is an int ranges between 0 to 48 as per the enum. lots of functions in Godot return this error for things that have high likelihood to not complete as the user expects but aren't worth 'proper' erroring out for one reason or another
Why would you waste time with this, when you can write your "expression" directly in the _ready function using the print function? print("expression 4 plus 2 is %d" % [4 + 2]) There you have a formatted number of 6. So expressions are neglected because it's unknown, or useless. The print statement can do a lot, and it's easier to use.
The print statement is just used here for the example. A real world scenario that would benefit from using expressions, would be to create a developer console that would allow you to execute functions in game while play testing. Expressions could do this easily, whereas the print function is completely useless in this scenario. I typically use print in tutorials to make it easier for people to see what's going on :)
Modulo works . I did 10 % 3 and got 1. 99 % 13 and got 8. Math checks out.
Also you can use conditionals by using Ternary-If expressions. Like so:
"Hello" if my_bool else "Goodbye"
You can even use a conditional like this:
["Goodbye", "Hello"][int(my_bool)]
But that creates an array and evaluates all the elements so you should probably use it responsibly.
An interesting feature.
Only missing real use cases where it comes handy.
I hope gdscript has a feature to encrypt these expressions to avoid malicious injection of malwares.
I don't understand where one would use this practically, in a real project. The only thing I can think of is mods, but at that point might as well allow full GDScript to make it easier for modders.
Even if it weren't for security reasons, I would avoid programming with it. It looks like a very fast way to write code that is very hard to read and maintain.
This kind of idea has come up in other languages and even in styles ( CSS 3 ). It was never a good idea. Another similar case showed up in Java: the code was stored and later read in without any validation. This was a nightmare.
Remember: On Windows, your game has admin rights most of the time!
This is pretty neat, but I don't see much value in doing this, particularly with all of its contrivances, than just writing the code in the script that you're already having to build to interpret the expression. That being said, while I can't think of anything at this time I could see it potentially being made use of in a modular skill system where effects could be determined based on properties. Like say, skill gems from Path of Exile might benefit from this. But I'd still rather build a system that didn't use these expressions because they don't seem easy to maintain or bugfix, even compared to other modular systems.
I do like seeing your videos on these little overlooked topics though. I actually was wondering about this when you went over it in the exports video so I'm glad you took the time to make this video. You wouldn't happen to have any 'advanced' examples of what this could be used for? Since I know that you try to keep your videos relatively simple so that they're more accessible.
Yeah for sure!
And I wouldn't recommend using this in most integral game systems, since it's obviously more difficult to work with than simply creating a script.
A good place to used expressions though, is when creating development console tools (allowing you to quickly execute functions while playtesting your game).
Personally I usually use PankuConsole, but it's still nice to know that expressions are an option if you're looking to create a more custom (or your own) version :)
Lastly, I will say that I'm currently playing around with using expressions for a type of item effect in my current project.
Depending on the scale of things, it could be extremely useful, but I'll continue weighing the pros and cons during development
Isn't it a dangerous thing to have? Especially if your plan to get custom expressions outside the executable, anyone could easily inject malicious code and this will be executed within a game.
Well for a standard usecase (using expressions to help with development tools and internal code), I don't see this being an issue.
Apart from that, technically yes.
If your game allowed players to create their own expressions for the game to run, then they could inject malicious code into their own computer, or "hack" their own system.
The only time I could see this being a problem in a real world settings is if:
A. You created a mutliplayer game that would allow players to send code snippets (expressions) to eachother for execution. (this would essentially be a "let's hack eachother" game though, and is kind of a silly idea.
B. You utilized the Steam workshop system (or similar) to send files to others users that would run in-game. This is a really bad place to use expressions though, so it's recommended to just use more static data for things like this.
C. The player downloaded a sketchy file or save from another user. (This would be an issue on the users end, since it's always bad practice to download sketchy files from the web, and anything could infect your computer; not just a GDScript snippet).
So basically, no this isn't anything to be concerned about.
And realistically, you're just going to be using expressions for development consoles or internal tools, so the player won't even be able to interact with those features in the first place :)
here for i thing: hi, nice to meet you, first youtuber who has ever replied to me, thanks. 🤝
Hmm...
if expression != OK:?
OK is part of the Error enum defined in GlobalScope if that's your question
@Adam-mb3jp Thank you. Is it similar like writing : if X == true:?
@@AgriasOaks99 Yes, if we 'strip' the expression Queble did, it's basically asking "if error == 0:" where error is an int ranges between 0 to 48 as per the enum. lots of functions in Godot return this error for things that have high likelihood to not complete as the user expects but aren't worth 'proper' erroring out for one reason or another
@Adam-mb3jp Thank you for clarifying it for me 😊
Why would you waste time with this, when you can write your "expression" directly in the _ready function using the print function?
print("expression 4 plus 2 is %d" % [4 + 2])
There you have a formatted number of 6. So expressions are neglected because it's unknown, or useless. The print statement can do a lot, and it's easier to use.
The print statement is just used here for the example.
A real world scenario that would benefit from using expressions, would be to create a developer console that would allow you to execute functions in game while play testing.
Expressions could do this easily, whereas the print function is completely useless in this scenario.
I typically use print in tutorials to make it easier for people to see what's going on :)