GDevelop-extensions icon indicating copy to clipboard operation
GDevelop-extensions copied to clipboard

New extension: Javascript Events

Open github-actions[bot] opened this issue 1 year ago • 8 comments

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

JavascriptEventsExample.zip

Extension file

JavascriptEvents.json.zip

github-actions[bot] avatar Nov 12 '23 22:11 github-actions[bot]

!update JavascriptEvents.json.zip

RebornOfc avatar Nov 13 '23 03:11 RebornOfc

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.

github-actions[bot] avatar Nov 13 '23 03:11 github-actions[bot]

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)

RebornOfc avatar Nov 13 '23 03:11 RebornOfc

In some hours I will apply a final update improving the description of the extension :)

RebornOfc avatar Nov 13 '23 06:11 RebornOfc

✅ Successfully updated the extension.

github-actions[bot] avatar Nov 13 '23 17:11 github-actions[bot]

Thank you for submitting an extension.

What is the purpose of this extension?

D8H avatar Nov 22 '23 19:11 D8H

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.)

RebornOfc avatar Nov 27 '23 19:11 RebornOfc