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
static1418
Newbie


Joined: 15 Aug 2002
Posts: 2
Location: USA

PostPosted: Thu Aug 15, 2002 6:26 am   

Nested IFS and A better way for #GAG?
 
Hello,

I have two things here. First off how do I convert this into a nested if. Been trying but too many Syntax errors and I cant figure out where it is wrong. Here is the version that is not nested:

#var hitpoints %1
#if (%1 <= 10) {#cw 576}
#if (%1 >= 11 & %1 <= 79) {#cw 524}
#if (%1 >= 80 & %1 <= 149) {#cw 12}
#if (%1 >= 150 & %1 <= 219) {#cw 14}
#if (%1 >= 220 & %1 <= 280) {#cw 10}
#if (%1 >= 281 & %1 <= 499) {#cw 9}
#if (%1 >= 500) {#cw 159}

Next question is... Is there a better way to do this:

#alias drin {
buy liqueur
#gag
drink liqueur
#gag
kill @target
#gag
drop glass
#gag
hp
#gag
}

I dont like to be spammed by the commands but I cannot turn off the ECHO COMMANDS options becuase I like to see most of the commands just not drinking becuase its done so often.

Thanks,
Stats
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Thu Aug 15, 2002 6:45 am   
 
#var hitpoints %1
#if (%1 <= 10) {#cw 576} {#if (%1 >= 11 & %1 <= 79) {#cw 524} {#if (%1 >= 80 & %1 <= 149) {#cw 12} {#if (%1 >= 150 & %1 <= 219) {#cw 14} {#if (%1 >= 220 & %1 <= 280) {#cw 10} {#if (%1 >= 281 & %1 <= 499) {#cw 9} {#if (%1 >= 500) {#cw 159}}}}}}}


You want to #SEND the command then:

#alias drin {
#SEND {buy liqueur}
#SEND {drink liqueur}
#SEND {kill @target}
#SEND {drop glass}
#SEND {hp}
}



Ton Diening
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Aug 15, 2002 6:19 pm   
 
There's no need to nest the #IF statements since you've included the precise range for each. However, the most common syntax error in nested code is mismatched delimiters (), {}, etc. That is, having more on the left side (, {, etc. than on the right side ), }, etc. or vice-versa.

LightBulb
Senior Member
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Thu Aug 15, 2002 11:27 pm   
 
If you don't want to see commands, perhaps check out #SEND, which SHOULD send the subsequent text directly to the mud without posting it to the window as well.

li'l shmoe of Dragon's Gate MUD
Reply with quote
static1418
Newbie


Joined: 15 Aug 2002
Posts: 2
Location: USA

PostPosted: Fri Aug 16, 2002 8:35 am   
 
Thanks for the help guys!

I would have thought that nesting the #IFs would have made it more efficient so that it wouldnt have to test each and every line but it looks like it still tests the whole thing.

Once again guys thanks a bunch for the help.
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