Page 1 of 1

Transfer variable

Posted: Tue Jul 06, 2010 2:07 pm
by zbynio
Hi
Any know how do I pass a variable from script in game to script in the bot?

;)

Re: Transfer variable

Posted: Tue Jul 06, 2010 11:00 pm
by rock5
zbynio wrote:Hi
Any know how do I pass a variable from script in game to script in the bot?

;)
I use something like that in fastlogin_revisited.

The in-game script uses a variable "loginNextToon" to tell it if it hould login your next character.

I read that value from the bot like this;

Code: Select all

value = RoMScript("LoginNextToon")
and change it like this;

Code: Select all

value = true
RoMScript("}LoginNextToon="..tostring(value)..";a={")

Re: Transfer variable

Posted: Wed Jul 07, 2010 6:37 am
by zbynio
a very cool way - thank you @rock5
but...
this is boolean
i need:
in-game script (addon) set a long alphanumeric string and read it in the script bot

ex.:
in addon mystring need as global <-- I dont know how make this

Code: Select all

function myAddOn.setHello() 
      mystring = "hello world 12345";
      return mystring;
end
in bot <-- work fine

Code: Select all

value = sendMacro("myAddOn.setHello();");
addMessage(value);

Re: Transfer variable

Posted: Wed Jul 07, 2010 9:18 am
by Administrator
Type shouldn't mater for this. I'm fairly certain that strings work.

Re: Transfer variable

Posted: Wed Jul 07, 2010 9:40 am
by rock5
zbynio wrote: in addon mystring need as global <-- I dont know how make this
Just declare the string outside of any functions, usually at the top of the file.
eg.

Code: Select all

mystring = "";
Actually I just had a an idea. If you want to use a function;

Code: Select all

function myAddOn.setHello(variable)
      return variable;
end
With this function you can return any global variable in the game.

For instance you want mystring, just use;

Code: Select all

value = sendMacro("myAddOn.setHello(mystring);");
But I'm pretty sure my example would have worked with any value. Easier too.