mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Compare commits
1 Commits
v5.2.176
...
more-array
Author | SHA1 | Date | |
---|---|---|---|
![]() |
04c4e22bc8 |
@@ -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["ObjectVariableLength"]
|
||||
.SetFunctionName("getVariableLength")
|
||||
.SetIncludeFile("runtimeobject.js");
|
||||
|
||||
GetAllActions()["MoveObjects"].codeExtraInformation.SetCustomCodeGenerator(
|
||||
[](gd::Instruction &,
|
||||
|
@@ -940,6 +940,44 @@ namespace gdjs {
|
||||
array.removeAtIndex(index);
|
||||
};
|
||||
|
||||
/**
|
||||
* Shortcut to return the size of an array or structure variable.
|
||||
* @returns {number}
|
||||
*/
|
||||
getVariableLength = 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
|
||||
|
Reference in New Issue
Block a user