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
Belle Morte
Newbie


Joined: 08 Aug 2005
Posts: 3

PostPosted: Mon Aug 08, 2005 8:52 am   

Trigger issues - string variables
 
I'm kind of new to the whole string varible thing, in the past I've simply used dozens of triggers or none at all, so this is a bit confusing for me.

Anyway I want to set up a single trigger for multiple spells to be cast on others and so far I've managed to get the trigger to fire but it's not distinguishing between varibles. This is what I have...

pattern:
(%w) says '(x)'

value:
#var x {heal|refresh|santuary}
cas '(x)' (%1)

like I said the trigger fires, but for some reason it won't distinguish between heal refresh and santuary, it tries to cast the entire variable.
So if someone could explain to me how this works I'd be greatful.

Also, I'd much rather setup a trigger which activates when someone reports to me.

example:

Smith reports '10/135Hp 247/565Mana 15/384Move'

I would then like the trigger to cast exactly as many heals and refreshes need to bring these numbers up to max without wasting all my mana in the process by spam healing or refreshing. Also should one of the spells fail I would like it to try again without having to start completely over.

I've looked over the tutorials and while some of it makes sense a lot of it is very confusing so if anyone can help I'd really appreciate it.

Thanks.
Reply with quote
dedawgg
Beginner


Joined: 05 Aug 2005
Posts: 12

PostPosted: Mon Aug 08, 2005 9:46 am   
 
For the first part, I'd recommend looking up 'FORALL' in the help, it's very useful when dealing with string lists.

For the pattern, try using (%w) says '(%w)'

...and for the value:

#VAR spellList {heal|refresh|sanctuary}
#FORALL @spellList {#IF (%2 = %i) {cas %i %1}}

so....
%1 is the name of the character and %2 is what he/she says.

As for the second part, you should be able to work it out with expressions...use a pattern such as
(%w) reports '(%d)/%dHp %d/%dMana (%d)/%dMove'

You can either use something like #IF (%2<200) or divide the current hp from the maxhp to get a percentage. Using these principles should help you figure out how to recast.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Mon Aug 08, 2005 10:39 am   
 
For the first bit it looks like you might be after a slightly different solution to what was recommended.

I'm guessing you have

#var x {heal|refresh|santuary}

And when someone says, "heal" then you cast heal on them, same with the others.

What you need is
#TRIGGER {(%w) says ~'({@x})~'} {cas %2 %1}

Which matches any member of variable x and captures it as normal to %2.
Reply with quote
Belle Morte
Newbie


Joined: 08 Aug 2005
Posts: 3

PostPosted: Mon Aug 08, 2005 11:09 am   
 
Actually the first one worked perfectly though I do appreciate both replies thank you!

next question, what if the spell has two words? and the mud I'm on requires that for these spells the spell itself be surround by apostraphes for example

cas 'cure blind' smith

I tried adding apostrophes to the variable in the trigger, and to the spellList neither seems to work. Any suggestions?

Also is there a way to add a delay before the trigger fires again so that I don't get spammed requests? and I need to somehow incorporate ^ in the current trigger so I don't get idiots trying to make me waste mana.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Mon Aug 08, 2005 1:07 pm   
 
I'm not sure why you'd want to match everything then use a forall, it's creating additional overhead.

Anyways though, my example should work fine if the spell has two words
To use apostrophes then just encase the bit you want in ', and put a ^ at the start to stop people sending you tells.

so
#TRIGGER {^(%w) says ~'({@spellList})~'} {cas '%2' %1}

As an aside, it might be worth creating a safelist so that not anyone can make you cast.

So
#var friends {Guinn|BelleMorte|dedawgg}

then
#TRIGGER {^({@friends}) says ~'({@spellList})~'} {cas '%2' %1}

That way only the people you like can force you to do things.
Reply with quote
Guinn
Wizard


Joined: 03 Mar 2001
Posts: 1127
Location: London

PostPosted: Mon Aug 08, 2005 1:11 pm   
 
Sorry, I missed the alarm bit

#VAR spellspam {0}
#TRIGGER {^({@friends}) says ~'({@spellList})~'} {#if (@spellspam = 0) {cas '%2' %1;spellspam = 1;#alarm spellspam {+5} {spellspam = 0}}}

So when someone tries to make you cast anything it checks 'spellspam = 0'. If that's okay it'll cast and make spellspam = 1, then wait 5 seconds and reset it to 0, so you cast a max of once every 5 seconds. It's also only matches at the start of a line.
_________________
CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;)
Reply with quote
Belle Morte
Newbie


Joined: 08 Aug 2005
Posts: 3

PostPosted: Mon Aug 08, 2005 7:12 pm   
 
ok stupid question and then I promise to figure the rest of this out myself, but special characters are going to interfere with these arn't they??

e.g. ~ and ;
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