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
Atreides_096
Wanderer


Joined: 21 Jan 2005
Posts: 99
Location: Solvang, CA

PostPosted: Mon Jul 11, 2005 1:04 am   

Class Enabler Trigger
 
Ok, this is a trigger I've worked on, on and off, for a long time... always drove me nuts I couldn't get it to work.

It's for a spellup script. The script has 3 core aliases (checkup, startspells, spellup). It works like this:

When a spell is practiced to mastery, the class for that spell is enabled. Then when one of the 3 aliases are run, using #if %class, it checks to see which spells it should cast. The enabler portion I've had to set to 1 trigger per spell, because I cannot get it to work in a single trigger. The attempts at a single trigger looked like:

Code:
#var lastspellm {%1} {Checks|Variables}
#if {%ismember( @lastspellm, @spellsenable)} {spellenable}


@spellsenable is the string variable with the list of spells to enable. A portal of the spellenable alias is:

Code:
#if {@lastspellm == absorb} {
  #T+ {Checks|Absorb}
  spellenablem
  }
#if {@lastspellm == accelerate} {
  #T+ {Checks|Accelerate}
  spellenablem
  }
#if {@lastspellm == adrenaline control} {
  #T+ {Checks|AdrenalineControl}
  spellenablem
  }


I have also tried this as imbedded if statements, such as:

Code:
]#if {@lastspellm == absorb} {
  #T+ {Checks|Absorb}
  spellenablem
  } {#if {@lastspellm == accelerate} {
  #T+ {Checks|Accelerate}
  spellenablem
  } {#if {@lastspellm == adrenaline control} {
  #T+ {Checks|AdrenalineControl}
  spellenablem
  }}}


The "spellenablem" alias is:

Code:
#var lastspellm {%proper( @lastspellm)} _nodef {Checks|Variables}
#say @lastspellm Class Activated!


When I run it with just 1 word spells, it works... but once I add in the multi-word spells, no matter how I do it, it activates EVERY class. Also, the spellenablem alias has never worked properly in any way shape or form :P What did I do wrong here?
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Jul 11, 2005 3:14 am   
 
Well, for starters, you should put quotes around all the spell names. That should get rid of your multi-word problem. Secondly, your #IF commands have {} around the condition. Proper syntax should be parentheses (somehow I doubt this would matter, but might as well do it right).

Personally, you could probably do this with a #CASE command:

#case %ismember(@lastspellm,@spellsenable) {#noop absorb;#T+ {Checks|Absorb}} {} {} {} ...
#SAY %concat(%proper(@lastspellm), "Class activated!")
_________________
EDIT: I didn't like my old signature
Reply with quote
Atreides_096
Wanderer


Joined: 21 Jan 2005
Posts: 99
Location: Solvang, CA

PostPosted: Mon Jul 11, 2005 12:52 pm   
 
Actually, they did have parenthesis around them.. in one of my last revisions, I attempted the switch to bracers :P I'll switch it back and try the quotation marks now... but regarding #case ... how exactly does this work? My understanding of #case was that it worked like "if value = 1" use first {} option, if value = 2 use second {} option, etc.. but there are no numerics incorporated in the trigger.. how would it know which option to use, rather than just either using the first, or all?

Thanks :)
Reply with quote
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Mon Jul 11, 2005 6:17 pm   
 
%ismember gives the position of the string in the stringlist (IE, if "blah" is the second item on the @random stringlist, %ismember("blah",@random) would give a "2") I think this is the feature that MattLofton is trying to use. Just arange your stringlist and cases to coincide.

So if spellsenable = "absorb|accelerate|adrenaline control" then it would be #case %ismember(@lastspellm,@spellsenable) {#noop absorb;#T+ {Checks|Absorb}} {#noop accelerate;#T+ {Checks|Accelerate}} {#noop adrenaline control;#T+ {Checks|Adrenaline Control}}

(Disclaimer: Not tested, just assuming that MattLofton has it right, which he usually does :) )
_________________
Everyone is entitled to their beliefs - until they die. Then only the truth matters.
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