diff --git a/extensions/community/GetBatteryPercentage.json b/extensions/community/GetBatteryPercentage.json new file mode 100644 index 000000000..2467ebaae --- /dev/null +++ b/extensions/community/GetBatteryPercentage.json @@ -0,0 +1,78 @@ +{ + "author": "", + "category": "Advanced", + "extensionNamespace": "", + "fullName": "GetBatteryPercentage", + "gdevelopVersion": "", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWJhdHRlcnktY2hhcmdpbmctNTAiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMjMsMTFIMjBWNEwxNSwxNEgxOFYyMk0xMiwxM0g0VjZIMTJNMTIuNjcsNEgxMVYySDVWNEgzLjMzQTEuMzMsMS4zMyAwIDAsMCAyLDUuMzNWMjAuNjdDMiwyMS40IDIuNiwyMiAzLjMzLDIySDEyLjY3QzEzLjQsMjIgMTQsMjEuNCAxNCwyMC42N1Y1LjMzQTEuMzMsMS4zMyAwIDAsMCAxMi42Nyw0WiIgLz48L3N2Zz4=", + "name": "GetBatteryPercentage", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/df8501561dc26e6084f300eb8c8e25c4528427199872cd875c912dae72c5ede4_battery-charging-50.svg", + "shortDescription": "Gets The Current Battery Percentage..", + "version": "1.0.0", + "description": "Update 1.0.0 Released.", + "tags": [ + "Battery" + ], + "authorIds": [ + "mu1pKMrGmTTX98LMxHYJ62GzFyJ2" + ], + "dependencies": [], + "globalVariables": [], + "sceneVariables": [ + { + "name": "VariableBattery", + "type": "number", + "value": 0 + } + ], + "eventsFunctions": [ + { + "description": "Gets The Current Battery Percentage.", + "fullName": "GetBatteryPercentage", + "functionType": "Expression", + "name": "Function", + "sentence": "", + "events": [ + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [], + "actions": [ + { + "type": { + "value": "SetReturnNumber" + }, + "parameters": [ + "VariableBattery" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::JsCode", + "inlineCode": [ + "", + "navigator.getBattery().then(function(battery) {", + " runtimeScene.getVariables().get(\"VariableBattery\").setNumber(", + " Math.round(battery.level * 100)", + " );", + " });", + "", + " ", + " eventsFunctionContext.returnValue = runtimeScene.getVariables().get(\"VariableBattery\").getAsNumber();" + ], + "parameterObjects": "", + "useStrict": true, + "eventsSheetExpanded": false + } + ], + "expressionType": { + "type": "expression" + }, + "parameters": [], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} \ No newline at end of file