|
ccogdill Beginner
Joined: 16 Jul 2002 Posts: 27
|
Posted: Fri May 09, 2003 7:07 am
returning alias name |
Is there a way to programatically tell what alias you are executing?
So, If I have an alias:
#AL kk {kill %1;kick %1}
Is there a way to return kk to the script? |
|
|
|
Lain Novice
Joined: 26 Oct 2001 Posts: 38
|
Posted: Fri May 09, 2003 11:32 am |
Not sure if there is an option to echo aliases, otherwise you can send it in the form of a SHOW or SAY and add the colour your usual commands are sent in.
#AL kk {#SH %ansi( yellow, black)kk;kill %1;kick %1}
For the colour %ansi(font colour, background colour) if you use black (0) for the background just put %ansi(yellow) and it will colour the text yellow.
Hope this helps,
Lain |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Fri May 09, 2003 12:42 pm |
Are you oversimplifying your example? How can you not know the name of an alias in its code?
#ALIAS {kill %1;kick %1;#SH The name of this alias is kk}
Or are you perhaps calling the alias indirectly by a variable reference? In this case, pass the value of the variable that contains the name of the alias as another parameter to the alias.
Kjata |
|
|
|
ccogdill Beginner
Joined: 16 Jul 2002 Posts: 27
|
Posted: Sat May 10, 2003 6:24 am |
Here is the code that fits within the alias. I wanted to know the name of the alias to make the code more error proof.
; Change this for the channel you wish to colorize, ex: gossip, say, tell, etc.
#var channel {say}
; Your randomly chosen scheme, if you only want one color scheme, just remove
; all but one string from the stringlist. Ex:
; #var SchemeList {"ccgg"}
; The letters in the schemelist represent colors, C = Cyan, G = Green
; These will usually be different on each mud.
#var SchemeList {"ccgg"|"PWB"|"PG"|"CBN"|"PW"|"gR"|"GH"|"Yb"|"MV"}
; The escape charecter needs to be changed if your mud has a different
; charecter besides the left curly bracket. Some muds use the & charecter.
; Check on your mud's help color page.
#var EscapeChar {"{"}
; The terminator charecter is sometimes required on muds to prevent color
; bleed. You may not need the terminator, but it is always
; safe to put it in.
#var Terminator {"x"}
;
;Do not modify script beyond this point.
;
#IF ( %aliasname == @channel) {
#echo "You can't name your alias and channel the same."
#echo "Choose a different name for your alias."
#echo "Most muds already have an alias for gossip, say, tell, etc."
#echo "Example, the semi-colon is often used as an alias for gossip."
#echo "So you could, make the alias name gossip, and use ; as your channel."
#echo "You may also shorten your alias name to gos and use gossip as your channel."
}
#var out ""
#var Scheme {%item( @SchemeList, %random( 1, %numitems( @SchemeList)))}
#var Count 0
#while ( %len( "%-1")>=@Count) {
#var out %concat( @out, @EscapeChar)
#var out %concat( @out, %copy( @Scheme, %mod( @Count, %len( @Scheme))+1, 1))
#var out %concat( @out, %copy( "%-1", @Count+1, 1))
#add Count 1
}
@channel @out@EscapeChar@Terminator
This was going into my contribution to the finished scripts. |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Sat May 10, 2003 1:34 pm |
Yeah, I see what you want. A simple solution is to put a ~ before the channel name each time you use it at the start of a line. If the alias is named the same as the channel, then the channel's command will be used instead of the alias. If there is no alias with the same name as the channel, the ~ won't appear and it will still work as normal. Example:
#EXEC %concat("~", @channel, " ", @out, @EscapeChar, @Terminator)
Kjata |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|