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
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Tue Nov 11, 2008 1:52 am   

Trigger selection question
 
Alright, I want to make a suggested afflictions list. It first examines what the target has, than I need it to be able to pick one affliction, then pick another without it being the same as the first affliction.

Easy Example:

A B C D E F is the desired affliction list

Target has a and c.

Trigger picks b as affliction one and d as affliction two out of the same affliction list.

Problem 2:
Once it finds out A is not afflicted(for affliction 1), I want it to pick A and not continue going on to F. I want to streamline it so it stops there instead of going through all the other possibilities.
Once it finds out D is not afflicted(for affliction 2), I want it to pick D and not continue going on to F. I want to streamline it so it stops there instead of going through all the other possibilities.

If more info is needed, I will give whatever you need.
Reply with quote
Tarken Aurelius
Apprentice


Joined: 23 Oct 2008
Posts: 120
Location: Cincinnati, Ohio

PostPosted: Tue Nov 11, 2008 11:03 am   
 
Give some example text of what you're working with and what you want it to do exactly.
_________________
Tarken Aurelius, quality triggers since 2004! Trigger consulting since 2008! Content Developer at BatMUD (www.bat.org)
Reply with quote
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Tue Nov 11, 2008 5:56 pm   
 
Code:

#IF (!%ismember( belonephobia, @afflictionlist)) {afflict1 = belonephobia} {#IF (!%ismember( indifference, @afflictionlist)) {afflict1 = indifference} {#IF (!%ismember( stupidity, @afflictionlist)) {afflict1 = stupidity}}}

#IF (!%ismember( belonephobia, @afflictionlist)) {#if (belonephobia != @afflict1) {afflict2 = belonephobia} {#IF (!%ismember( indifference, @afflictionlist)) {#if (indifference != @afflict1) {afflict2 = indifference} {#IF (!%ismember( stupidity, @afflictionlist)) {#if (stupidity != @afflict1) {afflict2 = stupidity} {}}}}}}


I am thinking something like that.. But once it makes a selection, I want it to stop instead of continuing through the list. I also want to try to find a way to stream line it.
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Tue Nov 11, 2008 6:20 pm   
 
Try This Here:

Make a var afflictpos with all possible affliction in it.
Code:
#CLASS Afflictions
#ALIAS doafflict {
   #VAR loopcnt {1}
   #WHILE !(@afflict1) {
      #IF (!%ismember( %item(@afflictpos,@loopcnt), @afflictionlist)) {afflict1 = %item(@afflictpos,@loopcnt)}
      #ADD loopcnt 1
   }
   #VAR loopcnt {1}
   #WHILE (!(@afflict2) AND @loopcnt < (%numitems(@afflictionlist) + 1)) {
      #IF ((!%ismember( %item(@afflictpos,@loopcnt), @afflictionlist)) AND (%item(@afflictpos,@loopcnt) != @afflict1)) {afflict1 = %item(@afflictpos,@loopcnt)}
      #ADD loopcnt 1
   }
   Do Whatever With Your Chosen Afflictions Here
}
#VAR loopcnt {}
#CLASS 0


Or your other option is to use a reversed #LOOP, to parse your list BACKWARDS. This still iterates thorough the whole list, but always takes the higher precedence affliction.

Code:
#LOOP %numitems(@afflictionlist),1 {#IF (!%ismember( %item(@afflictpos,%i), @afflictionlist)) {afflict1 = %item(@afflictpos,%i)}


However, I think my first code block is the more intuitive way to do it, because it only loops as far as needed.

Hmm, here is a 3rd way that just came to me:
Code:
#LOOP %numitems(@afflictionlist) {#IF (!%ismember( %item(@afflictpos,%i), @afflictionlist)) {#additem notafflicted %item(@afflictpos, %i)}
afflicted1 = %pop(notafflicted)
afflicted2 = %pop(notafflicted)


Use whichever method works best for you.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Wed Nov 12, 2008 10:32 pm   
 
The first example seems to be the best for what I want, but the afflict 2 is buggy. It returns 0 everytime.
I've looked it over, but honestly, I don't understand the code.
Reply with quote
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Wed Nov 12, 2008 10:54 pm   
 
Another problem is. once its set afflict1, even if afflict1 is in afflictionlist it still stays there, but
if you reset the variable, it will then update it.
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Thu Nov 13, 2008 2:25 am   
 
It was only code meant to be example to work from, not a fully functional setup.
To make the variable change, you'll need other triggers when you afflict someone, or check what afflictions they have.
Then change the afflictionlist var with the new afflictions they have. I've also added a variable clearing into this code so it FORCES a recheck each time.


The problem with the afflict2 loop is that its setting afflict1 again :p I was tired and forgot to change a couple things when I copied and pasted. Here is the proper code.
Code:
#CLASS Afflictions
#ALIAS doafflict {
   #VAR loopcnt {1}
   #VAR afflict1 {}
   #VAR afflict2 {}
   #WHILE !(@afflict1) {
      #IF (!%ismember( %item(@afflictpos,@loopcnt), @afflictionlist)) {afflict1 = %item(@afflictpos,@loopcnt)}
      #ADD loopcnt 1
   }
   #VAR loopcnt {1}
   #WHILE (!(@afflict2) AND @loopcnt < (%numitems(@afflictionlist) + 1)) {
      #IF ((!%ismember( %item(@afflictpos,@loopcnt), @afflictionlist)) AND (%item(@afflictpos,@loopcnt) != @afflict1)) {afflict2 = %item(@afflictpos,@loopcnt)}
      #ADD loopcnt 1
   }
   Do Whatever With Your Chosen Afflictions Here
}
#VAR loopcnt {}
#CLASS 0
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Dyron
Apprentice


Joined: 08 Apr 2004
Posts: 103
Location: USA

PostPosted: Thu Nov 13, 2008 5:05 pm   
 
I had already fixed the second line setting afflict1 again, but it's still having the same problem.. No matter what
afflict2 returns nothing.. Something in that code just isn't working, but I don't understand it enough to edit it.
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