- [Node Action] Add expression support.

+ Follow path action now comes with expression for automating path progress.
This commit is contained in:
MakhamDev 2023-10-16 15:09:17 +07:00
parent d07cb1ce70
commit 468ebbd5f3
8 changed files with 23 additions and 5522 deletions

View file

@ -256,7 +256,6 @@
"IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","ConfigValues":{"Itch":{"CopyToMask":"0",},},"CopyToMask":-1,"filePath":"datafiles",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Actions.zip","CopyToMask":-1,"filePath":"datafiles/data",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"icons.ai","CopyToMask":-1,"filePath":"datafiles/data/Actions",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Armature Build.json","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Armature Build.png","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Follow Path.json","CopyToMask":-1,"filePath":"datafiles/data/Actions/Nodes",},

Binary file not shown.

View file

@ -5,7 +5,7 @@
"location": ["Transform", "Transformations"],
"sprPath": "./Follow Path.png",
"nodes": [
{ "node": "Node_Path", "y": 64 },
{ "node": "Node_Path", "y": 64, "setValues": [ { "index": 0, "expression": "Project.progress" } ] },
{ "node": "Node_Transform", "setValues": [ { "index": 2, "unit": "constant" } ] }
],
"connections": [

File diff suppressed because one or more lines are too long

View file

@ -8,6 +8,9 @@
if(!directory_exists(root))
directory_create(root);
zip_unzip("data/Actions.zip", DIRECTORY);
return;
var _l = root + "/version";
if(file_exists(_l)) {
var res = json_load_struct(_l);

View file

@ -16,11 +16,11 @@
outputNode = noone;
location = noone;
static getName = function() { return name; }
static getTooltip = function() { return tooltip; }
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) {
static build = function(_x = 0, _y = 0, _group = PANEL_GRAPH.getCurrentContext(), _param = {}) { #region
var _n = [];
for( var i = 0, n = array_length(nodes); i < n; i++ ) {
var __n = nodes[i];
@ -39,6 +39,8 @@
_index.setValue(_setVal.value);
if(struct_has(_setVal, "unit"))
_index.unit.setMode(_setVal.unit);
if(struct_has(_setVal, "expression"))
_index.setExpression(_setVal.expression);
}
}
}
@ -50,14 +52,14 @@
}
return _n;
}
} #endregion
static serialize = function() {
static serialize = function() { #region
var map = { name, tooltip, nodes, connections, tags };
return map;
}
} #endregion
static deserialize = function(path) {
static deserialize = function(path) { #region
var map = json_load_struct(path);
name = struct_try_get(map, "name", "");
@ -81,11 +83,11 @@
}
return self;
}
} #endregion
}
function __initNodeActions(list) {
var root = DIRECTORY + "Actions";
var root = $"{DIRECTORY}Actions";
if(!directory_exists(root)) directory_create(root);
root += "/Nodes";

View file

@ -34,7 +34,7 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct
static getLength = function(ind = 0) {
var _path = getInputData(0);
var _fre = getInputData(1);
var _fre = getInputData(1); _fre = max(1, abs(_fre));
var _amo = getInputData(2);
var _len = struct_has(_path, "getLength")? _path.getLength(ind) : 0;
@ -45,7 +45,7 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct
static getAccuLength = function(ind = 0) {
var _path = getInputData(0);
var _fre = getInputData(1);
var _fre = getInputData(1); _fre = max(1, abs(_fre));
var _amo = getInputData(2);
var _len = struct_has(_path, "getAccuLength")? _path.getAccuLength(ind) : [];
@ -59,7 +59,7 @@ function Node_Path_Wave(_x, _y, _group = noone) : Node(_x, _y, _group) construct
static getPointRatio = function(_rat, ind = 0) {
var _path = getInputData(0);
var _fre = getInputData(1);
var _fre = getInputData(1); _fre = max(0.01, abs(_fre));
var _amo = getInputData(2);
var _shf = getInputData(3);
var _smt = getInputData(4);

View file

@ -1206,6 +1206,12 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
return true;
} #endregion
static setExpression = function(_expression) { #region
expUse = true;
expression = _expression;
expressionUpdate();
} #endregion
static expressionUpdate = function() { #region
expTree = evaluateFunctionList(expression);
resetCache();