hello_node_brush.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. let plugin = plugin_create();
  2. let category_name = "My Nodes";
  3. let node_name = "Hello World";
  4. let node_type = "HELLO_WORLD";
  5. // Create new node category
  6. let node_list = [
  7. {
  8. id: 0,
  9. name: node_name,
  10. type: node_type,
  11. x: 0,
  12. y: 0,
  13. color: 0xffb34f5a,
  14. inputs: [
  15. {
  16. id: 0,
  17. node_id: 0,
  18. name: "Scale",
  19. type: "VALUE",
  20. color: 0xffa1a1a1,
  21. default_value__f32: [1.0],
  22. min__f32: 0.0,
  23. max__f32: 5.0,
  24. precision__f32: 100.0,
  25. display: 0
  26. }
  27. ],
  28. outputs: [
  29. {
  30. id: 0,
  31. node_id: 0,
  32. name: "Value",
  33. type: "VALUE",
  34. color: 0xffc7c729,
  35. default_value__f32: [1.0],
  36. min__f32: 0.0,
  37. max__f32: 5.0,
  38. precision__f32: 100.0,
  39. display: 0
  40. }
  41. ],
  42. buttons: [],
  43. width: 0
  44. }
  45. ];
  46. nodes_brush_category_add(category_name, armpack_encode(node_list));
  47. // Brush node
  48. parser_logic_custom_nodes_set(node_type, function(node, from) {
  49. return Math.sin(sys_time() * node.inputs[0].get(0));
  50. });
  51. // Cleanup
  52. plugin_notify_on_delete(plugin, function() {
  53. parser_logic_custom_nodes_delete(node_type);
  54. nodes_brush_category_remove(category_name);
  55. });