Ashteru2006-11-07 12:41:52
Okay, I finally decided to get into zMud coding, after resisting to learn this mutant of a language for a long while. Now, I read the Mechanic's Corner a bit, and saw that Tuek adviced to use trigger states instead of the $ in triggers. (Which, oddly enough, doesn't work for me anyway.) So, I thought I'd give it a try.
I don't need much to understand it, but I just need to find a startingpoint from where I can learn it myself, so..., let's make an example.
It offers the following defences:
Physical cutting: 88
Physical blunt: 84
Armour Status: 95
A pale silver helm has no poisons or magical effects on it.
I have this output which I want to catch, and the numbers I want to save into variables.
So, I click on the statetab in my triggermenu, and I guess I put into the first line
Physical cutting: %d{cutting}
Then, I guess, I put
Physical blunt: %d{blunt}
into the second line. But how can I get both of those to fire?
I basically want to execute
#IF (@cutting > 100) {
#IF (@blunt < 100) {
smelt helm
take all commodity from forge
take all commodity from forge
take all commodity from forge
}
}
Where do I put that? Into the first stateline?
I don't need much to understand it, but I just need to find a startingpoint from where I can learn it myself, so..., let's make an example.
It offers the following defences:
Physical cutting: 88
Physical blunt: 84
Armour Status: 95
A pale silver helm has no poisons or magical effects on it.
I have this output which I want to catch, and the numbers I want to save into variables.
So, I click on the statetab in my triggermenu, and I guess I put into the first line
Physical cutting: %d{cutting}
Then, I guess, I put
Physical blunt: %d{blunt}
into the second line. But how can I get both of those to fire?
I basically want to execute
#IF (@cutting > 100) {
#IF (@blunt < 100) {
smelt helm
take all commodity from forge
take all commodity from forge
take all commodity from forge
}
}
Where do I put that? Into the first stateline?
Unknown2006-11-07 13:35:30
Don't go into the state tab. There's a little drop down box in the normal trigger window that lets you select and add states, to add the pattern and the command. The state tab is for editing what type of Trigger state it is, and its parameter.
Ashteru2006-11-07 13:38:35
Aah, okay. So, if I put the
Physical cutting: %d{cutting}
in the dropdown on 0, save the value, then the
Physical blunt: %d{blunt}
in the dropdown on 1, and then the whole code into the bluntfield, I'll safe both variables before the code is executed, AND it's faster than the normal $?
Physical cutting: %d{cutting}
in the dropdown on 0, save the value, then the
Physical blunt: %d{blunt}
in the dropdown on 1, and then the whole code into the bluntfield, I'll safe both variables before the code is executed, AND it's faster than the normal $?
Unknown2006-11-07 14:00:42
Using ^ and $ should be restricted to matching only the beginning and ending of a line, not as newlines in the middle of a pattern. I think you've got the %d{var} syntax confused, too. If you want to assign the variable in the pattern, use something more like &%dcutting. Here's what I recommend:
CODE
#TRIGGER {^It offers the following defences:$} {}
#COND {^Physical cutting: (%d)$} {cutting = %1} {within|param=1}
#COND {^Physical blunt: (%d)$} {blunt = %1} {within|param=1}
#COND {^Armour status: %d$} {#if (@cutting < 100 and @blunt < 100) {smelt helm;#3 {take all commodity from forge}}} {within|param=1}
#COND {^Physical cutting: (%d)$} {cutting = %1} {within|param=1}
#COND {^Physical blunt: (%d)$} {blunt = %1} {within|param=1}
#COND {^Armour status: %d$} {#if (@cutting < 100 and @blunt < 100) {smelt helm;#3 {take all commodity from forge}}} {within|param=1}
Ashteru2006-11-07 14:19:33
QUOTE(Zarquan @ Nov 7 2006, 03:00 PM) 351784
Using ^ and $ should be restricted to matching only the beginning and ending of a line, not as newlines in the middle of a pattern. I think you've got the %d{var} syntax confused, too. If you want to assign the variable in the pattern, use something more like &%dcutting. Here's what I recommend:
CODE
#TRIGGER {^It offers the following defences:$} {}
#COND {^Physical cutting: (%d)$} {cutting = %1} {within|param=1}
#COND {^Physical blunt: (%d)$} {blunt = %1} {within|param=1}
#COND {^Armour status: %d$} {#if (@cutting < 100 and @blunt < 100) {smelt helm;#3 {take all commodity from forge}}} {within|param=1}
#COND {^Physical cutting: (%d)$} {cutting = %1} {within|param=1}
#COND {^Physical blunt: (%d)$} {blunt = %1} {within|param=1}
#COND {^Armour status: %d$} {#if (@cutting < 100 and @blunt < 100) {smelt helm;#3 {take all commodity from forge}}} {within|param=1}
Oooh, thanks!^^
Hrm, though a little problem, it doesn't actually execute what's in the if, but it still saves the values into the variables.
And just so I understand, the {within|param=1} part means that it's only executed if the line that's in front of that is there, right? So, it only will save blunt if it comes after cutting, and only if cutting comes after the "It offers the following defences:$". If so, why then not use param=2 and param=3 for the blunt and the Armour status line?
Unknown2006-11-07 16:10:20
Within is the type of trigger state. The parameter is 1. This means it'll fire on the next matching pattern, so long as it is "within" one line of the previous matched state, meaning it checks the next line and no further.
Within with a parameter of 2 or 3 would check all lines within 2 or 3 lines after the previously matched pattern, and advance to the next state as soon as it matches, if it doesn't match within the set parameter of lines, then the trigger resets to the starting state.
Within with a parameter of 2 or 3 would check all lines within 2 or 3 lines after the previously matched pattern, and advance to the next state as soon as it matches, if it doesn't match within the set parameter of lines, then the trigger resets to the starting state.
Unknown2006-11-07 17:52:45
I see now (checking "wp helm" in the game) that there's more than one space between the colon and the number on each of those lines. Add the rest of the spaces or do a %s wildcard, and it should work.
Shorlen2006-11-07 18:25:07
QUOTE(Zarquan @ Nov 7 2006, 12:52 PM) 351870
I see now (checking "wp helm" in the game) that there's more than one space between the colon and the number on each of those lines. Add the rest of the spaces or do a %s wildcard, and it should work.
CODE
#TRIGGER {^It offers the following defences:$} {}
#COND {^Physical cutting:%s(%d)$} {cutting = %1} {within|param=1}
#COND {^Physical blunt:%s(%d)$} {blunt = %1} {within|param=1}
#COND {^Armour status:%s%d$} {#if (@cutting < 100 and @blunt < 100) {smelt helm;#3 {take all commodity from forge}}} {within|param=1}
#COND {^Physical cutting:%s(%d)$} {cutting = %1} {within|param=1}
#COND {^Physical blunt:%s(%d)$} {blunt = %1} {within|param=1}
#COND {^Armour status:%s%d$} {#if (@cutting < 100 and @blunt < 100) {smelt helm;#3 {take all commodity from forge}}} {within|param=1}
EDIT: The above is because I know that Ash is lazy
Ashteru2006-11-07 22:06:09
Oooh, thanks guys, overlooked that after armourstats is a variable amount of spaces too. And now I know how to make multiline triggs, weeh. Thanks again. ^^