Compare commits

...

1 Commits

Author SHA1 Message Date
Clément Pasteau
1f2da5a63c Add array variable tools and rename 2023-02-07 18:46:03 +01:00
6 changed files with 434 additions and 192 deletions

View File

@@ -406,8 +406,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.MarkAsAdvanced();
obj.AddAction("ModVarObjet",
_("Value of an object variable"),
_("Change the value of an object variable."),
_("Number"),
_("Change the number value of an object variable."),
_("the variable _PARAM1_"),
_("Variables"),
"res/actions/var24.png",
@@ -419,7 +419,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
ParameterOptions::MakeNewOptions());
obj.AddAction("ModVarObjetTxt",
_("Text of an object variable"),
_("Text"),
_("Change the text of an object variable."),
_("the text of variable _PARAM1_"),
_("Variables"),
@@ -432,7 +432,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
ParameterOptions::MakeNewOptions());
obj.AddAction("SetObjectVariableAsBoolean",
_("Boolean value of an object variable"),
_("Boolean"),
_("Change the boolean value of an object variable."),
_("Set the boolean value of variable _PARAM1_ of "
"_PARAM0_ to _PARAM2_"),
@@ -446,7 +446,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
obj.AddAction(
"ToggleObjectVariableAsBoolean",
_("Toggle the boolean value of an object variable"),
_("Toggle boolean"),
_("Toggles the boolean value of an object variable.") + "\n" +
_("If it was true, it will become false, and if it was false "
"it will become true."),
@@ -461,9 +461,10 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
obj.AddCondition("ObjectVariableChildExists",
_("Child existence"),
_("Check if the specified child of the variable exists."),
_("Check if the specified child of the object "
"structure variable exists."),
_("Child _PARAM2_ of variable _PARAM1_ of _PARAM0_ exists"),
_("Variables/Collections/Structures"),
_("Variables/Collections"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
@@ -473,7 +474,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
obj.AddAction("ObjectVariableRemoveChild",
_("Remove a child"),
_("Remove a child from an object variable."),
_("Remove a child from an object structure variable."),
_("Remove child _PARAM2_ from variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Structures"),
"res/actions/var24.png",
@@ -484,8 +485,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.MarkAsAdvanced();
obj.AddAction("ObjectVariableClearChildren",
_("Clear variable"),
_("Remove all the children from the object variable."),
_("Clear"),
_("Remove all the children from the object array or structure "
"variable."),
_("Clear children from variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections"),
"res/actions/var24.png",
@@ -619,8 +621,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.MarkAsAdvanced();
obj.AddCondition("VarObjet",
_("Value of an object variable"),
_("Compare the value of an object variable."),
_("Number"),
_("Compare the number value of an object variable."),
_("the variable _PARAM1_"),
_("Variables"),
"res/conditions/var24.png",
@@ -632,7 +634,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"number", ParameterOptions::MakeNewOptions());
obj.AddCondition("VarObjetTxt",
_("Text of an object variable"),
_("Text"),
_("Compare the text of an object variable."),
_("the text of variable _PARAM1_"),
_("Variables"),
@@ -645,7 +647,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"string", ParameterOptions::MakeNewOptions());
obj.AddCondition("ObjectVariableAsBoolean",
_("Boolean value of an object variable"),
_("Boolean"),
_("Compare the boolean value of an object variable."),
_("The boolean value of variable _PARAM1_ of object "
"_PARAM0_ is _PARAM2_"),
@@ -658,75 +660,74 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.SetDefaultValue("true");
obj.AddCondition("VarObjetDef",
"Variable defined",
"Check if the variable is defined.",
"Variable _PARAM1 of _PARAM0_ is defined",
_("Variable defined"),
_("Check if the object variable is defined."),
_("Variable _PARAM1 of _PARAM0_ is defined"),
_("Variables"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("string", _("Variable"))
.SetHidden();
.SetHidden(); // Deprecated.
obj.AddAction(
"ObjectVariablePush",
_("Append variable to an object array"),
_("Appends a variable to the end of an object array variable."),
_("Append variable _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Add existing variable"),
_("Adds an existing variable to the end of an object array variable."),
_("Add variable _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("scenevar", _("Scene variable with the content to append"))
.SetParameterLongDescription(
_("The content of the variable will *be copied* and appended at the "
"end of the array."))
.AddParameter("scenevar", _("Scene variable with the content to add"))
.SetParameterLongDescription(_("The content of the object variable will "
"*be copied* and added at the "
"end of the array."))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariablePushString",
_("Append a string to an object array"),
_("Appends a string to the end of an object array variable."),
_("Append string _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Add text"),
_("Adds a text (string) to the end of an object array variable."),
_("Add text _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("string", _("String to append"))
.AddParameter("string", _("Text to add"))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariablePushNumber",
_("Append a number to an object array"),
_("Appends a number to the end of an object array variable."),
_("Append number _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
obj.AddAction("ObjectVariablePushNumber",
_("Add number"),
_("Adds a number to the end of an object array variable."),
_("Add number _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("expression", _("Number to append"))
.AddParameter("expression", _("Number to add"))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariablePushBool",
_("Append a boolean to an object array"),
_("Appends a boolean to the end of an object array variable."),
_("Append boolean _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Add boolean"),
_("Adds a boolean to the end of an object array variable."),
_("Add boolean _PARAM2_ to array variable _PARAM1_ of _PARAM0_"),
_("Variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Array variable"))
.AddParameter("trueorfalse", _("Boolean to append"))
.AddParameter("trueorfalse", _("Boolean to add"))
.MarkAsAdvanced();
obj.AddAction(
"ObjectVariableRemoveAt",
_("Remove variable from an object array (by index)"),
_("Remove variable by index"),
_("Removes a variable at the specified index of an object array "
"variable."),
_("Remove variable at index _PARAM2_ from array variable _PARAM1_ of "
@@ -739,6 +740,48 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.AddParameter("expression", _("Index to remove"))
.MarkAsAdvanced();
obj.AddCondition("ObjectVariableSize",
_("Size"),
_("Compare the size of an object array variable."),
_("The size of the array variable _PARAM1_"),
_("Variables/Collections/Arrays"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
obj.AddExpression(
"ArrayVariableFirst",
_("First value"),
_("Get the value of the first element of an object array variable."),
_("Variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddExpression(
"ArrayVariableLast",
_("Last value"),
_("Get the value of the last element of an object array variable."),
_("Variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddExpression("ArrayVariableAt",
_("Value at index"),
_("Get the value of the element at a given index of an "
"object array variable. Remember that an array starts "
"at index 0 and ends at index size-1."),
_("Variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"))
.AddParameter("expression", _("Index of the element"));
obj.AddCondition("BehaviorActivated",
_("Behavior activated"),
_("Check if the behavior is activated for the object."),
@@ -1115,23 +1158,23 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
.AddParameter("expression", _("Target Y position"));
obj.AddExpression("Variable",
_("Value of an object variable"),
_("Value of an object variable"),
_("Number"),
_("Number value of an object variable"),
_("Variables"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddExpression("VariableChildCount",
_("Number of children of an object variable"),
_("Number of children of an object variable"),
_("Variables"),
_("Size"),
_("Size of an object array or structure variable"),
_("Variables/Collections"),
"res/actions/var.png")
.AddParameter("object", _("Object"))
.AddParameter("objectvar", _("Variable"));
obj.AddStrExpression("VariableString",
_("Text of an object variable"),
_("Text"),
_("Text of an object variable"),
_("Variables"),
"res/actions/var.png")
@@ -1293,7 +1336,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsBaseObjectExtension(
"res/actions/create24.png",
"res/actions/create24.png")
.AddCodeOnlyParameter("objectsContext", "")
.AddParameter("objectListOrEmptyIfJustDeclared", _("Group of potential objects"))
.AddParameter("objectListOrEmptyIfJustDeclared",
_("Group of potential objects"))
.SetParameterLongDescription(
_("Group containing objects that can be created by the action."))
.AddParameter("string", _("Name of the object to create"))

View File

@@ -27,9 +27,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition("VarScene",
_("Value of a scene variable"),
_("Compare the value of a scene variable."),
_("the scene variable _PARAM0_"),
_("Number"),
_("Compare the number value of a scene variable."),
_("The number of scene variable _PARAM0_"),
_("Scene variables"),
"res/conditions/var24.png",
"res/conditions/var.png")
@@ -39,9 +39,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition("VarSceneTxt",
_("Text of a scene variable"),
_("Text"),
_("Compare the text of a scene variable."),
_("the text of scene variable _PARAM0_"),
_("The text of scene variable _PARAM0_"),
_("Scene variables"),
"res/conditions/var24.png",
"res/conditions/var.png")
@@ -52,7 +52,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition(
"SceneVariableAsBoolean",
_("Boolean value of a scene variable"),
_("Boolean"),
_("Compare the boolean value of a scene variable."),
_("The boolean value of scene variable _PARAM0_ is _PARAM1_"),
_("Scene variables"),
@@ -63,14 +63,14 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
.SetDefaultValue("true");
extension
.AddCondition(
"VariableChildExists",
_("Child existence"),
_("Check if the specified child of the scene variable exists."),
_("Child _PARAM1_ of scene variable _PARAM0_ exists"),
_("Scene variables/Collections/Structures"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddCondition("VariableChildExists",
_("Child existence"),
_("Check if the specified child of the scene structure "
"variable exists."),
_("Child _PARAM1_ of scene variable _PARAM0_ exists"),
_("Scene variables/Collections/Structures"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("scenevar", _("Variable"))
.AddParameter("string", _("Name of the child"))
.MarkAsAdvanced();
@@ -78,7 +78,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition("GlobalVariableChildExists",
_("Child existence"),
_("Check if the specified child of the global "
_("Check if the specified child of the global structure "
"variable exists."),
_("Child _PARAM1_ of global variable _PARAM0_ exists"),
_("Global variables/Collections/Structures"),
@@ -90,7 +90,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition("VarSceneDef",
"Test if a scene variable is defined",
"Variable defined",
"Test if the scene variable exists.",
"Scene variable _PARAM0_ is defined",
_("Scene variables"),
@@ -98,12 +98,12 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
"res/conditions/var.png")
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Variable"))
.SetHidden();
.SetHidden(); // Deprecated.
extension
.AddCondition("VarGlobal",
_("Value of a global variable"),
_("Compare the value of a global variable."),
_("Number"),
_("Compare the number value of a global variable."),
_("the global variable _PARAM0_"),
_("Global variables"),
"res/conditions/var24.png",
@@ -115,7 +115,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition("VarGlobalTxt",
_("Text of a global variable"),
_("Text"),
_("Compare the text of a global variable."),
_("the text of the global variable _PARAM0_"),
_("Global variables"),
@@ -129,7 +129,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition(
"GlobalVariableAsBoolean",
_("Boolean value of a global variable"),
_("Boolean"),
_("Compare the boolean value of a global variable."),
_("The boolean value of global variable _PARAM0_ is _PARAM1_"),
_("Global variables"),
@@ -141,8 +141,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddCondition("VarGlobalDef",
"Test if a global variable is defined",
"Test if a global variable exists",
"Variable defined",
"Test if a global variable exists.",
"Global variable _PARAM0_ is defined",
_("Global variables"),
"res/conditions/var24.png",
@@ -150,12 +150,12 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
.AddCodeOnlyParameter("currentScene", "")
.AddParameter("string", _("Variable"))
.MarkAsAdvanced()
.SetHidden();
.SetHidden(); // Deprecated.
extension
.AddAction("ModVarScene",
_("Value of a scene variable"),
_("Change the value of a scene variable."),
_("Change number"),
_("Modify the number value of a scene variable."),
_("the scene variable _PARAM0_"),
_("Scene variables"),
"res/actions/var24.png",
@@ -166,7 +166,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction("ModVarSceneTxt",
_("String of a scene variable"),
_("Change text"),
_("Modify the text of a scene variable."),
_("the text of scene variable _PARAM0_"),
_("Scene variables"),
@@ -179,7 +179,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction(
"SetSceneVariableAsBoolean",
_("Boolean value of a scene variable"),
_("Change boolean"),
_("Modify the boolean value of a scene variable."),
_("Set the boolean value of scene variable _PARAM0_ to _PARAM1_"),
_("Scene variables"),
@@ -190,7 +190,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction("ToggleSceneVariableAsBoolean",
_("Toggle boolean value of a scene variable"),
_("Toggle boolean"),
_("Toggle the boolean value of a scene variable.") + "\n" +
_("If it was true, it will become false, and if it was "
"false it will become true."),
@@ -202,8 +202,8 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction("ModVarGlobal",
_("Value of a global variable"),
_("Change the value of a global variable"),
_("Change number"),
_("Modify the number value of a global variable."),
_("the global variable _PARAM0_"),
_("Global variables"),
"res/actions/var24.png",
@@ -215,7 +215,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction("ModVarGlobalTxt",
_("String of a global variable"),
_("Change text"),
_("Modify the text of a global variable."),
_("the text of global variable _PARAM0_"),
_("Global variables"),
@@ -229,7 +229,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction(
"SetGlobalVariableAsBoolean",
_("Boolean value of a global variable"),
_("Change boolean"),
_("Modify the boolean value of a global variable."),
_("Set the boolean value of global variable _PARAM0_ to _PARAM1_"),
_("Global variables"),
@@ -240,7 +240,7 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction("ToggleGlobalVariableAsBoolean",
_("Toggle boolean value of a global variable"),
_("Toggle boolean"),
_("Toggle the boolean value of a global variable.") + "\n" +
_("If it was true, it will become false, and if it was "
"false it will become true."),
@@ -251,33 +251,36 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
.AddParameter("globalvar", _("Variable"));
extension
.AddAction("VariableRemoveChild",
_("Remove a child"),
_("Remove a child from a scene variable."),
_("Remove child _PARAM1_ from scene variable _PARAM0_"),
_("Scene variables/Collections/Structures"),
"res/actions/var24.png",
"res/actions/var.png")
.AddAction(
"VariableRemoveChild",
_("Remove a child"),
_("Remove a child from a scene structure variable."),
_("Remove child _PARAM1_ from scene structure variable _PARAM0_"),
_("Scene variables/Collections/Structures"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"))
.AddParameter("string", _("Child's name"))
.MarkAsAdvanced();
extension
.AddAction("GlobalVariableRemoveChild",
_("Remove a child"),
_("Remove a child from a global variable."),
_("Remove child _PARAM1_ from global variable _PARAM0_"),
_("Global variables/Collections/Structures"),
"res/actions/var24.png",
"res/actions/var.png")
.AddAction(
"GlobalVariableRemoveChild",
_("Remove a child"),
_("Remove a child from a global structure variable."),
_("Remove child _PARAM1_ from global structure variable _PARAM0_"),
_("Global variables/Collections/Structures"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"))
.AddParameter("string", _("Child's name"))
.MarkAsAdvanced();
extension
.AddAction("VariableClearChildren",
_("Clear scene variable"),
_("Remove all the children from the scene variable."),
_("Clear"),
_("Remove all the children from the scene structure or array "
"variable."),
_("Clear children from scene variable _PARAM0_"),
_("Scene variables/Collections"),
"res/actions/var24.png",
@@ -287,8 +290,9 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction("GlobalVariableClearChildren",
_("Clear global variable"),
_("Remove all the children from the global variable."),
_("Clear"),
_("Remove all the children from the global structure or array "
"variable."),
_("Clear children from global variable _PARAM0_"),
_("Global variables/Collections"),
"res/actions/var24.png",
@@ -298,155 +302,249 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddAction("SceneVariablePush",
_("Append variable to a scene array"),
_("Appends a variable at the end of a scene array variable."),
_("Append variable _PARAM1_ to array variable _PARAM0_"),
_("Add existing variable"),
_("Adds an existing variable at the end of a scene array "
"variable."),
_("Add variable _PARAM1_ to array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Array variable"))
.AddParameter("scenevar", _("Scene variable with the content to append"))
.SetParameterLongDescription(_("The content of the variable will *be copied* and appended at the end of the array."))
.MarkAsAdvanced();
extension
.AddAction("SceneVariablePushString",
_("Append a string to a scene array"),
_("Appends a string at the end of a scene array variable."),
_("Append string _PARAM1_ to array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Array variable"))
.AddParameter("string", _("String to append"))
.MarkAsAdvanced();
extension
.AddAction("SceneVariablePushNumber",
_("Append a number to a scene array"),
_("Appends a number at the end of a scene array variable."),
_("Append number _PARAM1_ to array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Array variable"))
.AddParameter("expression", _("Number to append"))
.MarkAsAdvanced();
extension
.AddAction("SceneVariablePushBool",
_("Append a boolean to a scene array"),
_("Appends a boolean at the end of a scene array variable."),
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Array variable"))
.AddParameter("trueorfalse", _("Boolean to append"))
.AddParameter("scenevar", _("Scene variable with the content to add"))
.SetParameterLongDescription(
_("The content of the variable will *be copied* and added at the "
"end of the array."))
.MarkAsAdvanced();
extension
.AddAction(
"SceneVariableRemoveAt",
_("Remove variable from a scene array (by index)"),
_("Removes a variable at the specified index of a scene array variable."),
_("Remove variable at index _PARAM1_ from scene array variable _PARAM0_"),
"SceneVariablePushString",
_("Add text"),
_("Adds a text (string) at the end of a scene array variable."),
_("Add text _PARAM1_ to array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Array variable"))
.AddParameter("string", _("Text to add"))
.MarkAsAdvanced();
extension
.AddAction("SceneVariablePushNumber",
_("Add number"),
_("Adds a number at the end of a scene array variable."),
_("Add number _PARAM1_ to array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Array variable"))
.AddParameter("expression", _("Number to add"))
.MarkAsAdvanced();
extension
.AddAction("SceneVariablePushBool",
_("Add boolean"),
_("Adds a boolean at the end of a scene array variable."),
_("Add boolean _PARAM1_ to array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Array variable"))
.AddParameter("trueorfalse", _("Boolean to add"))
.MarkAsAdvanced();
extension
.AddAction("SceneVariableRemoveAt",
_("Remove variable by index"),
_("Removes a variable at the specified index of a scene array "
"variable."),
_("Remove variable at index _PARAM1_ from scene array "
"variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"))
.AddParameter("expression", _("Index to remove"))
.MarkAsAdvanced();
extension
.AddAction("GlobalVariablePush",
_("Append variable to a global array"),
_("Appends a variable at the end of a global array variable."),
_("Append variable _PARAM1_ to array variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Array variable"))
.AddParameter("scenevar", _("Scene variable with the content to append"))
.SetParameterLongDescription(_("The content of the variable will *be copied* and appended at the end of the array."))
.AddCondition("SceneVariableSize",
_("Size"),
_("Compare the size of a scene array variable."),
_("The size of the array variable _PARAM0_"),
_("Scene variables/Collections/Arrays"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("scenevar", _("Variable"))
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
.AddExpression(
"SceneVariableFirst",
_("First value"),
_("Get the value of the first element of a scene array variable."),
_("Scene variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"));
extension
.AddExpression(
"SceneVariableLast",
_("Last value"),
_("Get the value of the last element of a scene array variable."),
_("Scene variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"));
extension
.AddExpression("SceneVariableAt",
_("Value at index"),
_("Get the value of the element at a given index of a "
"scene array variable. Remember that an array starts "
"at index 0 and ends at index size-1."),
_("Scene variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"))
.AddParameter("expression", _("Index of the element"));
extension
.AddAction(
"GlobalVariableRemoveAt",
_("Remove variable from a global array (by index)"),
_("Removes a variable at the specified index of a global array variable."),
_("Remove variable at index _PARAM1_ from global array variable _PARAM0_"),
"GlobalVariablePush",
_("Add existing variable"),
_("Adds an existing variable at the end of a global array variable."),
_("Add variable _PARAM1_ to array variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Array variable"))
.AddParameter("scenevar", _("Scene variable with the content to add"))
.SetParameterLongDescription(
_("The content of the variable will *be copied* and added at the "
"end of the array."))
.MarkAsAdvanced();
extension
.AddAction("GlobalVariableRemoveAt",
_("Remove variable by index"),
_("Removes a variable at the specified index of a global "
"array variable."),
_("Remove variable at index _PARAM1_ from global array "
"variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"))
.AddParameter("expression", _("Index to remove"))
.MarkAsAdvanced();
extension
.AddAction("GlobalVariablePushString",
_("Append a string to a global array"),
_("Appends a string at the end of a global array variable."),
_("Append string _PARAM1_ to array variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddAction(
"GlobalVariablePushString",
_("Add text"),
_("Adds a text (string) at the end of a global array variable."),
_("Add text _PARAM1_ to array variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Array variable"))
.AddParameter("string", _("String to append"))
.AddParameter("string", _("Text to add"))
.MarkAsAdvanced();
extension
.AddAction("GlobalVariablePushNumber",
_("Append a number to a global array"),
_("Appends a number at the end of a global array variable."),
_("Append number _PARAM1_ to array variable _PARAM0_"),
_("Add number"),
_("Adds a number at the end of a global array variable."),
_("Add number _PARAM1_ to array variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Array variable"))
.AddParameter("expression", _("Number to append"))
.AddParameter("expression", _("Number to add"))
.MarkAsAdvanced();
extension
.AddAction("GlobalVariablePushBool",
_("Append a boolean to a global array"),
_("Appends a boolean at the end of a global array variable."),
_("Append boolean _PARAM1_ to array variable _PARAM0_"),
_("Add boolean"),
_("Adds a boolean at the end of a global array variable."),
_("Add boolean _PARAM1_ to array variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/actions/var24.png",
"res/actions/var.png")
.AddParameter("globalvar", _("Array variable"))
.AddParameter("trueorfalse", _("Boolean to append"))
.AddParameter("trueorfalse", _("Boolean to add"))
.MarkAsAdvanced();
extension
.AddCondition("GlobalVariableSize",
_("Size"),
_("Compare the size of a global array variable."),
_("The size of the array variable _PARAM0_"),
_("Global variables/Collections/Arrays"),
"res/conditions/var24.png",
"res/conditions/var.png")
.AddParameter("globalvar", _("Variable"))
.UseStandardRelationalOperatorParameters(
"number", ParameterOptions::MakeNewOptions())
.MarkAsAdvanced();
extension
.AddExpression(
"GlobalVariableFirst",
_("First value"),
_("Get the value of the first element of a global array variable."),
_("Global variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"));
extension
.AddExpression(
"GlobalVariableLast",
_("Last value"),
_("Get the value of the last element of a global array variable."),
_("Global variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"));
extension
.AddExpression("GlobalVariableAt",
_("Value at index"),
_("Get the value of the element at a given index of a "
"global array variable. Remember that an array starts "
"at index 0 and ends at index size-1."),
_("Global variables/Collections/Arrays"),
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"))
.AddParameter("expression", _("Index of the element"));
extension
.AddExpression("GlobalVariableChildCount",
_("Number of children of a global variable"),
_("Number of children of a global variable"),
_("Global variables"),
_("Size"),
_("Size of a global array or structure variable"),
_("Global variables/Collections"),
"res/actions/var.png")
.AddParameter("globalvar", _("Variable"));
extension
.AddExpression("VariableChildCount",
_("Number of children of a scene variable"),
_("Number of children of a scene variable"),
_("Scene variables"),
_("Size"),
_("Size of a scene array or structure variable"),
_("Scene variables/Collections"),
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"));
extension
.AddExpression("Variable",
_("Value of a scene variable"),
_("Value of a scene variable"),
_("Number"),
_("Number value of a scene variable"),
_("Scene variables"),
"res/actions/var.png")
.AddParameter("scenevar", _("Variable"));
extension
.AddStrExpression("VariableString",
_("Text of a scene variable"),
_("Text"),
_("Text of a scene variable"),
_("Scene variables"),
"res/actions/var.png")
@@ -454,15 +552,15 @@ void GD_CORE_API BuiltinExtensionsImplementer::ImplementsVariablesExtension(
extension
.AddExpression("GlobalVariable",
_("Value of a global variable"),
_("Value of a global variable"),
_("Number"),
_("Number value of a global variable"),
_("Global variables"),
"res/actions/var.png")
.AddParameter("globalvar", _("Name of the global variable"));
extension
.AddStrExpression("GlobalVariableString",
_("Text of a global variable"),
_("Text"),
_("Text of a global variable"),
_("Global variables"),
"res/actions/var.png")

View File

@@ -164,7 +164,7 @@ BaseObjectExtension::BaseObjectExtension() {
objectConditions["CollisionPoint"]
.SetFunctionName("isCollidingWithPoint")
.SetIncludeFile("runtimeobject.js");
objectConditions["ObjectTimer"] // deprecated
objectConditions["ObjectTimer"] // deprecated
.SetFunctionName("timerElapsedTime")
.SetIncludeFile("runtimeobject.js");
objectConditions["CompareObjectTimer"]
@@ -247,6 +247,12 @@ BaseObjectExtension::BaseObjectExtension() {
"getXFromAngleAndDistance");
objectExpressions["YFromAngleAndDistance"].SetFunctionName(
"getYFromAngleAndDistance");
objectExpressions["ArrayVariableFirst"].SetFunctionName(
"getFirstVariableValue");
objectExpressions["ArrayVariableLast"].SetFunctionName(
"getLastVariableValue");
objectExpressions["ArrayVariableAt"].SetFunctionName(
"getVariableValueAtIndex");
GetAllActions()["Create"].SetFunctionName(
"gdjs.evtTools.object.createObjectOnScene");
@@ -254,9 +260,9 @@ BaseObjectExtension::BaseObjectExtension() {
"gdjs.evtTools.object.createObjectFromGroupOnScene");
GetAllExpressions()["Count"].SetFunctionName(
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
GetAllConditions()["NbObjet"].SetFunctionName(
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
"gdjs.evtTools.object.pickedObjectsCount"); // Deprecated
GetAllExpressions()["SceneInstancesCount"].SetFunctionName(
"gdjs.evtTools.object.getSceneInstancesCount");
@@ -335,6 +341,9 @@ BaseObjectExtension::BaseObjectExtension() {
objectActions["ObjectVariableRemoveAt"]
.SetFunctionName("variableRemoveAt")
.SetIncludeFile("runtimeobject.js");
objectConditions["ObjectVariableSize"]
.SetFunctionName("getVariableSize")
.SetIncludeFile("runtimeobject.js");
GetAllActions()["MoveObjects"].codeExtraInformation.SetCustomCodeGenerator(
[](gd::Instruction &,

View File

@@ -46,11 +46,27 @@ VariablesExtension::VariablesExtension() {
"gdjs.evtTools.variable.getVariableNumber");
GetAllStrExpressions()["GlobalVariableString"].SetFunctionName(
"gdjs.evtTools.variable.getVariableString");
GetAllExpressions()["GlobalVariableFirst"].SetFunctionName(
"gdjs.evtTools.variable.getFirstVariableValue");
GetAllExpressions()["GlobalVariableLast"].SetFunctionName(
"gdjs.evtTools.variable.getLastVariableValue");
GetAllExpressions()["GlobalVariableAt"].SetFunctionName(
"gdjs.evtTools.variable.getVariableValueAt");
GetAllExpressions()["SceneVariableFirst"].SetFunctionName(
"gdjs.evtTools.variable.getFirstVariableValue");
GetAllExpressions()["SceneVariableLast"].SetFunctionName(
"gdjs.evtTools.variable.getLastVariableValue");
GetAllExpressions()["SceneVariableAt"].SetFunctionName(
"gdjs.evtTools.variable.getVariableValueAt");
GetAllConditions()["VarSceneDef"].SetFunctionName(
"gdjs.evtTools.variable.sceneVariableExists");
GetAllConditions()["VarGlobalDef"].SetFunctionName(
"gdjs.evtTools.variable.globalVariableExists");
GetAllConditions()["SceneVariableSize"].SetFunctionName(
"gdjs.evtTools.variable.getVariableChildCount");
GetAllConditions()["GlobalVariableSize"].SetFunctionName(
"gdjs.evtTools.variable.getVariableChildCount");
GetAllActions()["SetSceneVariableAsBoolean"].SetFunctionName(
"gdjs.evtTools.variable.setVariableBoolean");

View File

@@ -170,6 +170,43 @@ namespace gdjs {
): number {
return variable.getChildrenCount();
};
/**
* Shortcut to get the first value of an array variable.
* @returns {string | number | boolean}
*/
export const getFirstVariableValue = function (
array: gdjs.Variable
): string | float | boolean {
return array.getAllChildrenArray()[0].getValue();
};
/**
* Shortcut to get the last value of an array variable.
* @returns {string | number | boolean}
*/
export const getLastVariableValue = function (
array: gdjs.Variable
): string | float | boolean {
const children = array.getAllChildrenArray();
return children.length === 0
? 0
: children[children.length - 1].getValue();
};
/**
* Shortcut to get the value of an array variable at a given index.
* @returns {string | number | boolean}
*/
export const getVariableValueAt = function (
array: gdjs.Variable,
index: number
): string | float | boolean {
if (index < 0 || index >= array.getChildrenCount()) {
return 0;
}
return array.getAllChildrenArray()[index].getValue();
};
}
export namespace common {

View File

@@ -940,6 +940,44 @@ namespace gdjs {
array.removeAtIndex(index);
};
/**
* Shortcut to return the size of an array or structure variable.
* @returns {number}
*/
getVariableSize = function (array: gdjs.Variable): number {
return array.getChildrenCount();
};
/**
* Shortcut to get the value of an array variable at a given index.
* @returns {string | number | boolean}
*/
getVariableValueAtIndex = function (array: gdjs.Variable, index: number) {
if (index < 0 || index >= array.getChildrenCount()) {
return 0;
}
return array.getAllChildrenArray()[index].getValue();
};
/**
* Shortcut to get the first value of an array variable.
* @returns {string | number | boolean}
*/
getFirstVariableValue = function (array: gdjs.Variable) {
return array.getAllChildrenArray()[0].getValue();
};
/**
* Shortcut to get the last value of an array variable.
* @returns {string | number | boolean}
*/
getLastVariableValue = function (array: gdjs.Variable) {
const children = array.getAllChildrenArray();
return children.length === 0
? 0
: children[children.length - 1].getValue();
};
/**
* Shortcut to test if a variable exists for the object.
* @param name The variable to be tested