GDevelop-extensions
GDevelop-extensions copied to clipboard
New extension: Javascript Events
Description
Adds conditions, actions and expressions to compare the return value of or run a javascript code.
How to use the extension
Adds conditions, actions and expressions to compare the return value of or run a javascript code.
How to use:
- Use the condition "Javascript code number" to compare the evaluated number out of a javascript code.
- Use the condition "Javascript code string" to compare the evaluated string out of a javascript code.
- Use the condition "Javascript code boolean" to compare the evaluated boolean value out of a javascript code.
- Use the action "Run javascript code" to run a javascript code.
- Use the expression
Number
to return a number out of a javascript code. - Use the expression
String
to return a string out of a javascript code.
How to evaluate the return value (of conditions and expressions):
"eventsFunctionContext.returnValue = Your return value here;"
By default, the return value is 0 or false.
Tip: use single quotes if you need to type a string:
"eventsFunctionContext.returnValue = 'myStringReturnValue'"
Checklist
- [X] I've followed all of the best practices.
- [X] I confirm that this extension can be integrated to this GitHub repository, distributed and MIT licensed.
- [X] I am aware that the extension may be updated by anyone, and do not need my explicit consent to do so.
What tier of review do you aim for your extension?
Community (Unreviewed)
Example file
Extension file
!update JavascriptEvents.json.zip
Can't update the extension, as it doesn't pass automatic tests:
❌ 1 Error found in extension 'JavascriptEvents':
⟶ ❌ [JavaScript disallowed properties]: Found disallowed properties in extension 'JavascriptEvents':
{
allowedProperties: [
'getVariables',
'getLayer',
'getGame',
'getBackgroundColor',
'getName',
'createObject',
'createObjectsFrom',
'setBackgroundColor',
'sceneJustResumed',
'requestChange',
'hasLayer',
'enableDebugDraw'
],
disallowedProperty: 'getTimeManager',
objectName: 'runtimeScene'
}
❌ 1 Error found in extensions - please fix it before generating the registry.
Can't update the extension, as it doesn't pass automatic tests:
❌ 1 Error found in extension 'JavascriptEvents': ⟶ ❌ [JavaScript disallowed properties]: Found disallowed properties in extension 'JavascriptEvents': { allowedProperties: [ 'getVariables', 'getLayer', 'getGame', 'getBackgroundColor', 'getName', 'createObject', 'createObjectsFrom', 'setBackgroundColor', 'sceneJustResumed', 'requestChange', 'hasLayer', 'enableDebugDraw' ], disallowedProperty: 'getTimeManager', objectName: 'runtimeScene' } ❌ 1 Error found in extensions - please fix it before generating the registry.
Actually, the disallowedProperty is at the extension description, no event is using it. (Other than the example file)
In some hours I will apply a final update improving the description of the extension :)
✅ Successfully updated the extension.
Thank you for submitting an extension.
What is the purpose of this extension?
Thank you for submitting an extension.
What is the purpose of this extension?
Allow the user to quickly write javascript code between 2 specific conditions, or actions, something that normally take many unnecessary sub-events to accomplish.
It also allows you to write javascript "expressions" to return a number or a string. (This is meant to be used as a replacement to writting a entire expression for a code that you will use only one or two times in the entire project.)