|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Sat Aug 19, 2006 3:48 am
My question about variable |
Is there a possible way to execute commands stored in variable. I have a variable like #va tmp {e;s;n;e;s;e;w;s;n;e}.I want to execute tmp like alias.
Thx! |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Aug 19, 2006 5:05 am |
You can use an alias? Alternatively, you can use a Path. Paths use a different format for the directions, though, like so:
n = North
s = South
e = East
w = West
h = Northwest
j = Northeast
k = Southwest
l = Southeast
2esj5h
Also, to activate a path you use the path character (period by default). You can do it by content (.2esj5h) or by name (.tmp) |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Sat Aug 19, 2006 8:43 am |
Thanks
But let me show you the trigger below
#TRIGGER {^Zugg tells you (*)} {#EXEC %1}
if Zugg tells you n;e;s;w
It can't be executed.It seems that #exec can only take single argument. |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sat Aug 19, 2006 8:14 pm |
I wouldn't even bother with #EXECUTE in this instance.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Sun Aug 20, 2006 12:40 am |
The reason why i ask such a question is because that I stored all the information especially the path to arrive at the place where the mob is in a file MOB.TXT.
The file is arranged like below
MobName GotoFromMyHome Return OtherAttribute
Killer1 e;ne;e w;sw;w 1
Killer2 w;nw;w e;se;e 2
Killer3 n;n;e w;s;s 2
othermob ......
.
.
.
.
.
Now I use the command #file 1 Mob.txt,and then use the function %grep(1,^Killer) to find all the Mob with the name killer,and use the OtherAttribute to decide whether the mob is to be killed and finally I decide to goto where the Mob is from my home. How to use the record field GotoFromMyHome?
Attention:the GotoFromMyHome contain many commands and saved in variable now, so #exec won't work.
I have try all command in Zmud, Only "Forall" and "DDE" command seems to be useful.
#va GotoFromMyHome {e;ne;e};
The variable can be executed in this way------ #forall %replace(@GotoFromMyHome,;,|) {%i}
Or #dde zmud zmud <@GotoFromMyHome>
The first way doesn't work good enough, because if #va GotoFromMyHome {e;#alias triggeraction {n;e;s};e},it wont work;
The second way to treat variable is what i want, but when you switch window in Zmud, the #DDE command always be sent to current activated window. |
|
|
|
Qiz Novice
Joined: 14 Aug 2006 Posts: 34 Location: Sweden
|
Posted: Sun Aug 20, 2006 3:03 am Re: My question about variable |
john_y wrote: |
Is there a possible way to execute commands stored in variable. I have a variable like #va tmp {e;s;n;e;s;e;w;s;n;e}.I want to execute tmp like alias.
Thx! |
But why store it in a variable and not an alias?
#ALIAS tmp "e;s;e;w"
tmp will then execute as
e
s
e
w
And when retrieving it from a file, why store it at all, as variable or alias and not just execute it, unless you need it for further processing? |
|
Last edited by Qiz on Sun Aug 20, 2006 3:04 am; edited 1 time in total |
|
|
|
Vitae Enchanter
Joined: 17 Jun 2005 Posts: 673 Location: New York
|
Posted: Sun Aug 20, 2006 3:03 am |
maybe prepend the 2nd way with the window name?
:john_y:#dde zmud zmud <@GotoFromMyHome> |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Sun Aug 20, 2006 4:11 am Re: My question about variable |
Qiz wrote: |
john_y wrote: |
Is there a possible way to execute commands stored in variable. I have a variable like #va tmp {e;s;n;e;s;e;w;s;n;e}.I want to execute tmp like alias.
Thx! |
But why store it in a variable and not an alias?
#ALIAS tmp "e;s;e;w"
tmp will then execute as
e
s
e
w
And when retrieving it from a file, why store it at all, as variable or alias and not just execute it, unless you need it for further processing? |
Why store it in a variable, because it is fetched from a file Mob.txt by the function %grep().
Why not just execute it , because the file Mob.txt is a data file, not a script. Think of the format of the Mob.txt. |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Sun Aug 20, 2006 4:36 am |
Vitae wrote: |
maybe prepend the 2nd way with the window name?
:john_y:#dde zmud zmud <@GotoFromMyHome> |
I have tested.
It doesn't work. |
|
|
|
Qiz Novice
Joined: 14 Aug 2006 Posts: 34 Location: Sweden
|
Posted: Sun Aug 20, 2006 12:52 pm Re: My question about variable |
john_y wrote: |
Why store it in a variable, because it is fetched from a file Mob.txt by the function %grep(). |
Perhaps ditch grep and parse each path
With Mob.txt containing the program below parses the first path (second path would of course be done just the same way, and in between you can do whatever else is needed)
Killer1 e;ne;e w;sw;w 1
Killer2 w;nw;w e;se;e 2
Killer3 n;n;e w;s;s 2
Killer1 e;s;e w;n;w 1
the code below would send
e
ne
e
e
s
e
by parsing the first path on each line matching containing Killer1
#FILE 2 "Mob.txt"
#SHOW File open
#VAR lines %filesize( 2)
#SHOW lines: @lines
#LOOP @lines {
#VAR path1 0
#VAR path2 0
#VAR flag 0
#VAR nextDir 0
#VAR pathPos 1
#SHOW Line: %i
#VAR currentLine %read( 2)
#SHOW currentLine: @currentLine
#IF (%match( @currentLine, "Killer1%s(*)%s(*)%s(%d)", path1, path2, flag)) {
nextDir = %word( @path1, @pathPos, ";")
#WHILE (@nextDir != "") {
#SHOW In while...
@nextDir
#ADD pathPos 1
nextDir = %word( @path1, @pathPos, ";")
}
}
}
#CLOSE 2 |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Mon Aug 21, 2006 1:55 pm |
Thanks for your reply Qiz.
I think the while loop can be replaced with #forall %replace(@path1,;,|) {%i}.
----To reach the killer1 from home, I must go East, take a bus, and wait a period of time. After the bus reachs the destination, i should resume to type "out ;east". Like this------"e;take bus;wait a period of time;out;e". The question is i dunno known how long will it take to reach the bus destination. I was supposed to type "out;e" when mud system tell me that "The Bus reach the destination, you can get out". So I wrote the commands below which integrated with a trigger as the GotoFromHome field for Killer1 and saved it to a file .
Killer1 "e;take bus;#trigger {^The bus reach the destination, you can get out} {out;e}" "......" "1"
you see. the way you make didn't work here.
BTW I am playing chinese muds, so forgive me for my rusty english if i didn't make my questions clear because it is not my native language.
If you are interested in this question,you may try #DDE zmud zmud {@path1}. And you can put @path1 in a macro key #key F1 @path1 and stroke F1. It does work supprisingly.
I think my question could be concluded with such a question.
How to execute script saved in a variable. You wrote a program and saved it in a variable, but you can't execute it. |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Mon Aug 21, 2006 2:27 pm |
He wrote a program intending it to be saved in an alias not in a variable.
|
|
_________________ Taz :) |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Mon Aug 21, 2006 2:42 pm |
Taz wrote: |
He wrote a program intending it to be saved in an alias not in a variable. |
If i hadn't saved it in a file but a alias, I will have to write 2 aliases NPCGOTO and NPCBACK for each npc. In my mud, there are about 5 thousand npcs and some of them with the same name. I didn't known how to arrange there aliases and it will be very hard to mordify other npc information should be saved at the same time. |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Mon Aug 21, 2006 2:49 pm |
May anyone share some information with me about how to reach a npc and get the information about this npc in your mud.
Does everyone use map to calculate the path to go?
Does everyone use database?
The 2 things above i am quit unfamiliar. |
|
|
|
Qiz Novice
Joined: 14 Aug 2006 Posts: 34 Location: Sweden
|
Posted: Mon Aug 21, 2006 11:27 pm |
john_y wrote: |
Taz wrote: |
He wrote a program intending it to be saved in an alias not in a variable. |
If i hadn't saved it in a file but a alias, I will have to write 2 aliases NPCGOTO and NPCBACK for each npc. In my mud, there are about 5 thousand npcs and some of them with the same name. I didn't known how to arrange there aliases and it will be very hard to mordify other npc information should be saved at the same time. |
Yup that program was to be stored in an alias. I wrote it the way I did to exemplify the parsing process. However, with one minor modification you can get to every mob stored in the file.
at top of the code I wrote, insert:
#VAR findInFile %1
Then in the line which previously looked like
#IF (%match( @currentLine, "Killer1%s(*)%s(*)%s(%d)", path1, path2, flag)) {
make it be:
#IF (%match( @currentLine, "@findInFile%s(*)%s(*)%s(%d)", path1, path2, flag)) {
And then you can use it to get to any mob you like
gotoMob killer1
gotoMob killer2
and so on.
Combined with triggers as you suggested should do the trick. However I'd create and keep those triggers in zMud, not in the file. Then just use #T+ <name> and #T- <name> to toggle each on and off when you need it. |
|
|
|
Qiz Novice
Joined: 14 Aug 2006 Posts: 34 Location: Sweden
|
Posted: Mon Aug 21, 2006 11:34 pm |
john_y wrote: |
May anyone share some information with me about how to reach a npc and get the information about this npc in your mud.
Does everyone use map to calculate the path to go?
Does everyone use database?
The 2 things above i am quit unfamiliar. |
I've never used map or path so I'm no help with those. If I were to do what you are, I'd most defintely have a look at those. There has to be some way to record a path. If there isn't you can easily build your own path recorder with #ONINPUT
on variable to store the path
#VAR pathIs ""
And as long as you don't do anything but walk where you should (such as talk, chat...) one oninput trigger is enough
#ONINPUT {*} {#ADD pathIs %1; #ADD pathIs ~;} |
|
|
|
john_y Newbie
Joined: 19 Aug 2006 Posts: 9
|
Posted: Wed Aug 23, 2006 1:12 am |
Qiz wrote: |
Combined with triggers as you suggested should do the trick. However I'd create and keep those triggers in zMud, not in the file. Then just use #T+ <name> and #T- <name> to toggle each on and off when you need it. |
Yes, I keep those triggers in Zmud, But keep the command #t+ <name> in file.
So i wrote ------Killer1 "e;take bus;#t+ <TakeBusTrigger>" "......" "1"
And in you loop
#WHILE (@nextDir != "") {
#SHOW In while...
@nextDir
#ADD pathPos 1
nextDir = %word( @path1, @pathPos, ";")
}
When @nextDir was #t+ <TakeBusTrigger>; It fails; The mud server doesn't recognized #t+ <TakeBusTrigger>. Only Zmud can execute it. |
|
|
|
|
|