inside functions

Posted by Avariel on Fri 26 Jul 2002 01:06 PM — 4 posts, 17,675 views.

Portugal #0
i need help in 2 things.

1rst:

im trying to run alias inside script functions... dunno if thats possible but if it is id like to someone hepls me with sintax cus im not being able of doing it.

2nd:

i have a diferent function for each of my chars with the names like this

afk_<char_name_1>
afk_<char_name_2>
afk_<char_name_3>

when i connect to the mud i have a function that sets

self = <char_name>

ide like to know if it possible to set a function that runs afk_self function inside it... meaning that recognizes the variable set on connection and choses the right afk_* function. if its possible how do i do it.

thx.
Australia Forum Administrator #1
Quote:

im trying to run alias inside script functions...


You can't call aliases from scripts, because of the possibility of an endless loop. Eg. alias A calls script B, script B calls alias A and so on.

However, what you can do is make a variable, eg.

variable XXX = "go north"

Then the alias uses the variable, eg.

alias YYY = "@xxx"

With "expand variables" set this would send "go north".

Then in your script you can also use the same variable, eg.


world.send world.getvariable ("XXX")


This would send "go north".


Quote:

ide like to know if it possible to set a function that runs afk_self function inside it.


You can do this with the VB "execute" command. eg.


Execute "call afk_" & world.getvariable ("self")


This tells VB to join "afk_" with the contents of variable "self" then execute "call afk_self" (whatever self is).
Australia Forum Administrator #2
I just noticed this is the Jscript part of the forum, but the answer is very similar. Instead of "Execute" you would use "eval", like this:


eval ("afk_" + world.getvariable ("self") + " () ;");
Portugal #3
thank you, Nick

I'll probably gonna have some more questions as I try to do more complex alias :)

this reply will help me a lot.

have fun.