[PENNMUSH] Local Commands
Walker at M*U*S*H
walker at pennmush.org
Mon May 16 15:57:44 CDT 2005
I reccommend looking through the lecture logs at:
http://www.mushcode.net
(Unfortunately, it appears to be down at this moment, but it may go up
later today)
Also, the help files on the mush itself are quite extensive. I recommend
reading through them.
For converting a name into a player dbref, look at 'help pmatch'
For fetching attributes, look at: 'help xget'
Also, as you're only just beginning to learn to softcode, I recommend
training your mind to break this down into exactly what you need to do.
First in English.
Bad: When a person is fingered, I want to pemit the enactor their finger
information
Good: When a player types "+finger *", I want to do the following things.
1: Find out if the player name they type exists. If not, then pemit
that the player doesn't exist, and exit. Save the dbref of the 'victim'
for later use.
2: Send the following text:
A: A header
B: "NAME: " + name of victim
C: "SEX: " + the contents of Victim's "sex" attribute
D: "ORG: " + contents of victim's "Org" attribute
E: A footer.
Then, translate that into code:
1: Find out if the player name they type exists. If not, inform them and
exit.
We use @break here since it will stop execution of the action list if
not(pmatch(%0)) below returns true (the player does not exist)
@break not(pmatch(%0)) = @pemit %#= The player '%0' does not exist.
Save the dbref of the victim for later use, in a q-register.
@break not(setr(0,pmatch(%0))) = @pemit %#= The player '%0' does not
exist.
2: The victim's dbref is stored in the q-register "%q0" from step 1.
Send the following text:
@pemit %#= strcat()
A: A header
@pemit %#= strcat(u(header))
B: "NAME: " + name of victim
@pemit %#= strcat(u(header),%r,NAME: [name(%q0)]
C: "SEX: " + contents of victim's sex attribute
@pemit %# = strcat(u(header),%r,NAME: [name(%q0)],%r,SEX: [xget(%q0,sex)])
D: "ORG: " + contents of victim's "org" attribute
@pemit %# = strcat(u(header),%r,NAME: [name(%q0)],%r,SEX:
[xget(%q0,sex)],%r,ORG: [xget(%q0,org)])
E: A footer
@pemit %# = strcat(u(header),%r,NAME: [name(%q0)],%r,SEX:
[xget(%q0,sex)],%r,ORG: [xget(%q0,org)],%r,u(footer))
So now we chain 1+2 together:
@break not(setr(0,pmatch(%0))) = @pemit %#= The player '%0' does not
exist. ; @pemit %# = strcat(u(header),%r,NAME: [name(%q0)],%r,SEX:
[xget(%q0,sex)],%r,ORG: [xget(%q0,org)],%r,u(footer))
Set it on an attribute with the $-command "+finger *":
> @create Finger-Object
> &cmd-finger finger-object=$+finger *:@break not(setr(0,pmatch(%0))) =
@pemit %#= The player '%0' does not exist. ; @pemit %# =
strcat(u(header),%r,NAME: [name(%q0)],%r,SEX: [xget(%q0,sex)],%r,ORG:
[xget(%q0,org)],%r,u(footer))
Set a header and a footer:
> &header finger-object=center(name(%q0),30,-)
> &footer finger-object=center(mudname(),30,-)
You now have a functional +finger:
> +finger wakler
The player 'wakler' does not exist.
> +finger walker
------------Walker------------
NAME: Walker
SEX: male
ORG: The Bad Guys
-----------M*U*S*H------------
Softcoding is easier than you think, you just have to train yourself to
look at it in the right way. It may be different than my way, but hey,
it's worth a shot?
- Greg
Andrew Mackie-Mason wrote:
> I've been looking around those sites--thanks again, by the way--but I
> cannot figure out how to get attributes. Say I wanted a +finger
> command, where the caller could type +finger One, for example, or any
> other user. So far I have:
>
> &cmd-finger finger-object=$+finger *:@pemit %#=%0/name
>
> But this dosn't work. How can I get the user from the argument, and
> then get their name?
>
> Thanks, Andrew
>
> On 5/15/05, Andrew Mackie-Mason <drewmm at gmail.com> wrote:
>
>> Thanks!
>>
>> Andrew
>>
>> On 5/15/05, Gabe Stein <potterhead4 at comcast.net> wrote:
>>
>>> Hi,
>>>
>>> There are a lot of db's to get you started, such as Mush
>>> Warehouse (http://moosh.net) and MushCode (http://mushcode.com)
>>> that have a lot of global commands to help get you started.
>>>
>>> But to give you a pointer, basically what you're doing is giving
>>> something a command attribute. So you'd say:
>>>
>>> &cmd_who wholistobject=$+who:@dowhatever
>>>
>>> The $-symbol defines the command, so any attribute with a
>>> $-symbol as the first character will have the next thing be the
>>> command.
>>>
>>> Like I said, look around. Mushcode.com has a nice beginning
>>> programing tutorial, so enjoy.
>>>
>>>
>>>
>>>
>>> -Gabe
>>>
>>>
>>> On May 15, 2005, at 6:03 PM, Andrew Mackie-Mason wrote:
>>>
>>> Hello,
>>>
>>> I am new to PennMUSH, and creating MUSHes in general, so please
>>> bear with me. I would like help with creating local commands, for
>>> instance: +help, +who, +mail, etc.
>>>
>>> Thank you!
>>>
>>> Andrew _______________________________________________ Pennmush
>>> mailing list Pennmush at pennmush.org
>>> http://www.pennmush.org/mailman/listinfo/pennmush PennMUSH
>>> FAQ-o-matic! http://www.pennmush.org/cgi-penn/fom
>>>
>>>
>>
> _______________________________________________ Pennmush mailing list
> Pennmush at pennmush.org
> http://www.pennmush.org/mailman/listinfo/pennmush PennMUSH
> FAQ-o-matic! http://www.pennmush.org/cgi-penn/fom
>
More information about the Pennmush
mailing list