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
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Wed Jun 05, 2002 7:37 pm   

Question about %if
 
Hey gurus, I was just wondering if there is max number of %if's you can out in a script before it A)cant process it anymore or B)becomes reduntant.

Take this script for example:
#ALIAS mlvl {level %1;hitroll %abs( %1+20);hitdice %if( %1=100, 40d300+5000)%if( %1=101, 40d302+5005)%if( %1=102, 40d304+5010)%if( %1=103, 41d306+5015)%if( %1=104, 41d308+5020)%if( %1=105, 42d310+5025)%if( %1=106, 42d312+5030)%if( %1=107, 43d314+5035)%if( %1=108, 43d316+5040)%if( %1=109, 44d318+5045)%if( %1=110, 45d320+5050)%if( %1=111, 45d321+5065)%if( %1=112, 45d322+5080)%if( %1=113, 46d323+5095)%if( %1=114, 46d324+5110)%if( %1=115, 47d325+5125)%if( %1=116, 47d326+5140)%if( %1=117, 48d327+5155)%if( %1=118, 48d328+5170)%if( %1=119, 49d329+5185)%if( %1=120, 50d330+5200)%if( %1=121, 50d331+5220)%if( %1=122, 50d332+5240)%if( %1=123, 51d333+5260)%if( %1=124, 51d334+5280)%if( %1=125, 52d335+5300)%if( %1=126, 52d336+5320)%if( %1=127, 53d337+5340)%if( %1=128, 53d338+5360)%if( %1=129, 54d339+5380)%if( %1=130, 55d340+5400)%if( %1=131, 55d341+5420)%if( %1=132, 55d342+5440)%if( %1=133, 56d343+5460)%if( %1=134, 56d344+5480)%if( %1=135, 57d345+5500)%if( %1=136, 57d346+5520)%if( %1=137, 58d347+5540)%if( %1=138, 58d348+5560)%if( %1=139, 59d349+5580)%if( %1=140, 60d350+5600);damdice %if( %1=100, 10d20+75)%if( %1=101, 10d20+76)%if( %1=102, 10d20+78)%if( %1=103, 10d20+79)%if( %1=104, 10d21+81)%if( %1=105, 10d21+82)%if( %1=106, 10d21+84)%if( %1=107, 11d21+85)%if( %1=108, 11d21+87)%if( %1=109, 11d22+89)%if( %1=110, 11d22+90)%if( %1=111, 11d22+90)%if( %1=112, 11d22+91)%if( %1=113, 11d22+91)%if( %1=114, 11d23+92)%if( %1=115, 11d23+92)%if( %1=116, 11d23+93)%if( %1=117, 12d23+93)%if( %1=118, 12d23+94)%if( %1=119, 12d24+94)%if( %1=120, 12d24+95)%if( %1=121, 12d24+95)%if( %1=122, 12d24+96)%if( %1=123, 12d24+96)%if( %1=124, 12d25+97)%if( %1=125, 12d25+97)%if( %1=126, 12d25+98)%if( %1=127, 13d25+98)%if( %1=128, 13d25+99)%if( %1=129, 13d26+99)%if( %1=130, 13d26+100)%if( %1=131, 13d26+102)%if( %1=132, 13d26+104)%if( %1=133, 13d27+106)%if( %1=134, 13d27+108)%if( %1=135, 13d27+110)%if( %1=136, 14d27+112)%if( %1=137, 14d27+114)%if( %1=138, 14d28+116)%if( %1=139, 14d28+118)%if( %1=140, 14d28+120)}

When building on a mud it gets pretty tedious to go look up a mobs lvl and copy and paste several things based on that lvl.So I made this script, which works just fine. But what I'm wondering is would it be plausable to add another 180 %if statements for both the hitdice and damdice commands(for a grand total of 440 if statements)? Also, anyone think there is a better solution to this?I'm all ears
Reply with quote
NiteTrip
Novice


Joined: 21 May 2002
Posts: 40
Location: Canada

PostPosted: Wed Jun 05, 2002 10:57 pm   
 
I am sure the is a much more efficient way to do this, based on the patterns of the IF's. However I have no idea what yer trying to do, explain a bit more what this script does, where it gets the data and we'll fix you up :)
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Jun 05, 2002 11:45 pm   
 
#CASE or %case is the better option. Since your current structure lends itself to %if, you would probably want to go with %case.

Syntax: %case(i,s1,s2,s3...)

You seem to start at 100 so you want:
hitdice %case(%eval(%1-99),40d300+5000, 40d302+5005, 40d304+5010, 41d306+5015, 41d308+5020, 42d310+5025, 42d312+5030, 43d314+5035, 43d316+5040, 44d318+5045, 45d320+5050, 45d321+5065, 45d322+5080, 46d323+5095, 46d324+5110, 47d325+5125, 47d326+5140, 48d327+5155, 48d328+5170, 49d329+5185, 50d330+5200, 50d331+5220, 50d332+5240, 51d333+5260, 51d334+5280, 52d335+5300, 52d336+5320, 53d337+5340, 53d338+5360, 54d339+5380, 55d340+5400, 55d341+5420, 55d342+5440, 56d343+5460, 56d344+5480, 57d345+5500, 57d346+5520, 58d347+5540, 58d348+5560, 59d349+5580, 60d350+5600);
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Thu Jun 06, 2002 12:17 am   
 
*thwap self* Thats a great suggestion Vij, thanks a bunch :)
Reply with quote
dacheeba
Adept


Joined: 29 Oct 2001
Posts: 250

PostPosted: Thu Jun 06, 2002 8:16 am   
 
Just wanted to let you guys know that its taking 215 parameter strings per command, and smiling!

Though I'll have to remember next time I use extremely long scripts like that, to turn off the 'Syntax check while typing' Option before editing
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