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
Lain
Novice


Joined: 26 Oct 2001
Posts: 38

PostPosted: Tue Apr 08, 2003 2:39 am   

Targetting specifically
 
Could someone please help me with the following:

I wish to make an alias which would target an NPC by storing its name into a variable for further use. Like,

#ALIAS {target} {#VAR target %1}

Which I could then use with other aliases that would automatically add the name from the variable into the command, but only, if no argument is given after the alias. Like,

#ALIAS {stab} {#VAR target %1 "Only if argument given";"use "backstab @target" if no argument is given, otherwise use "backstab %1""}

So,

target dwarf
stab

Would give,
backstab dwarf

Whereas,
target dwarf
stab elf

Would give,
backstab elf
And store "elf" in a variable for further commands.

Also, sometimes I would need to be specific when targetting, so if say - an angry dwarf and a happy dwarf were standing in a tavern - and I wished to target the angry dwarf, I would need to "target angry dwarf" and have "angry dwarf" stored in the variable so that when typing "stab" I would not backstab the other dwarf by accident, I'm not certain if this is what should already happen, as when I first tried it out the variable would only store the word "angry".

Thanks,

Lain
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue Apr 08, 2003 2:53 am   
 
Surround whatever you're assigning to the variable with double-quotes or curly braces. This ensures that ZMud treats whatever is contained by the braces as one entity.

li'l shmoe of Dragon's Gate MUD
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Tue Apr 08, 2003 3:13 am   
 
I would say remove the target alias entirely, and do the whole thing with just the stab alias. In either case here is the short and dirty.

#AL stab {#IF ("%-1") {#VAR target {%-1}};#IF (@target) {backstab @target} {#ECHO You have no target currently specified.}}
Reply with quote
itsmarty
Novice


Joined: 29 Jan 2002
Posts: 37
Location: USA

PostPosted: Tue Apr 08, 2003 2:04 pm   
 
quote:
target dwarf
stab
Would give,
backstab dwarf

Whereas,
target dwarf
stab elf
Would give,
backstab elf
And store "elf" in a variable for further commands.


I suppose you could have a "target" alias in case you wanted to set the target without using one of the verbs, but it shouldn't be needed for operation. The verbs themselves should be able to either set the @target variable or use it, depending on whether you give an argument.

For instance, two aliases: quaff and munch.

munch
#IF ("%1") {#VAR target %1;eat %1} {eat @target}

quaff
#IF ("%1") {#VAR target %1;drink %1} {drink @target}

If @target == sandwich, entering munch on the command line sends "eat sandwich" and quaff by itself sends "drink sandwich". Entering quaff ale sends "drink ale" and sets @target = ale. Obviously you'd want to use two verbs that work together :)

This doesn't meet your two-word target requirement, but it could be added easily by someone who's not up past their bedtime.

Martin
Reply with quote
Lain
Novice


Joined: 26 Oct 2001
Posts: 38

PostPosted: Tue Apr 08, 2003 5:41 pm   
 
Thanks for your help,

I've added a target alias and used Vijilante's idea of targeting and attacking with one alias, I can then target if I don't wish to initiate combat with backstab.

Lain
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