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


Joined: 05 Jun 2004
Posts: 37
Location: USA

PostPosted: Sat Jun 05, 2004 6:49 pm   

#var editing
 
I have made some scripts to clear all the immunities, resistances, and vulns on a mob and to then reapply a number of random imm/res/vuln back on to the mob. To cut down on the spam I get from flagging and the spam the rest of the staff sees from wiznet secure, I can execute this command to remove all the immunities.

flag mob *mob imm - magic poison holy energy disease drowning illusion

By changing the - to +, I can add multiple damn types back. How can I change the below script to run x number of times with the immune var getting update, not overwritten, each time the script runs. Ex: first run through returns holy, second run returns acid. The immune var at the end of the second run is "holy acid."

(Note, the @ spec char has been changed to * because of the color code system on my mud)

#var mob %1
#var number %random( 1, 13)
#var immune %item( *immlist, *number)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jun 06, 2004 2:09 am   
 
Clear the variable before starting.
#VAR immune {}
Then just check to see if there's anything in it each time you repeat.
#IF %len( *immune) {#VAR immune {*immune %item( *immlist, *number)}} {#VAR immune {%item( *immlist, *number)}}

By the way, it's hard to think of a worse choice for your variable symbol than the general-purpose wildcard.
Reply with quote
turian
Novice


Joined: 05 Jun 2004
Posts: 37
Location: USA

PostPosted: Sun Jun 06, 2004 2:56 am   
 
Well, when I made it a * it was REAL late. I'll change it again. As for getting a for/next like statement to determine how many times it adds in nouns, what is the best way to do this?
Reply with quote
turian
Novice


Joined: 05 Jun 2004
Posts: 37
Location: USA

PostPosted: Sun Jun 06, 2004 3:01 am   
 
Oh and I was so rude! Thank you, LightBulb.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jun 06, 2004 11:52 am   
 
If you don't want duplication, the best method is to use a list rather than a string. #ADDITEM will automatically prevent duplicate entries and you can easily convert the list to a string when you are finished by replacing the |s with spaces.

If you just want to count how many times each immunity is used, a stringlist would still be a good idea but you would use the %additem function instead of the #ADDITEM command. The %countlist function will quickly provide the number of times each item exists in the list.

The reason * is a poor choice for variable symbol is that variables are frequently used in trigger patterns, so it's not a good idea to assign a symbol which already has another meaning assigned to it.
Reply with quote
turian
Novice


Joined: 05 Jun 2004
Posts: 37
Location: USA

PostPosted: Sat Jun 12, 2004 5:33 pm   
 
Well, getting closer to getting this thing finished. I've added an #until statement in, but it doesn't seem to want to work correctly. Here is where it stands now.

#var immune {}
#until {RI = 0} {$number %random( 1, 13) ; #IF %len( $immune) {#VAR immune {$immune %item( $immlist, $number)}} {#VAR immune {%item( $immlist, $number)} ; #add RI -1}}

RI is a varible set in an alias that determines how many Random Immunities I want the mob to have. It seems to just keep adding random immunes in there, completely igoring the #until statement. Is my #add in the wrong place or do I have a syntax error in there somewhere?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jun 13, 2004 3:08 am   
 
Did you mean?
#UNTIL {$RI = 0}
Reply with quote
turian
Novice


Joined: 05 Jun 2004
Posts: 37
Location: USA

PostPosted: Sun Jun 13, 2004 5:35 am   
 
Well, I'm getting very frustrated with getting this script to work correctly. Anyone interested in being brave and going over the entire thing and attempt to straighten it out?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sun Jun 13, 2004 5:59 pm   
 
Why did you ignore my question? You don't have to answer it, but it does answer your question.

RI is a string. It will never equal 0. If you meant a variable named RI, then you MUST put the variable symbol in front of the name! Otherwise, your loop will continue forever since the expression controlling it will always be false.
Reply with quote
turian
Novice


Joined: 05 Jun 2004
Posts: 37
Location: USA

PostPosted: Mon Jun 14, 2004 9:06 pm   
 
Didn't mean to not answer, my mistake. Yes, I did mean $RI and threw in that fix to no avail.
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