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
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Fri Feb 18, 2005 1:07 am   

#If command
 
I continue to add the #If command after a trigger command so that it will execute certain variables. Perhaps I'm using it wrong, but here is the code.

Code:
 #TRIGGER {hp ( (%d)/633 )    sp ( (%d)/629 )     mp ( (%d)/440 )} {
  #var hp_monitor {%1}
  #var sp_monitor {%2}
  #var mp_monitor {%3}
}

#If (hp_monitor < (sp_monitor - 25)) {cast 'heal light'}
#If (mp_monitor < 60) {cast 'regeneration'}


The Problem is everytime I go into the Zmud Script Editor it erases the #if commands as if they couldn't be used, thus the trigger ultimately doesn't work. Am I doing something wrong? Is there a way for it to keep and read the #if commands?
Reply with quote
Aarlot
Adept


Joined: 30 Dec 2003
Posts: 226

PostPosted: Fri Feb 18, 2005 1:30 am   
 
The IF commands should be IN the trigger.


#TRIGGER {hp ( (%d)/633 ) sp ( (%d)/629 ) mp ( (%d)/440 )} {
#var hp_monitor {%1}
#var sp_monitor {%2}
#var mp_monitor {%3}
#If (hp_monitor < (sp_monitor - 25)) {cast 'heal light'}
#If (mp_monitor < 60) {cast 'regeneration'}
}
_________________
Everyone is entitled to their beliefs - until they die. Then only the truth matters.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Feb 18, 2005 1:46 am   
 
Also make sure you are qouting the special chars with ~
#TRIGGER {hp ~( (%d)/633 ~) sp ~( (%d)/629 ~) mp ~( (%d)/440 ~)}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Fri Feb 18, 2005 8:35 pm   
 
The #if statements stay in the trigger, but nothing happens it doesn't cast heal or regeneration. Any thoughts or ideas?
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Fri Feb 18, 2005 8:50 pm   
 
Is the trigger firing at all?
Add an echo statement to the trigger to make sure the trigger is firing.
Also its very important to quote the special characters as nexela said.
Perhaps you could copy an example of your prompt, and post it along with a current example of the trigger?
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Feb 18, 2005 9:36 pm   
 
Say oops missing a few things (in red) :p


#TRIGGER {hp ~( (%d)/633 ~) sp ~( (%d)/629 ~) mp ~( (%d)/440 ~)} {
#var hp_monitor {%1}
#var sp_monitor {%2}
#var mp_monitor {%3}
#If (@hp_monitor < (@sp_monitor - 25)) {cast 'heal light'}
#If (@mp_monitor < 60) {cast 'regeneration'}
}
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Fri Feb 18, 2005 9:53 pm   
 
I've added an echo command, and it just doesn't trigger. I've also tried to add the (%d) in front of a different trigger and it just doesn't want to fire. I'm not sure why though.
Reply with quote
nexela
Wizard


Joined: 15 Jan 2002
Posts: 1644
Location: USA

PostPosted: Fri Feb 18, 2005 10:10 pm   
 
Then it is not matching correctly

Paste your mud prompt between some[ CODE ] tags.
_________________
Zmud Support Library
Zmud Knowledge Base
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Feb 18, 2005 10:11 pm   
 
I noticed you had multiple spaces in the trigger pattern in your first post. Whenever you have multiple spaces in a line of text you want to match, you need to use the %s wildcard. Without it, the multiple spaces in the pattern are compressed down to one single space and the pattern will then not match the line.
_________________
EDIT: I didn't like my old signature
Reply with quote
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Fri Feb 18, 2005 10:14 pm   
 
If I use the %s wildcard, I'll have to go %1, %3, %5, because %2 and %4 will be assigned to the wild card variable %s right?
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Fri Feb 18, 2005 10:32 pm   
 
only things enclosed in a capturing group () are assigned to %n variables
so adding if you add a %s but dont enclose it in parenthesis then you can ignore it as far as the $1,%2,etc are concerned
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Fri Feb 18, 2005 10:41 pm   
 
Alright, I attempted to use the %s wildcard and it still doesn't want to fire. So figuring it wasn't the spaces (I knew I had the correct amount in the first place) I tried something different. I took a trigger where I normally had a * instead of a direct variable such as (%w). So what I did was substitute the varibale (%w) for a trigger with a word in front of it, sacrifice corpse. I originally used the following:

Code:
 #trigger {* falls to the ground dead.}{loot corpse;sacrifice corpse}


However when I did the following it didn't want to read the trigger:

Code:
 #trigger {~(%w)~ falls to the ground dead.}{loot corpse;sacrifice corpse}


I tried this because the * wasn't working with #if (command) {execute this} {else execute this}. It was always just using the first command even if the arguement was false. Perhaps theres something wrong with my assigned variables or I have to turn something on to allow the assigned variables to work? Just so you know these variables are in different classes.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Fri Feb 18, 2005 10:52 pm   
 
hey Litteron why not post the current trigger your trying to make work
along with the line you're trying to capture,
just cut input from the mud and paste it here
maybe we can catch something you maybe missing Smile
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Sat Feb 19, 2005 12:43 am   
 
Here is the trigger. The Mud displays the command after each attack:

hp ( 633/633 ) sp ( 629/629 ) mp ( 440/440 )

Here is the Code I use:
Code:
 #TRIGGER {hp ~( (%d)/633~ ) %s sp ~( (%d)/629~ ) %s mp ~( (%d)/440~ )} {
  #var hp_monitor {%1}
  #var sp_monitor {%2}
  #var mp_monitor {%3}
  #If (@hp_monitor < (@sp_monitor - 25)) {cast 'heal light'}
  #If (@mp_monitor < 60) {cast 'regeneration'}
}


I'm really not sure where the problem is, but it's definitly in my triggers. Because I tried the echo command and it didn't fire.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat Feb 19, 2005 1:16 am   
 
Code:
#TRIGGER {hp ~( (%d)/633 ~) sp ~( (%d)/629 ~) mp ~( (%d)/440 ~)} {
#var hp_monitor {%1}
#var sp_monitor {%2}
#var mp_monitor {%3}
#If (@hp_monitor < (@sp_monitor - 25)) {cast 'heal light'}
#If (@mp_monitor < 60) {cast 'regeneration'}}



That should work the code you just posted had 2 things wrong with it that I could see.
first in the trigger pattern you put the ~ meant to quote the )
directly after the numbers and before a space.
so you had
hp ~( (%d)/633~ )
instead of
hp ~( (%d)/633 ~)
second you put the %s surrounded by 2 spaces
which basically makes it so there had 2 be at least 3 spaces before sp and one after since %s requires at least one space
you had
) %s sp ~(
instead of
)%ssp%s~(
or
) sp ~(

anyways the code i posted above matched the string that you pasted
hp ( 633/633 ) sp ( 629/629 ) mp ( 440/440 )
of course to get the trigger to fire hp has to be 25 or more lower than sp
and mp less than 60
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Sat Feb 19, 2005 3:08 am   
 
Crying or Very sad I tried that code Darkhael and it's still not firing at all. I did an echo to see if it would fire, it didn't work. I did exactly what you put, no go.
Reply with quote
Dharkael
Enchanter


Joined: 05 Mar 2003
Posts: 593
Location: Canada

PostPosted: Sat Feb 19, 2005 3:44 am   
 
bah I've no idea, why not, perhaps someone else might spot a mistake I made.
anyways this next code ignores whitespace all together
also instead of requiring specific numbers for the max hp,sp,mp
it accepts any number.


#REGEX {hp\s*\(\s*(\d+)/\d+\s*\)\s*sp\s*\(\s*(\d+)/\d+\s*\)\s*mp\s*\(\s*(\d+)/\d+\s*\)} {
#var hp_monitor {%1}
#var sp_monitor {%2}
#var mp_monitor {%3}
#If (@hp_monitor < (@sp_monitor - 25)) {cast 'heal light'}
#If (@mp_monitor < 60) {cast 'regeneration'}
}
_________________
-Dharkael-
"No matter how subtle the wizard, a knife between the shoulder blades will seriously cramp his style."
Reply with quote
littleron
Beginner


Joined: 05 Feb 2005
Posts: 11

PostPosted: Sat Feb 19, 2005 3:59 am   
 
WOO... Finally it worked. But I'd still like to know the problem with what happened, because of other triggers I have, but also so I can code them in the future. Perhaps I'll just attempt to figure out how to use #Regex but I'm not too familiar with those type of Unix commands. Either way we'll see. Maybe someone else sees the problem in my previous script though?
Reply with quote
mr_kent
Enchanter


Joined: 10 Oct 2000
Posts: 698

PostPosted: Sat Feb 19, 2005 8:05 am   
 
nexela wrote:
Paste your mud prompt between some[ CODE ] tags.


These forums compress whitespace, so showing us exactly what your prompt looks like does not give us a copy of your prompt to analyze.

If you want to know why your script didn't work, then please copy your prompt from a zMud session and paste it between code tags.

This thread has been around long enough that any glaring problems would have been pointed out, so it must be something to do with the transition from your zMud session to these forums.
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