TriggerReactor

TriggerReactor

24.6k Downloads

How to create/change local and global varibles from Executor?

miresru opened this issue ยท 2 comments

commented

How I can create or change local or global varible from Executor?

For example I have script:
{"myobj.myvar"} = "some data"
#TEST "new data"
#LOG {"myobj.myvar"}

How I can change myobj.myvar in TEST.js?

commented

I found sollution, but I am not sute it's right one.

Script file:
{"myobj.myvar"} = "some data"
#TEST "NEW DATA"
#LOG {"myobj.myvar"}

TEST.js
function TEST(args){
plugin.getVariableManager().put("myobj.myvar",args[0]); - to set global var
plugin.getVariableManager().saveAll(); - to save vars to file
var v = plugin.getVariableManager().get("myobj.myvar"); - to get global var
print("v="+v); - print it to console
return null;
}

For all other methods look here: VariableManager

commented

great that you are accessing VariableManager directly!

though, there are predefined functions: get(String), put(String, Object), and has(String)

they do the exact same thing as you are doing now.