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


Joined: 21 Jun 2005
Posts: 38

PostPosted: Sun Jan 18, 2009 11:35 pm   

Small q about stringlists and %random
 
To give an idea of what I'm trying to do, my char can "doublestab" to afflict with two of a range of toxins on each balance. What I'm trying to do is set up stringlists of commonly grouped afflictions and semi-automate my offense. Right now I have a bunch of singleuse aliases that {envenom dirk12345 with bleck|envenom dirk12345 with blook}

Quote:
#1 {%item(@kelpsoftlocktoxins,%random(1,5))}

This would be sent twice.

where

@kelpsoftlocktoxins is a stringlist of 5 or so toxins I want to be able to afflict with. {envenom dirk12345 with ether|envenom dirk12...)

I've been wracking my brains on it but I can't figure a way to ensure that the second toxin chose IS NOT the same as the first. Well, a friend showed me a way that I'm currently playing with but it's pretty messy. Basically storing the first in a variable and comparing the second to it before the game command is sent, rejecting it if it's the same and just using %random to keep trying for a non-match.

So, I'm wondering if anyone can think of a rather more elegant way of doing what I want to do?

Thanks if you can help guys.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Sun Jan 18, 2009 11:46 pm   
 
If you remake the list with your alias each time its easy

#ALIAS pd {
#VAR kelpsoftlocktoxins {ether|bleck|blook|..|..}
used=%item(@kelpsoftlocktoxins,%random(1,%numitems(@kelpsoftlocktoxins)))
envenom dirk12345 with @used
#DELITEM kelpsoftlocktoxins @used
used=%item(@kelpsoftlocktoxins,%random(1,%numitems(@kelpsoftlocktoxins)))
envenom dirk12345 with @used
}

that would allow you to resize the list on the fly without rewriting as well
_________________
Discord: Shalimarwildcat
Reply with quote
easal
Novice


Joined: 21 Jun 2005
Posts: 38

PostPosted: Sun Jan 18, 2009 11:48 pm   
 
Oh my... Yes, I like that very much!

Thank you very much Shalimar!
Reply with quote
easal
Novice


Joined: 21 Jun 2005
Posts: 38

PostPosted: Sun Jan 18, 2009 11:50 pm   
 
Bah, dp.
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Jan 18, 2009 11:50 pm   
 
TempRnd=%random(1,5)
#LOOP 2 {envenom dirk12345 %word(%item(@kelpsoftlocktoxins,@TempRnd),%i,"--")}

Then store you list in the form
venom1--venom2|ether--something that|goes well--with ether|venom1--venom5|I think you--get the idea
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
easal
Novice


Joined: 21 Jun 2005
Posts: 38

PostPosted: Sun Jan 18, 2009 11:53 pm   
 
And that looks quite good too Vijilante... Thanks! I'll play around with both tomorrow and see which I use.
Reply with quote
easal
Novice


Joined: 21 Jun 2005
Posts: 38

PostPosted: Wed Jan 21, 2009 7:57 pm   
 
Code:
used=%item( @kelpsoftlocktoxins, %random( 1, %numitems( @kelpsoftlocktoxins)))
envenom dirk12345 with @used
used2=%item( @kelpsoftlocktoxins, %random( 1, %numitems( @kelpsoftlocktoxins)))
#if (@used = @used2) {used2=%item( @kelpsoftlocktoxins, %random( 1, %numitems( @kelpsoftlocktoxins)))}
#if (@used = @used2) {used2=%item( @kelpsoftlocktoxins, %random( 1, %numitems( @kelpsoftlocktoxins)))}
envenom dirk12345 with @used2


This is what I've ended up using for now. << I had to add the comparison thing to cut down on the number of duplicates.
I like your idea too Vijilante, and will probably switch to it, I just have 10-15 variables written in useable form already, and considering there's twenty or so toxins total, that's a lot of different permutations to count through.

Thanks all for the help. :)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Thu Jan 22, 2009 1:46 pm   
 
This would be better...

Code:
used=%item( @kelpsoftlocktoxins, %random( 1, %numitems( @kelpsoftlocktoxins)))
envenom dirk12345 with @used
used2=%item( @kelpsoftlocktoxins, %random( 1, %numitems( @kelpsoftlocktoxins)))
#WHILE (@used = @used2) {
   used2=%item( @kelpsoftlocktoxins, %random( 1, %numitems( @kelpsoftlocktoxins)))
   }
envenom dirk12345 with @used2


This way you don't have to mod the list, and it'll continue redoing used2 until it is different than used.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Safovine
Newbie


Joined: 20 May 2008
Posts: 3

PostPosted: Thu Jan 29, 2009 4:14 am   
 
How would you get it not to go randomly? Ive tried most of the functions in the help section that I thought might be useful, but I cant get it to work, everything I try just uses the first item in the string list, and doesn't move down.
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