New parameter for instructions: "predicate" #2789
Replies: 2 comments 1 reply
-
An alternative would be creating something like the promise event as described here but the "sub events" would be passed as a callback instead of using promises (as they are not necessary, if asynchronous programming is added it would use async/await syntax) and that callback could then be used as predicate, as callback to a recurring event like the Firebase onAuthStateChange event or anything you would use a lambda function for. |
Beta Was this translation helpful? Give feedback.
-
There is surely something to explore here, but I would rather achieve asynchronous actions (and conditions) first, as they are an "obvious" missing feature (the biggest one being a "Wait X seconds" action, and actions making requests). I say obvious in the sense that this concept of asynchronous is something that any user will quickly search for, because it's already part of our natural language: "If object is there, then do something, wait for a few seconds, and do something else" (i.e: you find the idea of the condition, the action, the wait, another action). The "natural language" is an important point, because most concepts from the events in GDevelop are coming from this (you can almost read events, and you can at least understand them intuitively without a background in coding). |
Beta Was this translation helpful? Give feedback.
-
In javascript, it is common to pass a function to another function for flexibility. This allows for nice methods like
array.map
,array.sort
,array.find
,array.filter
... Those are impossible in GDevelop as of now, but a partial solution would be a "predicate" codeonly parameter. What it would do:This is only a partial solution as it would only support conditions, but I think it would be pretty clean compared to other solutions for creating "lambda functions" in events and help in a lot of cases already.
Beta Was this translation helpful? Give feedback.
All reactions