From bb1adf1801fa8eeb100bbfbba8919a81ae5a3f77 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 12 Nov 2023 14:39:28 +0300 Subject: [PATCH] [Community][Double Key Press] (#1079) It allows the user to check if a double key press has happened over a specific period of time set by the user. Thanks to: @NiQsterVX for this extension. --- extensions/community/DoubleKeyPress.json | 805 +++++++++++++++++++++++ 1 file changed, 805 insertions(+) create mode 100644 extensions/community/DoubleKeyPress.json diff --git a/extensions/community/DoubleKeyPress.json b/extensions/community/DoubleKeyPress.json new file mode 100644 index 00000000..b7c2d1b6 --- /dev/null +++ b/extensions/community/DoubleKeyPress.json @@ -0,0 +1,805 @@ +{ + "author": "", + "category": "Input", + "extensionNamespace": "", + "fullName": "Double key press", + "helpPath": "", + "iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0ibWRpLWtleWJvYXJkLW91dGxpbmUiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNNCw1QTIsMiAwIDAsMCAyLDdWMTdBMiwyIDAgMCwwIDQsMTlIMjBBMiwyIDAgMCwwIDIyLDE3VjdBMiwyIDAgMCwwIDIwLDVINE00LDdIMjBWMTdINFY3TTUsOFYxMEg3VjhINU04LDhWMTBIMTBWOEg4TTExLDhWMTBIMTNWOEgxMU0xNCw4VjEwSDE2VjhIMTRNMTcsOFYxMEgxOVY4SDE3TTUsMTFWMTNIN1YxMUg1TTgsMTFWMTNIMTBWMTFIOE0xMSwxMVYxM0gxM1YxMUgxMU0xNCwxMVYxM0gxNlYxMUgxNE0xNywxMVYxM0gxOVYxMUgxN004LDE0VjE2SDE2VjE0SDhaIiAvPjwvc3ZnPg==", + "name": "DoubleKeyPress", + "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/a85f9403cea5bc52457e445d4a200ed226e30c3493c927aa015d0bbdf847df01_keyboard-outline.svg", + "shortDescription": "Adds conditions to check for double key presses, similar to double clicks.", + "version": "1.0.0", + "description": [ + "This simple extension enables you to add a system, where a player needs to double press a certain key for an action to happen. ", + "For example you can add a sprinting system similar to Minecraft's, where you need to press W twice to start running.", + "", + "The extension adds 3 conditions:", + "Specific key double pressed", + "Specific key double pressed (text expression)", + "Any key double pressed" + ], + "tags": [ + "double key press", + "keyboard" + ], + "authorIds": [ + "2zlLuuwKidTQKeeBwNGHOao4URg1" + ], + "dependencies": [], + "eventsFunctions": [ + { + "description": "Check if a specific key was double pressed.", + "fullName": "Key double pressed", + "functionType": "Condition", + "name": "DoubleKeyPress", + "sentence": "_PARAM1_ was double pressed", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Starts the timer, so that the whole condition even works" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "DepartScene" + }, + "parameters": [ + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Simple, yet effective double press system that is just a boolean toggle" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "KeyFromTextPressed" + }, + "parameters": [ + "\"key\"", + "GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "BuiltinCommonInstructions::Once" + }, + "parameters": [] + } + ], + "actions": [ + { + "type": { + "value": "ToggleSceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "If the boolean is true, unpauses the timer, so that the \"time window\" function will work" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]", + "True" + ] + } + ], + "actions": [ + { + "type": { + "value": "UnPauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "If the boolean is false (pressed 2 times), condition is marked as true and resets the timer, so future uses won't be broken" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]", + "False" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Resets the boolean back to its original value if the time window is exceeded" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CompareTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")", + ">=", + "GetArgumentAsNumber(\"seconds\")" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "SetSceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Which key should it work on?", + "name": "key", + "supplementaryInformation": "scene", + "type": "key" + }, + { + "description": "Time window for the double tap (in seconds)", + "name": "seconds", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Check if any key was double pressed.", + "fullName": "Key double pressed (any key)", + "functionType": "Condition", + "name": "DoubleKeyPressAny", + "sentence": "Keyboard was double pressed", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Starts the timer, so that the whole condition even works" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "DepartScene" + }, + "parameters": [ + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Simple, yet effective double press system that is just a boolean toggle" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "AnyKeyPressed" + }, + "parameters": [ + "\"key\"" + ] + }, + { + "type": { + "value": "BuiltinCommonInstructions::Once" + }, + "parameters": [] + } + ], + "actions": [ + { + "type": { + "value": "ToggleSceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress.Any" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "If the boolean is true, unpauses the timer, so that the \"time window\" function will work" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress.Any", + "True" + ] + } + ], + "actions": [ + { + "type": { + "value": "UnPauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "If the boolean is false (pressed 2 times), condition is marked as true and resets the timer, so future uses won't be broken" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress.Any", + "False" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"" + ] + }, + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Resets the boolean back to its original value if the time window is exceeded" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CompareTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"", + ">=", + "GetArgumentAsNumber(\"seconds\")" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_Any\"" + ] + }, + { + "type": { + "value": "SetSceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress.Any", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Time window for the double tap (in seconds)", + "name": "seconds", + "type": "expression" + } + ], + "objectGroups": [] + }, + { + "description": "Check if a specific key was double pressed using a text expression.", + "fullName": "Key double pressed (text expression)", + "functionType": "Condition", + "name": "DoubleKeyPressExpression", + "sentence": "_PARAM1_ was double pressed", + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Starts the timer, so that the whole condition even works" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "DepartScene" + }, + "parameters": [ + "" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Simple, yet effective double press system that is just a boolean toggle" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "KeyFromTextPressed" + }, + "parameters": [ + "\"key\"", + "GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "BuiltinCommonInstructions::Once" + }, + "parameters": [] + } + ], + "actions": [ + { + "type": { + "value": "ToggleSceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]" + ] + } + ], + "events": [ + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "If the boolean is true, unpauses the timer, so that the \"time window\" function will work" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]", + "True" + ] + } + ], + "actions": [ + { + "type": { + "value": "UnPauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "If the boolean is false (pressed 2 times), condition is marked as true and resets the timer, so future uses won't be broken" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "SceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]", + "False" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "SetReturnBoolean" + }, + "parameters": [ + "True" + ] + } + ] + } + ] + }, + { + "type": "BuiltinCommonInstructions::Comment", + "color": { + "b": 109, + "g": 230, + "r": 255, + "textB": 0, + "textG": 0, + "textR": 0 + }, + "comment": "Resets the boolean back to its original value if the time window is exceeded" + }, + { + "type": "BuiltinCommonInstructions::Standard", + "conditions": [ + { + "type": { + "value": "CompareTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")", + ">=", + "GetArgumentAsNumber(\"seconds\")" + ] + } + ], + "actions": [ + { + "type": { + "value": "ResetTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "PauseTimer" + }, + "parameters": [ + "", + "\"__DoublePress_\"+GetArgumentAsString(\"key\")" + ] + }, + { + "type": { + "value": "SetSceneVariableAsBoolean" + }, + "parameters": [ + "__DoublePress[GetArgumentAsString(\"key\")]", + "" + ] + } + ] + } + ], + "parameters": [ + { + "description": "Which key should it work on?", + "name": "key", + "type": "string" + }, + { + "description": "Time window for the double tap (in seconds)", + "name": "seconds", + "type": "expression" + } + ], + "objectGroups": [] + } + ], + "eventsBasedBehaviors": [], + "eventsBasedObjects": [] +} \ No newline at end of file