Can I invoke a custom LUA function from an Alias? If yes, how?

Post Reply
EmanueleCiriachi
Posts: 9
Joined: Tue Jul 18, 2017 8:03 pm

Can I invoke a custom LUA function from an Alias? If yes, how?

Post by EmanueleCiriachi »

Under "Scripts" I created an item called "TestMovement" whose body is simply

echo('test')

I have an alias, and I would like to invoke the TestMovement function from it. How can I achieve this?

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Can I invoke a custom LUA function from an Alias? If yes, how?

Post by demonnic »

What you want to do then is make a testMovement() function inside the TestMovement script object. Doesn't matter waht the script object is called in this case, just what you call the function below.
Code: [show] | [select all] lua
function testMovement()
  echo("test")
end
and in the alias call
Code: [show] | [select all] lua
testMovement()

EmanueleCiriachi
Posts: 9
Joined: Tue Jul 18, 2017 8:03 pm

Re: Can I invoke a custom LUA function from an Alias? If yes, how?

Post by EmanueleCiriachi »

Works! Thank you very much.

User avatar
demonnic
Posts: 886
Joined: Sat Dec 05, 2009 3:19 pm

Re: Can I invoke a custom LUA function from an Alias? If yes, how?

Post by demonnic »

Quite welcome =)

User avatar
SlySven
Posts: 1023
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Can I invoke a custom LUA function from an Alias? If yes, how?

Post by SlySven »

demonnic wrote:
Wed Jul 19, 2017 6:05 pm
... Doesn't matter waht the script object is called in this case, just what you call the function below...
There is one case where the name of the script object is important and that is if one of the functions contained in its scripts is to be an event handler - in that case the name of the function and the name of the script object has to be the same - this is so the event system knows which function to send the event names entered for the script to handle to... :ugeek:

Post Reply