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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Madamegato
Beginner


Joined: 27 Nov 2002
Posts: 27
Location: USA

PostPosted: Fri Jan 10, 2003 3:50 am   

CASE within IF statement?
 
Hello again!

Ok. Here's my question. I have a trigger that looks much as this does:
trigger: ^(%w) gives you (*)
and my bot gives them a random thank you via:
value: #CASE %random{tell %1 Thank you for %2!} {tell %1 Wow! %2! Thanks!} ect.

Here is the issue however. There are certain emotes that trigger the giving command. Such as:
soandso gives you a big high five
or
soandso gives you a round of applause.

I thought, maybe I can set it up that the emotes are in a variable called @GiveEmotes and if the bot gets one of the above emotes, it will simply emote back, and if it is something else, it will thank them with one of the ten random thanks.

I'm not sure how to go about this though, or if it can be done. My idea is something like this:
pattern: ^(%w) gives you (*)
value: #IF (%ismember(%2,@GiveEmotes)) {emote to %1} {@Thanks}

Where @Thanks would be:
#VAR Thanks
value: %case(%random(10), "Thanks %1 for %2", "Thanks for the %2!")

I don't want to try it for fear that I might do something to my bot as it is running now after a bad bug, but does that look like it would work to do what I want?

-M.
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Jan 10, 2003 4:19 am   
 
That would work.

I'd just suggest you change the %case function to:
value: %case(%random(1,2), "Thanks %1 for %2", "Thanks for the %2!")

Where 2 is the number of options and 1 the minimum returned from the random fuction as %case(0,"1","2") returns nothing.

Ton Diening

Edit: I'll have to fire up zMud. Figured it would expand. ^_^
Reply with quote
Madamegato
Beginner


Joined: 27 Nov 2002
Posts: 27
Location: USA

PostPosted: Fri Jan 10, 2003 5:09 am   
 
Hmmm, it didn't work...

I tested it and got it to send me a correct response, but it sent:
"tell %1 Thanks for %2

So it's not recognizing and translating ^(%w) or (*). When I do try to save the variable, it turns the text half blue and gives me a syntax error. Last one was something along the lines of:
%2 !
... ^ Syntax Error

So I'm seeing the quotation marks when it gets something, and the %1 %2. Along with the Syntax errors in trying to save the @Thanks Variable.

Suggestions?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Jan 10, 2003 6:38 pm   
 
Skip the variable, just put your responses in the trigger.
#TRIGGER {^(%w) gives you (*)} {#IF (%ismember("%2", @GiveEmotes)) {emote to %1} {#CASE %random(1, 2) {tell %1 Thank you for %2!} {tell %1 Wow! %2! Thanks!}}}

LightBulb
Senior Member
Reply with quote
Madamegato
Beginner


Joined: 27 Nov 2002
Posts: 27
Location: USA

PostPosted: Sat Jan 11, 2003 4:51 am   
 
That didn't fly either. I cut and pasted it in, changed the thanks to the ones I had, and it still gives the thanks regardless. Here's what I have:
trigger: ^(%w) gives you (*)
value: #IF (%ismember( "%2", @GiveEmotes)) {
chuckle %1
say Thanks!
} {#CASE (%random( 1, 2)) {{tell %1 %2! Thank you!} {tell %1 Your heart is in the right place and your gift of %2 proves it.}}

@GiveEmotes are set up as:
a BIG high five|a round of applause|a hug

The @GiveEmotes is outside of my trigger class. The odd thing is, if I take the ^ from the front of the trigger to test it myself, and I put in:
'tell wynd Wynd gives you a hug', since it sends that to the mud twice, once as stated above, the other as 'You tell Wynd 'Wynd gives you a hug' I get the following response:

You chuckle at yourself
You say 'Thanks'
(this is at the initial input)
AND

You tell Wynd 'a hug! Thanks!'
(this happens when it sees the second)

When I put the ^ back in front of the %w, it just gives the thanks. (And yes, I do have someone testing it, so it's not myself trying to.)

Any other thoughts?
-W.
Reply with quote
Emit
Magician


Joined: 24 Feb 2001
Posts: 342
Location: USA

PostPosted: Sat Jan 11, 2003 5:52 am   
 
i'm thinking, punctuation.
your %ismember might be misfiring because the real message ends in a "."
after your trigger goes off, %2 will be everything up till the end of the line.
You can see the difference in your test tell.
the first time it fired, on the command being sent to the mud, this is the pattern that was matched

Wynd gives you a hug

and that was matched correctly because "a hug" is a member of your list.
the second time it fired this is the pattern that matched

Wynd gives you a hug'

and it didn't recognize that as a social because "a hug'" isn't a member of your list.

try this:
#var GiveEmotes {a BIG high five.|a round of applause.|a hug.}

but with whatever punctuation those socials usually end in. of course i could be way off, but this seems likely to me
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Jan 11, 2003 6:25 am   
 
Or include the punctuation in the trigger pattern.
trigger: ^(%w) gives you (*).
value: #IF (%ismember( "%2", @GiveEmotes)) {
chuckle %1
say Thanks!
} {#CASE (%random( 1, 2)) {{tell %1 %2! Thank you!} {tell %1 Your heart is in the right place and your gift of %2 proves it.}}

LightBulb
Senior Member
Reply with quote
Madamegato
Beginner


Joined: 27 Nov 2002
Posts: 27
Location: USA

PostPosted: Sat Jan 11, 2003 6:34 am   
 
You all are so awesome. I would hug you each in real life if I could!

*hug* *hug* *hug*

I don't know what I'd do if it weren't for you all...well...I guess I do. I would be rping and not botting! *chuckle*

Thanks! It's working like a charm with the punctuation included.
-M.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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