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
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Thu May 17, 2007 12:14 pm   

Some variable/triggers help please!
 
say i have 3 variables,
#VAR fruit {apple|banana|pear|mango}
#VAR animal {dog|cat|donkey|monkey}
#VAR flower {rose|tulip}

how do i set it up such that when i walk into a room and see, "An Apple." i will do 'kill fruit'
or when i see 'Dog', to kill animal? etc...

thanks!
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Thu May 17, 2007 1:24 pm   
 
Try

Code:


#trigger {^{An|A} (%w).$} {#if (%ismember(%1,@fruit) or (%ismember(%1,@animal) or (%ismember(%1,@flower)) {kill %1} {#say That mob is not in any list, can't kill!}}



Its untested so it might contain mistakes with bracets here and there, but you get the general idea. It checks the given pattern if the item is in any of those lists and if it is, it sends "kill item" (item being the %1 in trigger pattern), and if not, it will send you a #say, saying why not.


I hope it works.


EDIT: After I wrote it, I figured that you might start to have problems with "kill" executing several times at once in case there are mobs either from one list or one of each or whatever in a room you enter. If its a problem, I need to have more mud output info, though. If its not, I believe the trigger I gave you should most likely work.
Prog
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu May 17, 2007 2:57 pm   
 
Prognoi's on the right track, but since you specifically stated that the name of the variable be used instead of the same of the item, it might be best to separate that into more than one #if:

Code:
#trigger {^{An|A} (%w).$} {#if %ismember(%1,@fruit) {kill fruit} {#if %ismember(%1,@animal) {kill animal} {#if %ismember(%1,@flower) {kill flower} {#say That mob is not in any list, can't kill!}}}}


Since an item will probably never be on more than one list, you don't really need to nest the statements to make the script a bit more readable, but it doesn't let you do something if the item never matches.
Reply with quote
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Thu May 17, 2007 6:26 pm   
 
ok thanks.

what if, i walk into the room and see this:
An Apple.
A Dog.


is there anyway to 'kill fruit', then 'kill animal' after fruit is dead?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu May 17, 2007 6:36 pm   
 
You could load them into a list using #additem or %additem (check the help for usage) instead of just sending the kill command. Then you have a trigger that fires on a message you recieve after the mobs in the room, or uses a short alarm like +0.5 to wait until the list's been populated, then use %pop to get an item and kill it. It'd look something like this, assuming you use the automapper:

#event onroomenter {moblist="";#alarm +0.5 {killsomething}
#trig #trigger {^{An|A} (%w).$} {#if %ismember(%1,@fruit) {#var moblist %additem(fruit,@moblist)};#if %ismember(%1,@animal) {#var moblist %additem(animal,@moblist)};#if %ismember(%1,@flower) {#var moblist %additem(flower,@moblist)}}
#alias killsomething {#if (@moblist) {kill %pop(@moblist} {#say all mobs dead!}}
#trig {(%w) dies.} {killsomething}
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Thu May 17, 2007 7:02 pm   
 
awesomely fast reply. thanks.. this makes sense. i'll try it out...
Reply with quote
Deurack
Newbie


Joined: 24 Oct 2005
Posts: 3

PostPosted: Sat May 19, 2007 11:33 am   I've been working on a similar problem, help?
 
What if you're trying to prioritize the order in which you kill the mobs in the room. For example, If I walk into a room and see:

A teddy bear guard is here, trying to act tough.
A porcelain servant is here, trying to clean up everything on the floor.

The Bear is agro, and the servant is not. I want to kill the bear first. I have been trying to accomplish this by creating triggers for the mobs in question to populate 2 different variables, @agro and @peaceful with the name of the mob using the #additem command like this...

Pattern: A porcelain servant is here, trying to clean up everything on the floor.
Value: #var peaceful %additem( "servant", @peaceful)

Then trying to use triggers containing #IF and %pop to prioritize which is killed first. I've had next to no success. I've been working on this for some time now and am basically out of ideas. How would you go about doing what I'm trying to do?

Thanks in advance for your time and attention.
_________________
Your Perceptions Determine Your Reality
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat May 19, 2007 12:59 pm   
 
Like all good problems, there are a couple of ways to do it. Some of them are slower to execute than others - two lists sounds like possibly the easiest way.

#var PriorityMobs {bear|haddock|clam}
#trig {whatever} {#if (%ismember(%1,@PriorityMobs) {#addkey RoomMobs Aggro %additem(%1,@RoomMobs.Aggro)} {#addkey RoomMobs Peaceful %additem(%1,@RoomMobs.Peaceful)}}
#alias killsomething {#if (@RoomMobs.Aggro) {kill %pop(@RoomMobs.Aggro)} {#if (@RoomMobs.Peaceful) {kill %pop(@RoomMobs.Peaceful)} {#say nothing to kill}}}

Also, small change to the script in the post above - this is a zMUD question so you need to use #alias onroomenter {} instead of #event onroomenter {}.
Reply with quote
Deurack
Newbie


Joined: 24 Oct 2005
Posts: 3

PostPosted: Sat May 19, 2007 7:10 pm   Wow, thanks!
 
Ok...now I need to go read the help files to know what all that means. Some of it I recognize and understand and some I dont, but I'll get it. Thanks again!
_________________
Your Perceptions Determine Your Reality
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