====== Chataigne ====== ===== object ====== var myObject = { "myprop1":"value", "myprop2":"second", "myMethod": function(params) { this.myprop1 = params[0]; } } var my_instance = new myObject(); script.log(my_instance.myprop1); my_instance.mymethod(["test","one","two"]); script.log(my_instance.myprop1); ===== Values in script ===== When adding a value parameter in a module, only the parameter is saved between sessions/projects. If you want to keep the value content, use setAttribute("saveValueOnly",false) var mycontainer = local.values.addContainer("toto"); var myint1 = mycontainer.addIntParameter("myint", "",1,1,65536); myint1.setAttribute("saveValueOnly",false); ===== Custom variables ===== function getCustomVariablesGroup(name, shortname) { var my_group = root.customVariables.getItemWithName(shortname); if (my_group.name != shortname) { // build a new group my_group = root.customVariables.addItem(shortname); my_group.setName(name); } return my_group; } /** * Set or create then set the custom variable value * @param {int} page_id * @param {int} exec_id * @param {int} value * @param {string} type * @param {string} item_nice_name */ function setCustomVariablesValue(page_id, exec_id, value, type, item_nice_name) { // build names var shortname = "exec"+ page_id+ "_"+ exec_id; var name = "Exec "+ page_id+ "_"+ exec_id; // get the group var my_group = getCustomVariablesGroup(name, shortname); // define the item type var item_name = type; var item_type = "Int"; var int_max = 100; if (["Go", "Stop", "Resume", "Off"].contains(type)) { item_type = "Bool"; } // build some names var my_value = {}; var my_value_name = "exec"+ page_id+ "_"+exec_id+ item_name; var my_value_nice_name = "Exec "+ page_id+ "_"+ exec_id+ " "+ item_nice_name; var my_value_item = my_group.variables.getItemWithName(my_value_name); if (my_value_item.name != my_value_name) { // create if not exist my_value_item = my_group.variables.addItem(item_type+ " Parameter"); my_value = my_value_item.getChild(my_value_item.name); my_value.setName(my_value_nice_name); if (["CueMsb", "CueLsb"].contains(type)) { int_max = 999; } if (["Hour", "Minute", "second"].contains(type)) { int_max = 60; } if (!["Go", "Stop", "Resume", "Off"].contains(type)) { my_value.setRange(0,int_max); } } else { my_value = my_value_item.getChild(my_value_item.name); } if (["Go", "Stop", "Resume", "Off"].contains(type)) { my_value.set(true); my_value.set(false); } else { my_value.set(value); } my_group.variables.reorderItems(); }