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


Joined: 20 Aug 2008
Posts: 34

PostPosted: Tue Mar 24, 2009 4:20 am   

Trigger based off of previous line's input
 
I am trying to write a set of triggers to practice two connected skills, detect trap and disarm trap.

Right now my trigger is just for detect trap and is as such:

#alarm +10 {#case %random {detect door n} {detect door s} {detect door e} {detect door w} {detect door u} {detect door d}}
If the skill detects a trap I would like to trigger it to disarm the trap on the door in the direction it was detected. So if random gives me: detect door e and I get "You detect a trap" I will disarmtrap door e.
Reply with quote
shalimar
GURU


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

PostPosted: Tue Mar 24, 2009 7:10 am   
 
#ALARM +10 {Thisdoor=%item("n|e|w|s|u|d", %random(1,6));detect door @thisdoor}
#TR {You detect a trap} {disarmtrap door @thisdoor}
_________________
Discord: Shalimarwildcat
Reply with quote
LordFett213
Novice


Joined: 20 Aug 2008
Posts: 34

PostPosted: Tue Mar 24, 2009 12:26 pm   
 
Works like a champ.
Reply with quote
LordFett213
Novice


Joined: 20 Aug 2008
Posts: 34

PostPosted: Tue Mar 24, 2009 12:47 pm   
 
How about an addition to this that when you remove the trap (trigger {You remove a trap}) it starts over but removes the direction you just removed the trap from so you don't try and re-remove that trap? Then once all directions are removed they're readded.

So first success is on the east door, next attempt is between n|s|w|u|d then u door is taken care of so next round is n|s|w|d so on until the last one, say n is disarmed then the full list of 6 directions is available again.
Reply with quote
Tech
GURU


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

PostPosted: Wed Mar 25, 2009 7:16 am   
 
Something like this should help.

Code:
#VAR Dirs "n|e|w|s|u|d"
#ALARM +10 {Thisdoor=%item(@Dirs, %random(1,%numitems(@Dirs)));detect door @thisdoor}
#TR {You detect a trap} {disarmtrap door @thisdoor;#CALL %delitem(@Thisdoor,@Dirs);#IF (%numitems(@Dirs) == 0) {Dirs="n|e|w|s|u|d"}}


That's off the top of my head but should do the trick. The last bit of code there resets the Dirs variable after you've gone through all the doors.
_________________
Asati di tempari!
Reply with quote
LordFett213
Novice


Joined: 20 Aug 2008
Posts: 34

PostPosted: Wed Mar 25, 2009 2:59 pm   
 
I tried with your stuff Tech and it just isn't firing. I have since shalimar first posted added a bit to the triggers, going to post everything and see if I can figure out the problem.

Code:
#CLASS {skillbot|detect trap}
#TRIGGER {You don't detect anything strange.} {#ALARM +15 {Thisdoor=%item( "n|e|w|s|u|d", %random( 1, 6));detect door @thisdoor}}

#TRIGGER {You are too weary to concentrate right now...rest a bit.} {#ALARM +15 {Thisdoor=%item( "n|e|w|s|u|d", %random( 1, 6));detect door @thisdoor}}

#TRIGGER {Nothing seems to happen...} {#alarm +15 {detect door @thisdoor}}

#TRIGGER {You remove a trap!} {#alarm +6 {pick door @thisdoor}}

#TRIGGER {You detect a trap!} {#alarm +15 {disarmtrap door @thisdoor}}

#TRIGGER {You cannot concentrate enough at the moment...rest a bit.} {#alarm +15 {disarmtrap door @thisdoor}}

#TRIGGER {The lock quickly yields to your skills and pops open.} {open door @thisdoor;#ALARM +15 {Thisdoor=%item( "n|e|w|s|u|d", %random( 1, 6));detect door @thisdoor}}

#TRIGGER {You failed to pick the lock.} {#alarm +6 {pick door @thisdoor}}

#CLASS 0


All the doors are locked, so once I have removed the trap I am trying my hand at picking the door. If I find a trap and do not disarm it, I have it recheck that same door until I disarm it and then start picking it. Once the door has been picked I start on a new random direction until I find a trap. What I have for what Tech added is this:

Code:
#CLASS {skillbot|detect traps 2}
#TRIGGER {You don't detect anything strange.} {#ALARM +15 {Thisdoor=%item( @Dirs, %random( 1, %numitems( @Dirs))) detect door @thisdoor}}

#TRIGGER {You are too weary to concentrate right now...rest a bit.} {#ALARM +15 {Thisdoor=%item( @Dirs, %random( 1, %numitems( @Dirs))) detect door @thisdoor}}

#TRIGGER {Nothing seems to happen...} {#alarm +15 {detect door @thisdoor}}

#TRIGGER {You remove a trap!} {#alarm +6 {pick door @thisdoor}}

#TRIGGER {You detect a trap!} {#alarm +15 {disarmtrap door @thisdoor}}

#TRIGGER {You cannot concentrate enough at the moment...rest a bit.} {#alarm +15 {disarmtrap door @thisdoor}}

#TRIGGER {The lock quickly yields to your skills and pops open.} {open door @thisdoor;#CALL %delitem(@Thisdoor,@Dirs);#IF (%numitems( @Dirs) == 0) {Dirs="n|e|w|s|u|d"};#ALARM +15 {Thisdoor=%item( @Dirs, %random( 1, %numitems( @Dirs))) detect door @thisdoor}}

#TRIGGER {You failed to pick the lock.} {#alarm +6 {pick door @thisdoor}}

#CLASS 0


The 2nd trigger set fires on You detect a trap and Nothing seems to happen. But You don't detect anything strange it seems to have a problem. I don't know if I messed up in my entering of the #call %delitem or what. Also each time it tries it adds door dir to the thisdoor variable so after say 5 attempts I end up with "s door e door u door w door d" as the variable.
Reply with quote
shalimar
GURU


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

PostPosted: Wed Mar 25, 2009 7:35 pm   
 
well for one, you are redefining @thisdoor whenever you are too weary to concentrate instead of just using the current value

instead of the call line try

#DELITEM dirs @thisdoor

here is the culpret

#ALARM +15 {Thisdoor=%item( @Dirs, %random( 1, %numitems( @Dirs))) detect door @thisdoor}}
should be
#ALARM +15 {Thisdoor=%item( @Dirs, %random( 1, %numitems( @Dirs)));detect door @thisdoor}}
_________________
Discord: Shalimarwildcat
Reply with quote
LordFett213
Novice


Joined: 20 Aug 2008
Posts: 34

PostPosted: Thu Mar 26, 2009 4:40 am   
 
Thanks for that catch on the ; shalimar. But the #CALL %delitem(@Thisdoor,@Dirs) doesn't remove anything from the @Dirs variable. So if the 2nd detect is the same as the first it gets stuck on that door until repop.

I cleared the @dirs variable list and it repopulated it fine. It is just not removing the direction it just cleared after the door was picked.
Reply with quote
shalimar
GURU


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

PostPosted: Thu Mar 26, 2009 6:48 am   
 
did you try the #DELITEM?
_________________
Discord: Shalimarwildcat
Reply with quote
LordFett213
Novice


Joined: 20 Aug 2008
Posts: 34

PostPosted: Thu Mar 26, 2009 7:33 am   
 
You the man shalimar... I guess I didn't fully read/understand your post the first time through.

Making more then simple triggers is still pretty new to me. So far it looks like everything is working.
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