|
Kyote Novice
Joined: 13 Jan 2002 Posts: 36 Location: USA
|
Posted: Tue Aug 20, 2002 9:35 pm
stringlist help needed? |
On the mud I play you can use a command "finger" to see if a mob has repopped or not. I want to have the names of the various mobs in a stringlist;
#VAR moneymakerval {foreign|horror|coins|lepr}
then I want it to take the first name in this stringlist and finger it to see if it's there. If it is I get this response;
Mobname tells you 'Pull that again and I'm gonna kick your ass ..'
If it's there I want to gate to it, kill it, then move on to the next name in the list and do the same, till all the names have been gone through. Also, if the mob hasn't repopped it says;
They aren't here.
at which point I want it to remove the name from the list and go on to the next name in the stringlist. Can someone show me how to do this properly? My experiments have either skipped names in the list or fingered the same name twice...
Any help would be appreciated.
Kyote |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Tue Aug 20, 2002 10:00 pm |
#ALIAS autofinger {#IF (@index > %numitems(@moneymakerval)) {#SAY Finished} {#TEMP {{tells you 'Pull that again and I'm gonna kick your ass|They aren't here.}} {#IF (%trigger =~ "Pull that again") {gate %item(@moneymakerval, @index);kill %item(@moneymakerval, @index);#TEMP {is DEAD!!!} {#ADD index 1;autofinger}} {#ADD index 1;autofinger}};finger %item(@moneymakerval, @index)}}
You need to reset the value of @index to 1 before calling the alias to start the process.
Kjata |
|
|
|
Kyote Novice
Joined: 13 Jan 2002 Posts: 36 Location: USA
|
Posted: Tue Aug 20, 2002 11:02 pm |
Thanks Kjata. But I'm having trouble understanding this... I don't suppose you or someone else could explain what this does step by step could you?
Kyote |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Aug 21, 2002 12:12 am |
Sure, no problem.
It all consists of one alias: autofinger. Upon callind this alias, it will first determine if the variable @index, which tracks at which item in the @moneymakerval stringlist we current are, is already bigger than the number of items in @moneymakerval. If it is, this means we have finished going through the list.
If we have not finished, it then proceeds to create a temporary trigger. This trigger is deleted once it fires. The temporary trigger will look for one of two texts: either "tells you 'Pull that again and I'm gonna kick your ass" or "They aren't here." These two correspond to the possible respondes from the finger command. After creating this trigger it proceeds to perform a finger on the next item in the list (which is determined by @index)
Now, after performing the finger, the temporary trigger will fire (either because the mov is there, or because it isn't.) When it fires, it checks to see if the line that fired the trigger matches "Pull that again". If it matches this, it means that the trigger fired because the mob is there and then it proceeds to gate to the mob and kill it. Now, because you cannot go on to finger the next mob until you have finished killing this one, the trigger creates another temporary trigger that fires on "is DEAD!!!" (this, of course, should be changed to something that matches your MUD output when you have killed a mob.) This second temporary trigger adds one to @index (so that we move on to the next item in the list) and calls the autofinger alias again. If the line that fired the first temporary trigger does not maych "Pull that again", it means that the mob wasn't found. When the mob isn't there, it proceeds to add one to @index and call autofinger again.
Kjata |
|
|
|
Kyote Novice
Joined: 13 Jan 2002 Posts: 36 Location: USA
|
Posted: Wed Aug 21, 2002 4:49 pm |
Thanks ALOT Kjata. I understand how it works now. But whats this line, or rather, %trigger represent? I couldn't find it in the help files.
(%trigger =~ "Pull that again"
Kyote |
|
|
|
Kyote Novice
Joined: 13 Jan 2002 Posts: 36 Location: USA
|
Posted: Wed Aug 21, 2002 5:25 pm |
I have a problem. I changed a few things and here's what I get..
-- TICK!!
finger foreign
They aren't here.
finger horror
finger coins
finger lepr
Finished
6336/6336hp 5594/5641mn 4820/4820mv 950
The hunting horror tells you 'Pull that again and I'm gonna kick your ass ..'
6336/6336hp 5594/5641mn 4820/4820mv 950
They aren't here.
6336/6336hp 5594/5641mn 4820/4820mv 950
The leprechaun tells you 'Pull that again and I'm gonna kick your ass ..'
And here is what I have as my trigger and alias. I have a macro set to activate my ticker class folder.
#CLASS {Ticker} {disable}
#TRIGGER {-- TICK!!} {#va index 1;autofinger}
#CLASS 0
#ALIAS autofinger {#IF (@index > %numitems( @moneymakerval)) { #SAY Finished} {#TEMP {{tells you 'Pull that again and I'm gonna kick your ass|They aren't here.}} {#IF (%trigger =~ "Pull that again") {q1 %item( @moneymakerval, @index);#TEMP {{is DEAD!!!}} {#ADD index 1;autofinger}} {#ADD index 1;autofinger}};finger %item( @moneymakerval, @index)}}
Could you tell me what I'm doing wrong?
Kyote |
|
|
|
Kjata GURU
Joined: 10 Oct 2000 Posts: 4379 Location: USA
|
Posted: Wed Aug 21, 2002 7:55 pm |
The problem is that zMUD tries to match any newly created trigger agaisnt the last line recived. When you got the "They aren't here" message, the alias was called again, and a new temporary trigger was created, but this trigger looked at the last line ("They aren't here") and fired immediately. This continued until it finished going through the list.
The fix is to add a small delay (1 second) for when you received "They aren't here":
#ALIAS autofinger {#IF (@index > %numitems(@moneymakerval)) {#SAY Finished} {#TEMP {{tells you 'Pull that again and I'm gonna kick your ass|They aren't here.}} {#IF (%trigger =~ "Pull that again") {q1 %item(@moneymakerval, @index);#TEMP {is DEAD!!!} {#ADD index 1;autofinger}} {#ALARM {+1} {#ADD index 1;autofinger}}};finger %item(@moneymakerval, @index)}}
Kjata |
|
|
|
Kyote Novice
Joined: 13 Jan 2002 Posts: 36 Location: USA
|
Posted: Wed Aug 21, 2002 9:52 pm |
That did it Kjata. Thanks alot Mate.
Kyote |
|
|
|
|
|