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


Joined: 09 Oct 2003
Posts: 40

PostPosted: Tue Sep 28, 2004 11:36 pm   

Alias and parameters simple question
 
I was trying to make an alias that when I type glist pop would populate a list of all the roomids from every zone in my map. When I didn't type glist it would echo the populated list to the screen.

Every thing was going fine and dandy tell I tried to make the if statement check to see if pop is in the first parameter.

alias
name: glist
commands:
#if ("%1"=pop) {#echo hi}

Now this works.
could some one explain to me why that works and nothing else I tried seemed to work at all?
#var dummy ""
#var gotolist ""
#gauge pop "Populating List" {@dummy} {%numrooms} {0} {} {hi,red} {} {}
#loop %numrooms {
#add dummy 1
#if (%null( %roomid( %i))=0) {
#additem gotolist %roomid( %i)
#echo ~>~> added room %i as %roomid( %i)
}
}
#unbutton pop
}
Is there an easier way to do this?
Also is there any difference between %numroom and %numrooms?

Phanku
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Sep 29, 2004 12:29 am   
 
How can we explain without knowing what else you tried? Presumably, everything else you tried didn't work because you had errors of one kind or another.

Yes, there's a difference between %numroom and %numrooms. %numrooms is a defined function when used with parentheses and might be recognized as a system variable without them. %numroom isn't defined or recognized either way.

You could eliminate the second #IF and just remove any blank item when you finish the loop. There won't be more than one, since #ADDITEM doesn't add duplicates.

#AL glist {
#IF ("%1" = pop) {#ECHO hi}
#VAR dummy 0
#VAR gotolist ""
#GAUGE pop "Populating List" {@dummy} {%numrooms()} {0} {} {hi,red} {} {}
#LOOP %numrooms() {
#ADD dummy 1
#ADDI gotolist {%roomid( %i)}
#ECHO ~>~> added room %i as %roomid( %i)
}
#UNB pop
#DELI gotolist {}
}

Don't know if there's an easier way or not.
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Phanku
Novice


Joined: 09 Oct 2003
Posts: 40

PostPosted: Wed Sep 29, 2004 2:57 am   
 
I had also tried
#if (%1="pop") {#echo hi}
#if ("%1"="pop") {#echo hi}
#if (%1=pop) {#echo hi}

Thanks for the help on the other stuff tho lightbulb, it helped alot.

Phanku
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Sep 29, 2004 3:13 am   
 
Why don't you start by replacing the #if line with simply "#ECHO %1" or "#ECHO %param(1)" and see what it actually contains. If screen space is at a premium or a trigger might be affected use #INPUT instead of #ECHO.

If your inputing from the command I don't see how any of the 4 would have any problems. While quotes on both would generally be reccommended you have a lot of control over the contents of %1 and can get away with no quotes at all. So I have to assume that the alias is actually being called from another script or may have some simple issue like the case, meaning you did "glist POP" or "glist Pop" at the command line.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Phanku
Novice


Joined: 09 Oct 2003
Posts: 40

PostPosted: Wed Sep 29, 2004 3:54 am   
 
Okay maybe i'm tired or something cause now every if statment i have writen on this thread is working.. Shrug go figure.

Maybe it was just a glitch. who knows.

Thanks tho for that help vijilante and Lightbulb.
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