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


Joined: 28 Aug 2003
Posts: 49

PostPosted: Fri Sep 05, 2003 11:18 am   

Resting when needed script
 
Hi,i got 2 tiggers based on prompt in order to sleep when my movement is low:

#tr {^<*/*hp */*m %1mv *exp <<*>>$}{#if %1<10 {sleep;#t- ref2;#t+ ref}}

#tr {^<*/*hp */*m %1mv *exp <<*>>$}{#if {%1>50} {#t- ref;#t+ ref2;despertar;step}}

One of them is in ref class,and the other on ref2 class,so when 1 is active,the other isnt.

I think it should work but it doesnt,what its suposed to do is to sleep when i get less movement than 10,and wake up and keep walking when i get 50 or more movement... and there is probably a better way to do that... Any idea?

Thanks
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 05, 2003 4:38 pm   
 
~ in front of special characters, especially the grouping characters. Prompt triggers usually require the 'prompt' option and I usually use 'nocr' also. As for better ways, limited wildcards are usually better than *. %1, %2, etc. are best reserved for the trigger Value (commands) instead of the Pattern.

Do you only have 1 value for mv? Not two values like hp and m?
You need a space between the end of the pattern and the beginning of the value.
You should use () around the condition of #IF.

#TR {^~<%n/%dhp %n/%dm (%n)mv %dexp ~<~<*~>~>$} {#IF (%1 < 10) {sleep;#T- ref2;#T+ ref}} {} {prompt|nocr}
#TR {^~<%n/%dhp %n/%dm (%n)mv %dexp ~<~<*~>~>$} {#IF (%1 > 50) {#T- ref;#T+ ref2;despertar;step}} {} {nocr|prompt}
Reply with quote
Droid
Novice


Joined: 28 Aug 2003
Posts: 49

PostPosted: Fri Sep 05, 2003 8:43 pm   
 
Actually zmud did recognice the tigger,and shooted when needed,but didnt work properly,what i need to change is value,which still doesnt work with that :|
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Sep 05, 2003 10:21 pm   
 
You asked for better ways to do things. I suggested several. Use them or not, as you choose.

If, as seems likely, you have two values for mv, then naturally neither your trigger nor mine will work properly. Mine won't work because it's pattern won't match the MUD output. Yours won't work because you'll always have less than 10 times your max moves so you'll always sleep, and you'll never have 51+ times your max moves so you'll never wake up (if that's what 'despertar' does).

If you have 75/100mv then %1 will be '75/100'. Since zMUD uses integer math by default, this isn't even three-quarters, it's 0. To get %1 greater than 10 would require 1100/100mv. To make %1 greater than 50 would require 5100/100.

Modified for two values:
#TR {^~<%n/%dhp %n/%dm (%n)/%dmv %dexp ~<~<*~>~>$} {#IF (%1 < 10) {sleep;#T- ref2;#T+ ref}} {} {prompt|nocr}
#TR {^~<%n/%dhp %n/%dm (%n)/%dmv %dexp ~<~<*~>~>$} {#IF (%1 > 50) {#T- ref;#T+ ref2;despertar;step}} {} {nocr|prompt}
Reply with quote
Droid
Novice


Joined: 28 Aug 2003
Posts: 49

PostPosted: Sat Sep 06, 2003 12:02 am   
 
Oki,im sorry that seems i didnt explain myself all right,excuse me.

I finally got it to work,that way:
this as pattern:
^<*/*hp */*m %1mv *exp <<*>>$
and same values as the ones you use.
The %1 before mv is the movement points i still have.
My prompt is next:
<225/225hp 124/124m 144mv 36,121exp <<HS>>

Well,dont understand why,but this works fine.
Thanks for your help,and sorry for my english
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Sep 06, 2003 7:48 am   
 
If you're satisfied with having triggers that work, you can skip the explanation below. If you want to know why the triggers weren't working, read on.

Since you hadn't provided a sample I didn't realize you have commas in the number for experience. I used %d which only matches the digits 0 to 9, instead of %n which also matches +, -, and commas. Fixing the triggers from my first post is just a matter of changing that wildcard from %d to %n.

#TR {^~<%n/%dhp %n/%dm (%n)mv %nexp ~<~<*~>~>$} {#IF (%1 < 10) {sleep;#T- ref2;#T+ ref}} {} {prompt|nocr}
#TR {^~<%n/%dhp %n/%dm (%n)mv %nexp ~<~<*~>~>$} {#IF (%1 > 50) {#T- ref;#T+ ref2;despertar;step}} {} {nocr|prompt}

(Actually, if this is all the triggers do, their patterns could end with 'mv')

-*-*-*-*-

Your original triggers were for command-line entry. They didn't work for the reasons I said. Your new triggers work because you entered them directly into the editor. It makes a significant difference.

I copied your original triggers and pasted them into my own command line. When I looked in the editor, this is what I had:
Trigger1
Pattern:
{^*/*hp */*m %1mv *exp <<*>$}{#if %1<10 {sleep;#t- ref2;#t+ ref}}
Value:
blank
Trigger2
Pattern:
{^*/*hp */*m %1mv *exp <<*>$}{#if {%1>50} {#t- ref;#t+ ref2;despertar;step}}
Value:
blank

As you can see, the < at the beginning and the > at the end were removed because you didn't use ~. This also shows how leaving out the space between the pattern and value causes everything to end up in the pattern. But even with the space, your pattern would have still been missing the <> which would prevent it from matching.
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