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


Joined: 16 Dec 2010
Posts: 4

PostPosted: Thu Dec 16, 2010 5:31 am   

multi state trigger help
 
Every time I look into a bucket this is what I see. I'm trying to create a multi-state trigger based off of this mud output:

Code:
========================
-Bucket-

Apple
Orange
Big Apple

========================
 3 items in the bucket
========================


Items in the bucket change and I want to create a list that looks like this
#say Inside the bucket you found Apple, Orange and Big Apple.

Every time you look inside the bucket, the order may shift and I can't figure out how to use states to match the variables properly and output a list where the information changes order each time.
Reply with quote
soulless
Newbie


Joined: 16 Dec 2010
Posts: 4

PostPosted: Thu Dec 16, 2010 1:35 pm   
 
#trigger {-Bucket-}
#cond {Apple} {#var item1 apple} {duration|3}

Don't know how to make it stop on the ==== and I know I'm not storing the vars efficiently...
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Thu Dec 16, 2010 5:06 pm   
 
I believe this'll do twhat you'd like.

Code:
#TRIGGER "BucketTrigger" {-Bucket-} {#VAR BucketContents ""}
#COND {^(*)$} {#IF ("%1" = "========================") {#STATE BucketTrigger 2} {#VAR BucketContents %additem("%1", @BucketContents)} {manual}
#COND {========================} {#SAY %concat( "Inside the bucket you found ", %expandlist( @BucketContents, ", "), ".")}


This should work and will reproduce the list even with duplicate items. ie:

========================
-Bucket-

Apple
Orange
Big Apple
Orange

========================
4 items in the bucket
========================
Inside the bucket you found Apple, Orange, Big Apple, Orange.


Last edited by DraxDrax on Thu Dec 16, 2010 5:11 pm; edited 1 time in total
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Dec 16, 2010 5:10 pm   
 
You might find it easier to use two triggers. One to start and stop and one to actually count the items in the bucket.

Something like this.
Code:
#trigger {-Bucket-} {#T+ CountBucket}
#cond {=============} {#T- CountBucket}
#TRIGGER CountBucket {(*)} {#ADDITEM Bucket %1}
_________________
Asati di tempari!
Reply with quote
soulless
Newbie


Joined: 16 Dec 2010
Posts: 4

PostPosted: Thu Dec 16, 2010 7:26 pm   
 
DraxDrax, your solution perfectly did what I was needing it to. Thanks so much!

I've not used stringlists before - Is there a way to manipulate the data inside it before the say?
========================
-Bucket-

Apple [rotten]
Orange [fresh]
Big Apple [fresh]
Orange [rotten and stinky]

========================
4 items in the bucket
========================

Is there a way to remove rotten fruit from the stringlist (using #delitem I surmise) and change Big Apple to just Apple?
#say You have an Orange and an Apple!
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Fri Dec 17, 2010 8:22 am   
 
Yep, that can be done, but before we tackle that problem, can you give a bit more information? I assume you want to do something with the contents of the bucket. Possibly remove them and eat them, or something along those lines, and it would be helpful if you could explain everything you'd like to do with your fruit, what condition you'd like them in, and the proper way to manipulate them on your mud. *

This is important if, for example, you only wanted to do things with fresh fruit, ignoring the rotten ones, and had something like this:

========================
-Bucket-

Apple [fresh]
Apple [rotten]
Big Apple [fresh]

========================
3 items in the bucket
========================

In this case you'd want to get the first and third apple while ignoring the second. On the mud I play, the syntax to retrieve objects inside of containers according to their order is 'get <#>.<object> <container>' so to get apples #1 and #3 you would 'get 1.apple bucket' and 'get 2.apple bucket' (after removing the first apple, two apples remain and the first one is the rotten one).

But perhaps your mud uses a different syntax, or perhaps you can use the keyword 'fresh', thus eliminating the need to specify items according to their order, or perhaps you have some entirely different agenda... Whatever the case, we can help you, but more info would make it easier.


* did this sound vaguely sexual to anyone else, or am I just weird?
Reply with quote
soulless
Newbie


Joined: 16 Dec 2010
Posts: 4

PostPosted: Fri Dec 17, 2010 11:12 pm   
 
I mostly just want to know how to work with the data once it's put into the string so that I can seperate out fresh and rotten fruit. Syntax is get 2.fruit etc and junk 3.fruit. I can't use the keyword fresh, so I need to find a way to remove the rotten fruit from the string list and only remove good fresh fruit.
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