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
dantelestat
Beginner


Joined: 30 Jul 2001
Posts: 20

PostPosted: Thu Jan 24, 2002 12:45 am   

user defined functions
 
I never tried this before but i need to make a function and the #function command is not working at all. what could be the cause? This is what I am trying to implement:
#fu go {#if (@wield=="crossbow") {dismount;#temp {You have regained your balance.} {go %1}} {go %1}}

nothing happens if I type that in the command line and I don't see a function window like there is for aliases/triggers/variables/etc and if I type #fu alone i don't get a list of the function I just made. I was expecting that would list all user defined functions so I am a bit confused.
Reply with quote
Palomar
Apprentice


Joined: 11 Oct 2000
Posts: 138
Location: Portugal

PostPosted: Thu Jan 24, 2002 1:20 am   
 
1. You can edit a function as you edit variables.

2. What you want is an alias (that can execute commands like #IF) and not a function (that evaluates an expression + returns a result).

Palomar
Reply with quote
iljhar
GURU


Joined: 10 Oct 2000
Posts: 1116
Location: USA

PostPosted: Thu Jan 24, 2002 1:45 am   
 
Like Palomar said, this could probably be set up as an alias instead. Be careful, you're going to create a loop if you do it the way you're doing. Try this:

#alias go {#if (@wield="crossbow") {dismount;#temp {You have regained your balance.} {~go %1}} {~go %1}}

Iljhar
Reply with quote
dantelestat
Beginner


Joined: 30 Jul 2001
Posts: 20

PostPosted: Thu Jan 24, 2002 4:01 am   
 
no you don't understand perhaps it is my fault. I was looking to make go a function because it must take the argument of the building name. This is a function which lets me enter buildings so i want to type go Louvre for example and let "Louvre" be the argument passed in.
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Thu Jan 24, 2002 4:05 am   
 
Yes, aliases can receive arguments to. When you call an alias, you pass arguments to it by simply writting them after the alias name. Suppose you have an alias called test, then:
test arg1 arg2

passes arg1 and arg2 as arguments. You can access the arguments inside the alias with %1, %2, etc.

Kjata
Reply with quote
dantelestat
Beginner


Joined: 30 Jul 2001
Posts: 20

PostPosted: Thu Jan 24, 2002 4:07 am   
 
my apologies it did in fact work as an alias i had no idea you could pass variables into aliases in the form of %1 %2 etc. thanks for the help
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Jan 25, 2002 3:06 am   
 
quote:

my apologies it did in fact work as an alias i had no idea you could pass variables into aliases in the form of %1 %2 etc. thanks for the help



User-defined functions can't take advantage of the much more direct (if not powerful) #command procedures.

li'l shmoe of Dragon's Gate MUD
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