|
nduval Beginner
Joined: 06 Sep 2006 Posts: 10
|
Posted: Sat Apr 17, 2010 2:10 am
ZMud to CMud #alias |
I see that there was a change to the way aliases work with variables, but I don't quite get how to get around it. I had a stepper that worked liked this:
alias {walk} {step@stepnum;#math stepnum @stepnum +1}
then all my directions aliased as:
alias {step1} {e}
alias {step2} {w}
alias {step3} {s}
So, this worked in zmud, but now in cmud, if I step@stepnum it does 'step 1' with a space. Any quick and easy way to avoid that space? Or I guess, if there are only complicated methods, please explain to someone with very limited skills in such things. Much appreciated! |
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sat Apr 17, 2010 4:32 pm |
I would offer an alternative suggestion to the method you now use. Instead, why don't you create a string list. In each step of the string list, place a direction. And we'll be using one integer variable named step.
So, we have a string list, which we'll call _path_place1, and an int variable named step, and another named _curr_path
The walk alias will be designed as follows, in the script box we're going to have this:
Code: |
$_ispath=0
#IF (@_curr_path!=%-1) {
#say "You've changed paths."
_step=1
}
_curr_path = %-1
#switch (%-1="Monastery") {
$_path=@_path_place1
$_ispath=1
}
(%-1="Graveyard") {
$_path=@_path_place2
$_ispath=1
}
(%-1="City Square") {
$_path=@_path_place3
$_ispath=1
}
{#say "That is not a path"}
#IF ($_ispath) {
#IF (@_step=%numitems($_path) || @_step>%numitems($_path)) {
_step=1
#say Path finished
}
{
#send %item($_path, @_step)
#ADD _step 1
}
}
|
I haven't tested it, so it may not be exactly that. But something like that will give you all the functionality I presume you're looking for. You can make a new path by simply making another string list and feeding directions into it, and then create another step in the #SWITCH statement in order to access it.
Then your command will be as simple as:
walk City Square
as long as you keep typing that, it will continue along the path you have set, each step bringing the stringlist to the next direction. If you change it suddenly, mid-path, to:
walk Graveyard
it will reset step and begin from the beginning of the graveyard path |
|
|
|
nduval Beginner
Joined: 06 Sep 2006 Posts: 10
|
Posted: Sat Apr 17, 2010 4:43 pm |
Thanks for the reply Chamenas. Unfortunately that is way over my head =P I will try to make sense out of it. Is it just impossible to make a small change to my walker scripts to make them work as they used to in zmud? I don't get why the space goes in there. I've tried to use two variables, like @walk@stepnumber which creates no space, but then it won't call the alias, it just sends the text to the mud. So confusing...
|
|
|
|
chamenas Wizard
Joined: 26 Mar 2008 Posts: 1547
|
Posted: Sat Apr 17, 2010 5:27 pm |
Unfortunately, you'll have to wait for someone else to respond to that. I've never really played around with concating variable names. But, if I'm right about assuming what you're looking for, I can make a script for that ;-)
|
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Sat Apr 17, 2010 6:06 pm |
#ALIAS {walk} {%concat("step", @stepnum);#math stepnum (@stepnum + 1)}
>walk
step1
Sorry Ozzy, I don't understand you.
>walk
step2
Sorry Ozzy, I don't understand you.
this what your after? |
|
|
|
nduval Beginner
Joined: 06 Sep 2006 Posts: 10
|
Posted: Sat Apr 17, 2010 6:22 pm |
Yes =) Thank you!
|
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Sat Apr 17, 2010 6:37 pm |
#ALIAS {walk} {#exec step@{stepnum};#math stepnum (@stepnum + 1)}
if you want e, w and then s to be sent to the mud instead of step1, step2 and step3 |
|
_________________ Taz :) |
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Sat Apr 17, 2010 6:49 pm |
Putting the variable name in brackets was supposed to be the way it was done in zMUD to expand the variable contents and automatically(implicitly) concatenate it onto whatever surrounded it. It appears that in CMUD either step@stepnum step{@stepnum} and step@{stepnum} give step1, step2 etc but only when preceded by the #execute which also then interprets the following alias. Without the #execute as you noticed any of those attempts at implicit concat give step 1, step 2 etc and then no longer matches your alias.
I guess the most correct way in CMUD is to use an explicit concat rather than an implicit concat but of course remember that the rule with CMUD is that commands sent to the mud should not begin with an in built function like for instance %concat.
So the most correct version is to use Private's version but put #exec in front so:
#ALIAS {walk} {#exec %concat("step", @stepnum);#math stepnum (@stepnum + 1)}
If you wanted the result to be sent to the mud without firing as an alias then you would use the following instead:
#ALIAS {walk} {#send %concat("step", @stepnum);#math stepnum (@stepnum + 1)} |
|
_________________ Taz :)
Last edited by Taz on Sat Apr 17, 2010 7:00 pm; edited 1 time in total |
|
|
|
nduval Beginner
Joined: 06 Sep 2006 Posts: 10
|
Posted: Sat Apr 17, 2010 6:59 pm |
Thanks for the followup Taz, and also I think knowing of #execute will be very handy. I still have limited knowledge of such things, but that helps a great deal. Thanks everyone for your help!
|
|
|
|
Taz GURU
Joined: 28 Sep 2000 Posts: 1395 Location: United Kingdom
|
Posted: Sat Apr 17, 2010 7:02 pm |
I edited the follow up to be slightly more factual.
|
|
_________________ Taz :) |
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Sat Apr 17, 2010 7:48 pm |
and if you wanted it to send to the mud only if an alias don't exist...
Code: |
<alias name="walk" id="8423">
<value>$x = %concat( "step", @stepnum)
#IF (%alias( $x)) {
#SHOW {Alias exists for $x}
#EXECUTE $x
} {
#SHOW {No alias for $x}
#SEND $x
}
#MATH stepnum (@stepnum + 1)</value>
</alias>
|
>walk
Alias exists for step1
stepping 1
>walk
No alias for step2
step2
Unknown command. Please check the helpfiles.
>walk
Alias exists for step3
stepping 3
i added this as i remember having a lot of aliases that used "%concat("something ", @blah)", then later in zmud nothing had to be changed when i made a "something1" alias.
after 15 years using a client, it sure is tough learning so many differences all at once... |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Sun Apr 18, 2010 4:13 am |
The bad thing about it is that most of the "changes" aren't changes at all. Zmud was lax enough that you really didn't have to actually learn how to do things properly and naturally people learned the wrong way to do things (hehe, you're kind of a case in point, Ozzy).
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Private Adept
Joined: 10 Jan 2002 Posts: 264 Location: USA
|
Posted: Sun Apr 18, 2010 11:32 am |
what worked, worked well for many years... what else is there to say :P
|
|
|
|
|
|