Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Fri Aug 15, 2008 3:49 pm   

Triggers only firing half of the time? [2.35]
 
I have this anti-theft script for Achaea. Yesterday, it was working 100% perfect. Then I tested it an hour earlier, and it wouldn't re-wear one of my items. Now it refuses to update one of the variables for just one of my weapons, a rapier. The other one is working fine.
Any help would be much appreciated. Here's the code:

Code:
#DELCLASS {AinentScripts}
#CLASS 0
#CLASS {AinentScripts}
#TRIG "more" {^Type MORE to continue reading. (*)$} {MORE} {} {disable}
#ALIAS II {#T+ "more";#T+ "what_wielding";#T+ "what_wearing";~II;#ALARM {+1} {#T- "more";#T- "what_wielding";#T- "what_wearing"}} {}
#CLASS 0
#CLASS {AinentScripts|AntiTheft}
#CLASS 0
#CLASS {AinentScripts|AntiTheft|Gold}
#TRIGGER "gold" {^You get %a gold sovereigns from a canvas backpack.$} {put %1 gold in pack288273} {}
#ALIAS gold {get %1 gold from pack;#T- "gold";#WAIT 2000;#T+ "gold"} {}
#CLASS 0
#CLASS {AinentScripts|AntiTheft|Journal}
#CLASS 0
#CLASS {AinentScripts|AntiTheft|Armor}
#VAR armors {a suit of leather armour|flowing white robes|a pair of white, comfortable trousers|a simple pair of sandals|a canvas backpack|a wide brimmed hat with a plume|a pair of striped blue and white socks}
#VAR armor_nums {armour84201|robes127315|trousers276252|sandals282752|pack288273|hat280065|socks179146}
#ALIAS armors {#PROMPT armors "Please enter the FULL names to your armors, separated with a |";#PROMPT armor_nums "Now please enter the armor numbers, separated with a |"}
#TRIG {^You remove (*).$} {#FORALL @armor_nums {wear %i}} {}
#COND {^You have recovered balance on all limbs.$} {#FORALL @armor_nums {wear %i}} {}
#CLASS 0
#CLASS {AinentScripts|AntiTheft|Instrument}
#CLASS 0
#CLASS {AinentScripts|AntiTheft|Weap}
#VAR right_weap {}
#VAR right_weap_num {}
#VAR left_weap {}
#VAR left_weap_num {}
#TRIG "what_wielding" {^You are wielding:$} {} {} {disable}
#COND {%s(*):%s(*) in your left hand.$} {#VAR left_weap {%2};#VAR left_weap_num {%1}} {}
#COND {%s(*):%s(*) in your right hand.$} {#VAR right_weap {%2};#VAR right_weap_num {%1}} {}
#TRIG {^You begin to wield (*) in your left hand.$} {#VAR left_weap {%1};#T+ "more";#T+ "what_wielding";II;#ALARM {+4} {#T- "more"#T- "what_wielding"}} {}
#TRIG {^You begin to wield (*) in your right hand.$} {#T+ "more";#T+ "what_wielding";II;#ALARM {+4} {#T- "more";#T- "what_wielding"}} {}
#TRIG {^You begin to wield (*) in your left hand.$} {II} {}
#TRIG {^You cease wielding @right_weap in your right hand.$} {wield @right_weap_num} {}
#TRIG {^You cease wielding @left_weap in your left hand.$} {wield @left_weap_num} {}
#CLASS 0
#ECHO {Achaea anti-theft reflexes installed! I hope you are wearing everything that you have! One moment please...}
#ALARM {+1} {II}
#ALARM {+3} {armors}


EDIT: Also, any time I try to manually delete this script from the PE, I get an error message asking me to close CMUD.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Aug 15, 2008 5:12 pm   
 
Quote:
I tested it an hour earlier, and it wouldn't re-wear one of my items. Now it refuses to update one of the variables for just one of my weapons, a rapier. The other one is working fine.

Can you be a little more specific about what is or is not happening?

I see that this code expects the output of the II command to display "You are wielding:", then "...in your left hand.", then "...in your right hand." Does it always have left hand then right hand?

Code:
#TRIG {^You begin to wield (*) in your left hand.$} {#VAR left_weap {%1};#T+ "more";#T+ "what_wielding";II;#ALARM {+4} {#T- "more"#T- "what_wielding"}} {}
#TRIG {^You begin to wield (*) in your right hand.$} {#T+ "more";#T+ "what_wielding";II;#ALARM {+4} {#T- "more";#T- "what_wielding"}} {}
#TRIG {^You begin to wield (*) in your left hand.$} {II} {}

Here you have two nearly identical triggers for left hand, and only one for right hand. The longer left hand trigger is superfluous--the #T+ and #T- executed in it is duplicated in your alias II. The same is true for the one right hand trigger. You should get rid of the longer triggers and make a right hand trigger matching the shorter left hand trigger like so:
Code:
#TRIG {^You begin to wield (*) in your left hand.$} {II} {}
#TRIG {^You begin to wield (*) in your right hand.$} {II} {}


For the armor, I don't know. Are you sure you put in the right item number? I see a couple other oddities in your code, probably from old modifications. For instance, some of your triggers have captures, "(*)", which you don't actually use. But these little things shouldn't pose any problem.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Aug 15, 2008 5:17 pm   
 
Oh, one more thing I notice. Your II alias has "#T+ "what_wearing"", but I don't see a what_wearing trigger. I assume it is supposed to be similar to your what_wielding trigger? Does this trigger not exist, or did you just neglect to include it in your posting?
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Fri Aug 15, 2008 8:18 pm   
 
Rahab wrote:
Oh, one more thing I notice. Your II alias has "#T+ "what_wearing"", but I don't see a what_wearing trigger. I assume it is supposed to be similar to your what_wielding trigger? Does this trigger not exist, or did you just neglect to include it in your posting?


Oh, oops. I forgot I deleted that trigger because I couldn't get it to work because my info inv (II) list was more than one page long and i couldn't get it to work through the MORE command.
But i'll try those things you recommended and let you know.
Thanks
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Fri Aug 15, 2008 8:23 pm   
 
Ok, what is not happening, is it is not updating my variable for what my weapons are. It will fire on one of them, but not for both weapons.
And sometimes, it shows left hand first, then right hand first.
Here's a copy of what the II command shows me:

Code:

You are wielding:
      buckler354196: a buckler in your left hand.
      rapier240991: an ornate steel rapier in your right hand.

You are holding:
      vial94393           an oaken vial
      vial118571          an oaken vial
      vial158559          an oaken vial
      vial179818          an oaken vial
      vial208888          an oaken vial
      vial226096          an oaken vial
      vial286968          a small pinewood vial


You are wearing:
      armour84201         a suit of leather armour
      robes127315         flowing white robes
      trousers276252      a pair of white, comfortable trousers
      sandals282752       a simple pair of sandals
Type MORE to continue reading. (80% shown)
1246h, 1152m ex-more

      pack288273          a canvas backpack
      hat280065           a wide brimmed hat with a plume
      socks179146         a pair of striped blue and white socks
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Fri Aug 15, 2008 8:25 pm   
 
Would it work better to use a multi-line trigger, like a regex, or just to use a #TEMP trigger?
If it would be a regex, would you mind making that for me? My previous post should be enough info to make one. I have no idea how to make regexes (regi?) though
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Fri Aug 15, 2008 8:30 pm   
 
Also, every time I resend this script when I edit something, it keeps making multiples of every variable in the script, so the parts of the script that do work (removing/rewearing *some* items), it tries to rewear all of them several times. And since I put a #DELCLASS at the beginning of the script, I can't see why this would be happening.
Reply with quote
Orang
Apprentice


Joined: 22 Jul 2004
Posts: 118
Location: USA

PostPosted: Fri Aug 15, 2008 8:49 pm   
 
Ok, I think I got it. I replaced all the #COND with #TEMP, but within the first trigger and they seem to be working fine. Hard telling if CMUD will decide it doesn't like that an hour from now though.... Neutral
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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