Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Sat Feb 20, 2010 6:17 pm   

Random Emote w/ One Command
 
I have a number of different emotes such as nod1, nod2, nod3 and bow1, bow2, bow3 etc. Each one is a different form of the emote. I would like a script where I could just type nod or bow and it would pick on of the emotes randomly and display it. Any ideas?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Feb 20, 2010 7:46 pm   
 
#command_you_use %item(@list_of_emotes,%random(1,%numitems(@list_of_emotes)))
_________________
EDIT: I didn't like my old signature
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Sat Feb 20, 2010 9:09 pm   
 
So then it would look like this:

#nod %item(@nod1, nod2, nod3,%random(1,%numitems(@nod1, nod2, nod3)))

?
Reply with quote
Erasmus
Wanderer


Joined: 04 Aug 2004
Posts: 82
Location: Philadelphia

PostPosted: Sat Feb 20, 2010 9:46 pm   
 
Try this:

#VARIABLE list_of_nods {nod1|nod2|nod3}
#ALIAS nod %item(@list_of_nods,%random(1,%numitems(@list_of_nods)))

edit: fixed spelling error
_________________
Erasmus

Last edited by Erasmus on Sun Feb 21, 2010 3:53 am; edited 1 time in total
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Sun Feb 21, 2010 2:25 am   
 
It doesn't do random. The first time I type 'nod' it sets itself to nod3 and keeps repeating that one.
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Sun Feb 21, 2010 4:32 pm   
 
Anyone have any correction or fix to this yet?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sun Feb 21, 2010 6:32 pm   
 
There shouldn't need to be any fix. Erasmus's code works just fine. Try using the alias more than a few times, because with just three items in the list there's a high probability that it will simply pick the same one over and over.
_________________
EDIT: I didn't like my old signature
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Mon Feb 22, 2010 12:41 am   
 
Well, I set three emotes titled nod1, nod2, nod3. I entered the script Erasmus wrote. I tested it by typing in nod 50 times. I got the same emote 50 times.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Feb 22, 2010 3:34 am   
 
Maybe check the variable? If it's set as string(literal), it might not work properly. It should be Autotype or Stringlist.
_________________
EDIT: I didn't like my old signature
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Mon Feb 22, 2010 4:59 pm   
 
I have no clue what you just said :)
I used the script listed a few sections above to the letter.
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Mon Feb 22, 2010 5:05 pm   
 
Ok, I figured out what you meant. I went to the variable and it was listed as string list. But I changed it to autotype and it didn't work either.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Feb 22, 2010 6:12 pm   
 
The problem was that Erasmus forgot some braces:
Code:
#VARIABLE list_of_nods {nod1|nod2|nod3}
#ALIAS nod {%item(@list_of_nods,%random(1,%numitems(@list_of_nods)))}


Actually, using the %item() as the first thing in a command line is not a good idea, so a better code would be:
Code:
#VARIABLE list_of_nods {nod1|nod2|nod3}
#ALIAS nod {#SEND %item(@list_of_nods,%random(1,%numitems(@list_of_nods)))}
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Feb 23, 2010 12:19 am   
 
:)

Ok, now when I type nod (after using Rahab's second code above) I get an echo of the random nod (nod1 or nod2 or nod3) and then a what? If I actually type in the nod1, nod2 or nod3 the emote runs.
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Feb 23, 2010 12:29 am   
 
Maybe use #SENDRAW instead of #SEND. Sounds like something in the nod emote is getting parsed, which #SEND allows to happen.
_________________
EDIT: I didn't like my old signature
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Feb 23, 2010 1:13 am   
 
The only thing that changed was now the command (nod1 or nod2, etc) doesn't get echoed (in other words I don't see it now). All I get now is what?
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Feb 23, 2010 1:15 am   
 
Should I be putting the actual emotes in where it says {nod1|nod2|nod3}?
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Feb 23, 2010 1:26 am   
 
Yeah, I just tested it by changing the #VAR part that shows {nod1|nod2|nod3}. I changed it, for testing purposes, to {emote nods|emote winks|emote pukes} and when I type "nod" I get one of those randomly. So I must not have explained myself in my original request.

I have aliases labeled nod1, nod2 and nod3. Each one is an ALIAS. For instance, nod1 is emote nods suspiciously, nod2 is emote nods and causes some garbage to fall out of it's hair, etc. I want to be able to type "nod" and have these go off randomly.

Or do I HAVE to put in each emote in the variable section for this to work? I recall when I had a version of zMud, I had a script that worked but I can't find it in the forums and I can't find it in my old zmud files.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Tue Feb 23, 2010 2:13 am   
 
Instead of #SEND use #EXECUTE
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
shadowsurfer
Novice


Joined: 17 Dec 2004
Posts: 34

PostPosted: Tue Feb 23, 2010 4:15 am   
 
Eureka! That did it. Thanks everyone Very Happy
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Feb 23, 2010 2:22 pm   
 
Yeah, sorry. If it's a command for the mud, then use #SEND, if it's a Cmud command or alias, use #EXEC.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net