question

Jouky D avatar image
0 Likes"
Jouky D asked Jouky D commented

How to trigger OnReset: Reset the table of a Global Table by FlexScript?

Hello everyone,

I need to create a table using FlexScript and this table has to reset some values to 0 on Reset.

How do I trigger an event On Reset when I create a global table?


Thank you!

FlexSim 23.1.2
global tableflexscripton reset
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Jouky D commented

A table you create through Tools.create() will have a "resettrigger" node in its variables. Write the needed code to that node as a string and switch the node to flexscript.

1710231518971.png

  1. Object newTable = Tools.create("GlobalTable");
  2. treenode resetTrigger = getvarnode(newTable, "resettrigger");
  3. // Add code that resets the first column to 0
  4. resetTrigger.value = "Table current = param(1);\
  5. for(int row = 1; row <= current.numRows; row++) {\
  6.     current[row][1] = 0;\
  7. }";
  8. // Switch to flexscript
  9. switch_flexscript(resetTrigger, 1);
  10. buildnodeflexscript(resetTrigger);

1710231518971.png (5.1 KiB)
· 6
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.