Array filter

This commit is contained in:
Tanasart 2023-03-22 12:56:29 +07:00
parent a0ea9499b4
commit 03817e8aeb
13 changed files with 307 additions and 4 deletions

View file

@ -135,6 +135,7 @@
{"name":"sprites","order":12,"path":"folders/sprites.yy",},
{"name":"gameframe","order":2,"path":"folders/sprites/gameframe.yy",},
{"name":"widgets","order":5,"path":"folders/widgets.yy",},
{"name":"for filter","order":3,"path":"folders/nodes/data/iterate/for filter.yy",},
],
"ResourceOrderSettings": [
{"name":"s_node_corner","order":14,"path":"sprites/s_node_corner/s_node_corner.yy",},
@ -321,6 +322,7 @@
{"name":"s_node_vfx_override","order":11,"path":"sprites/s_node_vfx_override/s_node_vfx_override.yy",},
{"name":"rotatorRange","order":12,"path":"scripts/rotatorRange/rotatorRange.yy",},
{"name":"font_loader","order":8,"path":"scripts/font_loader/font_loader.yy",},
{"name":"node_iterator_filter_input","order":1,"path":"scripts/node_iterator_filter_input/node_iterator_filter_input.yy",},
{"name":"point_rotate","order":1,"path":"scripts/point_rotate/point_rotate.yy",},
{"name":"s_node_vfx_variable","order":10,"path":"sprites/s_node_vfx_variable/s_node_vfx_variable.yy",},
{"name":"node_displacement","order":1,"path":"scripts/node_displacement/node_displacement.yy",},
@ -454,6 +456,7 @@
{"name":"node_unicode","order":3,"path":"scripts/node_unicode/node_unicode.yy",},
{"name":"draw_set_text","order":1,"path":"scripts/draw_set_text/draw_set_text.yy",},
{"name":"s_node_warp","order":9,"path":"sprites/s_node_warp/s_node_warp.yy",},
{"name":"node_iterator_filter_output","order":2,"path":"scripts/node_iterator_filter_output/node_iterator_filter_output.yy",},
{"name":"color_function","order":9,"path":"scripts/color_function/color_function.yy",},
{"name":"fd_rectangle_set_pressure_size","order":11,"path":"scripts/fd_rectangle_set_pressure_size/fd_rectangle_set_pressure_size.yy",},
{"name":"node_color_data","order":6,"path":"scripts/node_color_data/node_color_data.yy",},
@ -613,6 +616,7 @@
{"name":"node_rigid_object","order":1,"path":"scripts/node_rigid_object/node_rigid_object.yy",},
{"name":"areaBox","order":1,"path":"scripts/areaBox/areaBox.yy",},
{"name":"__global_object_depths","order":7,"path":"scripts/__global_object_depths/__global_object_depths.yy",},
{"name":"s_node_filter_array","order":28,"path":"sprites/s_node_filter_array/s_node_filter_array.yy",},
{"name":"node_noise_grid_hex","order":24,"path":"scripts/node_noise_grid_hex/node_noise_grid_hex.yy",},
{"name":"node_lua_global","order":1,"path":"scripts/node_lua_global/node_lua_global.yy",},
{"name":"o_dialog_preset","order":1,"path":"objects/o_dialog_preset/o_dialog_preset.yy",},

View file

@ -7,7 +7,6 @@
],
"configs": {
"children": [
{"children":[],"name":"Tester",},
{"children":[
{"children":[],"name":"Alpha",},
],"name":"Demo",},
@ -167,6 +166,7 @@
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"Steamworks","folderPath":"folders/Steamworks.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"UGC","folderPath":"folders/Steamworks/UGC.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"widgets","folderPath":"folders/widgets.yy",},
{"resourceType":"GMFolder","resourceVersion":"1.0","name":"for filter","folderPath":"folders/nodes/data/iterate/for filter.yy",},
],
"IncludedFiles": [
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ApolloHelp.html","CopyToMask":-1,"filePath":"datafiles",},
@ -525,7 +525,7 @@
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Tree sway.png","CopyToMask":-1,"filePath":"datafiles/Sample Projects",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Tree sway.pxc","CopyToMask":-1,"filePath":"datafiles/Sample Projects",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Steamworks_Extension_Documentation.html","CopyToMask":0,"filePath":"datafiles",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ucrtbased.dll","ConfigValues":{"Tester":{"CopyToMask":"64",},},"CopyToMask":-1,"filePath":"datafiles",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"ucrtbased.dll","ConfigValues":{},"CopyToMask":-1,"filePath":"datafiles",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"webpmux.exe","CopyToMask":-1,"filePath":"datafiles/webp",},
{"resourceType":"GMIncludedFile","resourceVersion":"1.0","name":"Welcome files.zip","CopyToMask":-1,"filePath":"datafiles",},
],
@ -583,6 +583,7 @@
{"id":{"name":"textInput","path":"scripts/textInput/textInput.yy",},},
{"id":{"name":"node_dither","path":"scripts/node_dither/node_dither.yy",},},
{"id":{"name":"sh_perlin_smear","path":"shaders/sh_perlin_smear/sh_perlin_smear.yy",},},
{"id":{"name":"node_iterate_filter","path":"scripts/node_iterate_filter/node_iterate_filter.yy",},},
{"id":{"name":"node_array_remove","path":"scripts/node_array_remove/node_array_remove.yy",},},
{"id":{"name":"node_path_blend","path":"scripts/node_path_blend/node_path_blend.yy",},},
{"id":{"name":"node_switch","path":"scripts/node_switch/node_switch.yy",},},
@ -747,6 +748,7 @@
{"id":{"name":"s_node_vfx_override","path":"sprites/s_node_vfx_override/s_node_vfx_override.yy",},},
{"id":{"name":"rotatorRange","path":"scripts/rotatorRange/rotatorRange.yy",},},
{"id":{"name":"font_loader","path":"scripts/font_loader/font_loader.yy",},},
{"id":{"name":"node_iterator_filter_input","path":"scripts/node_iterator_filter_input/node_iterator_filter_input.yy",},},
{"id":{"name":"point_rotate","path":"scripts/point_rotate/point_rotate.yy",},},
{"id":{"name":"s_node_vfx_variable","path":"sprites/s_node_vfx_variable/s_node_vfx_variable.yy",},},
{"id":{"name":"node_struct","path":"scripts/node_struct/node_struct.yy",},},
@ -899,6 +901,7 @@
{"id":{"name":"draw_set_text","path":"scripts/draw_set_text/draw_set_text.yy",},},
{"id":{"name":"s_node_array","path":"sprites/s_node_array/s_node_array.yy",},},
{"id":{"name":"s_node_warp","path":"sprites/s_node_warp/s_node_warp.yy",},},
{"id":{"name":"node_iterator_filter_output","path":"scripts/node_iterator_filter_output/node_iterator_filter_output.yy",},},
{"id":{"name":"color_function","path":"scripts/color_function/color_function.yy",},},
{"id":{"name":"fd_rectangle_set_pressure_size","path":"scripts/fd_rectangle_set_pressure_size/fd_rectangle_set_pressure_size.yy",},},
{"id":{"name":"node_color_data","path":"scripts/node_color_data/node_color_data.yy",},},
@ -1078,6 +1081,7 @@
{"id":{"name":"node_rigid_object","path":"scripts/node_rigid_object/node_rigid_object.yy",},},
{"id":{"name":"areaBox","path":"scripts/areaBox/areaBox.yy",},},
{"id":{"name":"__global_object_depths","path":"scripts/__global_object_depths/__global_object_depths.yy",},},
{"id":{"name":"s_node_filter_array","path":"sprites/s_node_filter_array/s_node_filter_array.yy",},},
{"id":{"name":"node_noise_grid_hex","path":"scripts/node_noise_grid_hex/node_noise_grid_hex.yy",},},
{"id":{"name":"node_lua_global","path":"scripts/node_lua_global/node_lua_global.yy",},},
{"id":{"name":"o_dialog_preset","path":"objects/o_dialog_preset/o_dialog_preset.yy",},},

View file

@ -0,0 +1,70 @@
//Make an iterator_* parent???
function Node_Iterate_Filter(_x, _y, _group = noone) : Node_Collection(_x, _y, _group) constructor {
name = "Filter Array";
color = COLORS.node_blend_loop;
icon = THEME.loop;
combine_render_time = false;
iterated = 0;
inputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, [] )
.setVisible(true, true);
outputs[| 0] = nodeValue("Array", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, [] );
custom_input_index = ds_list_size(inputs);
custom_output_index = ds_list_size(inputs);
loop_start_time = 0;
ALWAYS_FULL = true;
if(!LOADING && !APPENDING && !CLONING) {
var input = nodeBuild("Node_Iterator_Filter_Input", -256, -32, self);
var output = nodeBuild("Node_Iterator_Filter_Output", 256, -32, self);
output.inputs[| 0].setFrom(input.outputs[| 0]);
}
static getNextNodes = function() {
__nodeLeafList(getNodeList(), RENDER_QUEUE);
initLoop();
}
static onStep = function() {
var type = inputs[| 0].value_from == noone? VALUE_TYPE.any : inputs[| 0].value_from.type;
inputs[| 0].type = type;
}
static initLoop = function() {
iterated = 0;
loop_start_time = get_timer();
var arrIn = inputs[| 0].getValue();
var arrOut = outputs[| 0].getValue();
surface_array_free(arrOut);
outputs[| 0].setValue([])
printIf(global.RENDER_LOG, " > Loop begin");
}
static iterationStatus = function() {
var iter = true;
var arrIn = inputs[| 0].getValue();
var maxIter = is_array(arrIn)? array_length(arrIn) : 0;
if(!is_real(maxIter)) maxIter = 1;
iterated++;
if(iterated >= maxIter) {
render_time = get_timer() - loop_start_time;
iterated = 0;
return ITERATION_STATUS.complete;
}
resetAllRenderStatus();
return ITERATION_STATUS.loop;
}
PATCH_STATIC
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_iterate_filter",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "for filter",
"path": "folders/nodes/data/iterate/for filter.yy",
},
}

View file

@ -0,0 +1,25 @@
function Node_Iterator_Filter_Input(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Value";
color = COLORS.node_blend_loop;
manual_deletable = false;
outputs[| 0] = nodeValue("Value in", self, JUNCTION_CONNECT.output, VALUE_TYPE.any, 0 );
outputs[| 0].getValueDefault = method(outputs[| 0], outputs[| 0].getValueRecursive); //Get value from outside loop
outputs[| 0].getValueRecursive = function() {
if(!variable_struct_exists(group, "iterated"))
return outputs[| 0].getValueDefault();
var ind = group.iterated;
var val = group.inputs[| 0].getValue();
return [ array_safe_get(val, ind), group.inputs[| 0] ];
}
static step = function() {
if(!variable_struct_exists(group, "iterated")) return;
outputs[| 0].type = group.inputs[| 0].type;
}
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_iterator_filter_input",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "for filter",
"path": "folders/nodes/data/iterate/for filter.yy",
},
}

View file

@ -0,0 +1,12 @@
{
"isDnD": false,
"isCompatibility": false,
"parent": {
"name": "group",
"path": "folders/nodes/data/group.yy",
},
"resourceVersion": "1.0",
"name": "node_group_input",
"tags": [],
"resourceType": "GMScript",
}

View file

@ -0,0 +1,68 @@
function Node_Iterator_Filter_Output(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
name = "Filter Output";
color = COLORS.node_blend_loop;
manual_deletable = false;
inputs[| 0] = nodeValue("Value", self, JUNCTION_CONNECT.input, VALUE_TYPE.any, false )
.setVisible(true, true);
inputs[| 1] = nodeValue("Result", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false )
.setVisible(true, true);
static getNextNodes = function() {
if(!struct_has(group, "iterationStatus")) return;
var _ren = group.iterationStatus();
if(_ren == ITERATION_STATUS.loop) { //Go back to the beginning of the loop, reset render status for leaf node inside?
printIf(global.RENDER_LOG, " > Loop restart: iteration " + string(group.iterated));
__nodeLeafList(group.getNodeList(), RENDER_QUEUE);
} else if(_ren == ITERATION_STATUS.complete) { //Go out of loop
printIf(global.RENDER_LOG, " > Loop completed");
group.setRenderStatus(true);
var _ot = group.outputs[| 0];
for(var j = 0; j < ds_list_size(_ot.value_to); j++) {
var _to = _ot.value_to[| j];
if(!_to.node.renderActive) continue;
if(_to.node.active && _to.value_from != noone && _to.value_from.node == group) {
_to.node.triggerRender();
if(_to.node.isUpdateReady()) ds_queue_enqueue(RENDER_QUEUE, _to.node);
}
}
} else
printIf(global.RENDER_LOG, " > Loop not ready");
}
static step = function() {
if(!variable_struct_exists(group, "iterated")) return;
var type = inputs[| 0].value_from == noone? VALUE_TYPE.any : inputs[| 0].value_from.type;
inputs[| 0].type = type;
group.outputs[| 0].type = type;
}
static update = function(frame = ANIMATOR.current_frame) {
if(inputs[| 0].value_from == noone)
return;
if(!variable_struct_exists(group, "iterated"))
return;
var val = inputs[| 0].getValue();
var res = inputs[| 1].getValue();
var _val = group.outputs[| 0].getValue();
if(!is_array(_val)) return;
if(res) {
var is_surf = inputs[| 0].value_from.type == VALUE_TYPE.surface;
var _new_val = val;
if(is_surf) _new_val = surface_array_clone(val);
else _new_val = array_clone(val);
array_push(_val, _new_val);
}
group.outputs[| 0].setValue(_val);
}
}

View file

@ -0,0 +1,11 @@
{
"resourceType": "GMScript",
"resourceVersion": "1.0",
"name": "node_iterator_filter_output",
"isCompatibility": false,
"isDnD": false,
"parent": {
"name": "for filter",
"path": "folders/nodes/data/iterate/for filter.yy",
},
}

View file

@ -106,6 +106,16 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
addNodeObject(itere, "Index", s_node_iterator_index, "Node_Iterator_Index", [1, Node_Iterator_Index]);
addNodeObject(itere, "Array Length", s_node_iterator_length, "Node_Iterator_Each_Length", [1, Node_Iterator_Each_Length]);
var filter = ds_list_create();
addNodeCatagory("Filter", filter, ["Node_Iterate_Filter"]);
ds_list_add(filter, "Groups");
addNodeObject(filter, "Input", s_node_group_input, "Node_Group_Input", [1, Node_Group_Input]);
addNodeObject(filter, "Output", s_node_group_output, "Node_Group_Output", [1, Node_Group_Output]);
ds_list_add(filter, "Loops");
addNodeObject(filter, "Index", s_node_iterator_index, "Node_Iterator_Index", [1, Node_Iterator_Index]);
addNodeObject(filter, "Array Length", s_node_iterator_length, "Node_Iterator_Each_Length", [1, Node_Iterator_Each_Length]);
var feed = ds_list_create();
addNodeCatagory("Feedback", feed, ["Node_Feedback"]);
ds_list_add(feed, "Groups");
@ -512,6 +522,7 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
addNodeObject(node, "Feedback", s_node_feedback, "Node_Feedback", [1, Node_Feedback],, "Create group that reuse output from last frame to the current one.");
addNodeObject(node, "Loop", s_node_loop, "Node_Iterate", [1, Node_Iterate], ["iterate", "for"], "Create group that reuse output as input repeatedly in one frame.");
addNodeObject(node, "Loop Array", s_node_loop_array, "Node_Iterate_Each", [1, Node_Iterate_Each], ["iterate each", "for each", "array loop"], "Create group that iterate to each member in an array.");
addNodeObject(node, "Filter Array", s_node_filter_array,"Node_Iterate_Filter", [1, Node_Iterate_Filter], "Filter array using condition.");
ds_list_add(node, "Lua");
addNodeObject(node, "Lua Global", s_node_lua_global, "Node_Lua_Global", [1, Node_Lua_Global]).setVersion(1090);
@ -532,8 +543,10 @@ function NodeObject(_name, _spr, _node, _create, tags = []) constructor {
var hid = ds_list_create();
addNodeCatagory("Hidden", hid, ["Hidden"]);
addNodeObject(hid, "Input", s_node_feedback_input, "Node_Iterator_Each_Input", [1, Node_Iterator_Each_Input]);
addNodeObject(hid, "Output", s_node_feedback_output, "Node_Iterator_Each_Output", [1, Node_Iterator_Each_Output]);
addNodeObject(hid, "Input", s_node_loop_input, "Node_Iterator_Each_Input", [1, Node_Iterator_Each_Input]);
addNodeObject(hid, "Output", s_node_loop_output, "Node_Iterator_Each_Output", [1, Node_Iterator_Each_Output]);
addNodeObject(hid, "Input", s_node_loop_input, "Node_Iterator_Filter_Input", [1, Node_Iterator_Filter_Input]);
addNodeObject(hid, "Output", s_node_loop_output, "Node_Iterator_Filter_Output", [1, Node_Iterator_Filter_Output]);
addNodeObject(hid, "Grid Noise", s_node_grid_noise, "Node_Grid_Noise", [1, Node_Grid_Noise]);
addNodeObject(hid, "Triangular Noise", s_node_grid_tri_noise, "Node_Noise_Tri", [1, Node_Noise_Tri]).setVersion(1090);
addNodeObject(hid, "Hexagonal Noise", s_node_grid_hex_noise, "Node_Noise_Hex", [1, Node_Noise_Hex]).setVersion(1090);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1,74 @@
{
"resourceType": "GMSprite",
"resourceVersion": "1.0",
"name": "s_node_filter_array",
"bbox_bottom": 63,
"bbox_left": 0,
"bbox_right": 63,
"bbox_top": 0,
"bboxMode": 0,
"collisionKind": 1,
"collisionTolerance": 0,
"DynamicTexturePage": false,
"edgeFiltering": false,
"For3D": false,
"frames": [
{"resourceType":"GMSpriteFrame","resourceVersion":"1.1","name":"11ba9239-26e0-4926-97c9-23ed48eaa71c",},
],
"gridX": 0,
"gridY": 0,
"height": 64,
"HTile": false,
"layers": [
{"resourceType":"GMImageLayer","resourceVersion":"1.0","name":"40df6802-8e46-4bc2-acec-fbc930237b66","blendMode":0,"displayName":"default","isLocked":false,"opacity":100.0,"visible":true,},
],
"nineSlice": null,
"origin": 4,
"parent": {
"name": "node",
"path": "folders/nodes/icons/node.yy",
},
"preMultiplyAlpha": false,
"sequence": {
"resourceType": "GMSequence",
"resourceVersion": "1.4",
"name": "s_node_filter_array",
"autoRecord": true,
"backdropHeight": 768,
"backdropImageOpacity": 0.5,
"backdropImagePath": "",
"backdropWidth": 1366,
"backdropXOffset": 0.0,
"backdropYOffset": 0.0,
"events": {"resourceType":"KeyframeStore<MessageEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
"eventStubScript": null,
"eventToFunction": {},
"length": 1.0,
"lockOrigin": false,
"moments": {"resourceType":"KeyframeStore<MomentsEventKeyframe>","resourceVersion":"1.0","Keyframes":[],},
"playback": 1,
"playbackSpeed": 30.0,
"playbackSpeedType": 0,
"showBackdrop": true,
"showBackdropImage": false,
"timeUnits": 1,
"tracks": [
{"resourceType":"GMSpriteFramesTrack","resourceVersion":"1.0","name":"frames","builtinName":0,"events":[],"inheritsTrackColour":true,"interpolation":1,"isCreationTrack":false,"keyframes":{"resourceType":"KeyframeStore<SpriteFrameKeyframe>","resourceVersion":"1.0","Keyframes":[
{"resourceType":"Keyframe<SpriteFrameKeyframe>","resourceVersion":"1.0","Channels":{"0":{"resourceType":"SpriteFrameKeyframe","resourceVersion":"1.0","Id":{"name":"11ba9239-26e0-4926-97c9-23ed48eaa71c","path":"sprites/s_node_filter_array/s_node_filter_array.yy",},},},"Disabled":false,"id":"aa903ffc-cb8f-4417-b3a7-e40ec84f2bd2","IsCreationKey":false,"Key":0.0,"Length":1.0,"Stretch":false,},
],},"modifiers":[],"spriteId":null,"trackColour":0,"tracks":[],"traits":0,},
],
"visibleRange": null,
"volume": 1.0,
"xorigin": 32,
"yorigin": 32,
},
"swatchColours": null,
"swfPrecision": 2.525,
"textureGroupId": {
"name": "Default",
"path": "texturegroups/Default",
},
"type": 0,
"VTile": false,
"width": 64,
}