forked from ZeraGmbH/Blockly.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Dynamic; | ||
using BlocklyNet.Core.Model; | ||
using BlocklyNet.Extensions.Builder; | ||
using Newtonsoft.Json; | ||
|
||
namespace BlocklyNet.Extensions; | ||
|
||
/// <summary> | ||
/// Execute a function as a Blockly.NET group. | ||
/// </summary> | ||
[CustomBlock( | ||
"execute_group", | ||
"", | ||
@"{ | ||
""message0"": ""ExecutionGroup %1 %2 %3"", | ||
""args0"": [ | ||
{ | ||
""type"": ""input_dummy"" | ||
}, | ||
{ | ||
""type"": ""field_label_serializable"", | ||
""name"": ""RESULT"", | ||
""text"": ""Result"" | ||
}, | ||
{ | ||
""type"": ""input_value"", | ||
""name"": ""RESULT"" | ||
} | ||
], | ||
""previousStatement"": null, | ||
""nextStatement"": null, | ||
""colour"": ""#107159"", | ||
""tooltip"": ""Execute something as a group."", | ||
""helpUrl"": """" | ||
}", | ||
"" | ||
)] | ||
public class ExecutionGroup : Block | ||
{ | ||
/// <inheritdoc/> | ||
public override async Task<object?> EvaluateAsync(Context context) | ||
{ | ||
/* Register the group. */ | ||
context.Engine.BeginGroup(Id); | ||
|
||
/* Execute the function to get the group result. */ | ||
var groupResult = await Values.EvaluateAsync("RESULT", context); | ||
|
||
/* Finish the group. */ | ||
context.Engine.EndGroup(groupResult); | ||
|
||
/* Continue with execution. */ | ||
return await base.EvaluateAsync(context); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters