Author Topic: Aliases to other commands  (Read 2052 times)

0 Members and 1 Guest are viewing this topic.

Offline Tristan Parker

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Physgun enthusiast
Aliases to other commands
« on: March 17, 2015, 03:44:32 PM »
Hello Ulysees members,
I'm relatively new to ULX and just getting into the LUA files, and although I have a basic understanding of how ULX works behind the stage, I'm not sure of one code and would like help. The question I'm posing is the following: How can I create a new command which is an alias of another? To further extend this, the example I propose is that I would like !addons to redirect to !motd. What code can I use to make reference to this?

And another question: can I create a command which executes two commands simutaneously? I would like to have the !freefly command execute both the ulx noclip and ulx god commands.

Thank you for your help.
"A man is least himself when he talks in his own person. Give him a mask, and he will tell you the truth."
~ Oscar Wilde

Offline lynx

  • Jr. Member
  • **
  • Posts: 59
  • Karma: 15
Re: Aliases to other commands
« Reply #1 on: March 17, 2015, 06:48:15 PM »
With Lua you can do most anything. So making one that can do two is easy, and can be complicated or simple depending on how you want to do it.

As for an alias do you want !addons to be fully !motd or to just open like !motd but another page?

Also, if you plan on asking for help coding then you should post in the Developer Corner, and if you are suggestion someone make a command then it should be in suggestions. This board is mostly chat and asking for help with problems that come up with ULX itself, not with coding for ULX. :)

Offline Bite That Apple

  • Hero Member
  • *****
  • Posts: 858
  • Karma: 416
  • Apple Innovations 2010®
    • Fun 4 Everyone Gaming
Re: Aliases to other commands
« Reply #2 on: March 18, 2015, 04:38:55 AM »
From what I see you want, you want two commands to do the same thing. I don't know if this works for a fact, but I believe I've seen this somewhere. If this works, you should tell me, because I do not know myself. So as an example I'll be using ulx\lua\ulx\modules\sh\fun.lua

on line 20 according to the default ulx file, it should be
Code: [Select]
local slap = ulx.command( CATEGORY_NAME, "ulx slap", ulx.slap, "!slap" )
If you just do this {  } in where the command is entered, both commands will work:

Code: [Select]
local slap = ulx.command( CATEGORY_NAME, "ulx slap", ulx.slap, {"!slap", "!bitchslap"} )
Quote from: John F. Kennedy 1963
A man may die, nations may rise and fall, but an idea lives on.

Offline Tristan Parker

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Physgun enthusiast
Re: Aliases to other commands
« Reply #3 on: March 18, 2015, 09:53:02 AM »
Thank you Bite That Apple! I knew it was something along those lines but not quite sure exactly how to do it.

I tried doing something along the lines of what you said originally but I didn't add the parenthesizes. Much appreciated!
"A man is least himself when he talks in his own person. Give him a mask, and he will tell you the truth."
~ Oscar Wilde