switchScript


JavaScript is a powerful scripting language that allows with few lines of code to implement simple to complex logic on EVE Manager and will give you the possibility to make your own script.

COMPONENT’S PROPERTIES

Customizable component’s title and icon. Please refer to “Common properties” guide.

User Data(textbox): This simple window is the core of the script, here you can write your own code following simple rules like:

getValueAsString(IDComponent); this method will get the value of the component using the ID that you can find on EVE Manager as a String (“this is a string”.);

getValueAsInt(IDComponent);  this method will get the value of the component using the ID that you can find on EVE Manager as an Integer (1,2,3,4,5 etc.);

getValueAsBoolean(IDComponent); this method will get the value of the component as a boolean that represents  one of two value: true or false you can find the ID of the component on EVE Manager;

setValue(IDComponent, ValueoftheComponent); this method will let you set the value (for example a Switch that have  0/1 values) of your desired component;

setTrigger(IDComponent,”function”); this method triggers the specified event and the default behavior of an event, it’s really important to remember that the setTrigger will not work without a component ID and a”function”;

removeTrigger(component ID); this method will let you remove the specified trigger set for the specific component ID.

setInterval(secondsfunction); this method will continue calling the function every X seconds that you entered inside “”.

removeInterval(“function“); this method will let you remove the specified function that you previously used inside the setInterval. object can be used to request data from a web server.

log; allows the user to keep tracking of what is happening inside the script. This functionality’s not still present and it will be available on the next release of the EVE Manager.

HTTPRequest; this method can be used to request data from a web server.  An example can be:

var x =HTTPRequest(“URL”);

Note: for any requests / suggestions please contact the technical support.

If…Else Statement


In this example we are using a Switch with the ID “12” and a “Changeable Value” with the ID “14”.  Using an if statement we will able to tell to EVE Manager to enable the Switch when the Changeable Value reaches the number 10 or higher. A perfect use for this script is when you need something to happen when a certain value is reached.

In this example we are using a Switch with the ID “14” and a “Drop Down” with the ID “13”.  Using an if statement we will able to tell to EVE Manager to enable the Switch when the Drop Down reaches the number 0 of the index, this mean that if it reach the value 1 the “Air Conditioner” will turn off. A perfect use for this script is when you need something to happen a value of the Drop Down is chosen.

Javascript Functions


In this example we are using an Info component with the ID “12”.  Using a function we will able to  increase the Info value by 1 every 2 seconds.  In this case to call the function we have to put it inside the method setInterval(2,”executeAdd”); as you can see the first argument inside the parenthesis is for how long in seconds we should increment by 1 (++) the value of the variable a, in the second argument  we simply call the function.

In this example we are using two Info components with the ID “11” and “12”.  Using a function we will able to increase the first Info value by 1 every 2 seconds and the second Info by 1 every 10 seconds. In this case to call the function we have to put it inside the method setInterval(2,”executeAddEvery2S”) and setInterval(10,”executeAddEvery10S”); as you can see the first argument inside the parenthesis is for how long in seconds we should increment by 1 (++) the value of the variable a, in the second argument we simply call the function that will, as said before, add 1 to the variable a.

In this example we are using two Switch components with the ID “12” and “13” and two Info components with the ID “14” and “15”.  Using a function we will able to increase the first Info value by 1 every click on the Switch the same happens if we click the second Switch with the other Info. A perfect use of functions is when you need to execute some code when something happens.  In this case to call the function we have put it inside the method setTrigger(12,”executeWhen12Clicked”) and setTrigger(13,”executeWhen13Clicked”); as you can see the first argument inside the parenthesis is the component that we should increase by 1 (++) the value of the variable a, in the second argument we simply call the function that will, as said before,  add 1 to the variable a after clicking the component 12 or 13.

Well done, keep learning!

Our suggestion for your next lesson: