|
GeminiWood Newbie
Joined: 04 Nov 2019 Posts: 2
|
Posted: Mon Nov 04, 2019 1:43 am
Need some help figuring out a multi-line trigger, conditional and if set. |
So, I'm trying to figure out how to set up a trigger and conditional set that activates when the mud returns:
The corpse of (mob name) contains:
(Weak magic) a pair of scale mail gloves
(Weak magic) the glowing zircon amulet
a roughly made wooden bucket
a rough skirt of homespun red fabric
(Moderate magic) studded leather gloves
a rough homespun shirt of dull green
<player info>
Basically, I need it to activate on the first line, then conditionally look through the items until a blank line returns, looking for Moderate magic|Potent magic|Powerful magic|Artifact magic|Magical * item *, such as
(Moderate magic) studded leather gloves
then grab the magic item, with a set of possible keywords (ring, amulet, leather, cloth, etc.) and put them in a bag, but not the (Weak magic) items.
Then it needs to end the conditional status when a blank line is returned, and reset to the primary trigger.
Any ideas? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Mon Nov 04, 2019 10:58 pm |
Something like this should work:
Code: |
#TR {The corpse of * contains:} {}
#COND {*} {#IF (%len(%trim(%line))>3) {
#STATE 1
#IF (%match(%line, "Moderate magic|Potent magic|Powerful magic|Artifact magic|Magical")) {
$keyword=%word(%line, %numwords(%line))
get $keyword
put $keyword in bag
}}} {within|param=1} |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
GeminiWood Newbie
Joined: 04 Nov 2019 Posts: 2
|
Posted: Sat Nov 09, 2019 9:45 am |
Code:
Code: |
#TR {The corpse of * contains:} {}
#COND {*} {#IF (%len(%trim(%line))>3) {
#STATE 1
#IF (%match(%line, "Moderate magic|Potent magic|Powerful magic|Artifact magic|Magical")) {
$keyword=%word(%line, %numwords(%line))
get $keyword
put $keyword in bag
}}} {within|param=1} |
This is some fantastic and concise programming. I was wondering if there is a way to have an OR or an AND function in the pattern.
For example, in line 4 :
#IF (%match(%line, "Moderate magic" OR "Potent magic" OR "Powerful magic" OR "Artifact magic")) {
and then a second set of parameters for the AND function, such as
#IF (%match(%line, "cloth" OR "ring" OR "amulet")) {
So an item has to have 1 item from the first set of parameters AND 1 item from the second set to trigger the next set of commands.
Or do I need to set up an IF command dependent, such as IF "Moderate", subsidiary IF "cloth", IF "ring", etc.?
I'm not sure if I'm explaining this well.
Right now, without knowing the scripting for proper AND/OR components, this is the type of solution I have come up with:
Code: |
#IF (%len(%trim(%line))>3) {
#STATE 1
#IF (%match(%line, "Moderate magic")) {
#IF (%match(%line, "ring")) {
$keyword=%word(%line,%numwords(%line))
get $keyword
put $keyword in bag
}
#IF (%match(%line, "amulet")) {
$keyword=%word(%line,%numwords(%line))
get $keyword
put $keyword in bag
}}
#IF (%match(%line, "Potent magic")) {
#IF (%match(%line, "ring")) {
$keyword=%word(%line,%numwords(%line))
get $keyword
put $keyword in bag
}
#IF (%match(%line, "amulet")) {
$keyword=%word(%line,%numwords(%line))
get $keyword
put $keyword in bag
}}} |
Functional, but quite inelegant. Thanks. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4692 Location: Pensacola, FL, USA
|
Posted: Sun Nov 10, 2019 12:16 am |
Unfortunately, you have to make it redundantly long like this:
Code: |
#IF ((%match(%line, "Moderate magic")) OR (%match(%line, "Potent magic")) OR (%match(%line, "Powerful magic")) OR (%match(%line, "Artifact magic"))) {stuff} |
However, my earlier version:
Code: |
#IF (%match(%line, "Moderate magic|Potent magic|Powerful magic|Artifact magic|Magical")) {stuff} |
treated them all as an anonymous variable (the pipe symbol "|" is used to separate members of a list) and checked against that instead, essentially the same thing.
Though if that is not working try:
Code: |
#IF (%match(%line, "{Moderate magic|Potent magic|Powerful magic|Artifact magic|Magical}")) {stuff} |
The next part, the 'stuff' we should try to avoid redundancy in code #IF possible:
Code: |
#LOCAL $keyword
#SWITCH (%match(%line, "({ring|amulet})", $keyword)) {#NOOP} {$keyword=%word(%line,%numwords(%line))}
get $keyword
put $keyword in bag |
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
|
|
|
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
|
|