 |
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Tue Feb 02, 2010 12:35 pm
Can someone help me with a conditional trigger? |
I am trying to write a trigger that matches text from a list of courier jobs to enable them to be completed automatically. Here is the work list from the MUD:
1664. From Venus to Titan - 75 tons of Fruit - 7gtu 11ig/tn 2hcr
1665. From Earth to Paradise - 75 tons of Weapons - 6gtu 11ig/tn 2hcr
1666. From Arovia to Tropicana - 75 tons of Holos - 7gtu 11ig/tn 2hcr
1667. From Brass to Mercury - 75 tons of Nickel - 7gtu 11ig/tn 2hcr
1668. From Brass to Mars - 75 tons of RNA - 7gtu 10ig/tn 2hcr
1669. From Sumatra to Earth - 75 tons of TQuarks - 6gtu 8ig/tn 2hcr
1670. From Roblox to St Thomas - 75 tons of Probes - 8gtu 8ig/tn 2hcr
1671. From Mars to Doris - 75 tons of Spices - 6gtu 9ig/tn 2hcr
1672. From Battle School to Razorsharp - 75 tons of Musiks - 9gtu 10ig/tn 2hcr
1673. From Phobos to Rhea - 75 tons of Hides - 7gtu 9ig/tn 2hcr
1674. From Phobos to Brass - 75 tons of BioChips - 7gtu 8ig/tn 2hcr
1675. From Mars to Venus - 75 tons of Weapons - 7gtu 10ig/tn 2hcr
1676. From Selena to Rhea - 75 tons of Polymers - 9gtu 9ig/tn 2hcr
1677. From Selena to Rhea - 75 tons of Cereals - 9gtu 10ig/tn 2hcr
1678. From Mercury to Magellan - 75 tons of Weapons - 4gtu 55ig/tn 2hcr
1679. From Evil to Stormy - 75 tons of Nickel - 6gtu 10ig/tn 2hcr
1680. From Mars to Brass - 75 tons of Alloys - 6gtu 8ig/tn 10hcr
The first number is the job ID, then it tells you which planet to collect from, which to deliver to and then a few misc details of the job which are not important here.
This is my pattern match:
(%d). From (%w) to (%w) - *
And this is the subsequent script:
#variable jobno %1
#variable fromplanet %2
#variable toplanet %3
#if (%ismember(@fromplanet,@sollist)) {board
goto @fromplanet
board
ac @jobno
#execute toak@fromplanet
collect
#execute fromak@fromplanet
board
goto @toplanet
board
#execute toak@toplanet
deliver
#execute fromak@toplanet}
I need to check @fromplanet against a list because I only want to accept certain jobs. When the pattern matches it runs the script correctly and all is well. The problem that I have is that when it returns FALSE on the check of @fromplanet against @sollist it does nothing. I want it to go on to the next item in the list until it returns TRUE and runs the script. However I only ever want it to run once in sequence because you can only do one job at a time.
Can anyone tell me how to do this?
Thanks! |
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Tue Feb 02, 2010 2:10 pm |
From my reading of the script, it should already be doing this. In fact, my reading of it is that this trigger should be spamming the delivery of every single acceptable job. Here is what it looks like it should be doing:
First (or next) line from mud runs through trigger.
If @fromplanet is not in @sollist, it does nothing, otherwise it spits out the commands for doing the job
Trigger processing ends
Next line from mud runs through trigger
Repeat for all lines.
If there are 6 acceptable jobs in the list, by the time Cmud has processed all of the lines from the mud it should have spit out commands for all six jobs. I'm not sure whether that's what you actually want it to do. If it's not doing that, I'm not sure what's happening. Are you disabling the trigger or anything like that? |
|
|
|
 |
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Tue Feb 02, 2010 6:53 pm |
Hi Rahab,
Thanks for the help. If there are 6 acceptable jobs in the list then I only want the commands to run for the first trigger, otherwise it overloads the mud. The job list is generated by typing "work" into the mud and then it lists up to 20 jobs. So I want to type "work" and then autorun against the first acceptable job in the list and then stop. Then I can type "work" again and repeat. This script has to be supervised because the MUD has many in-built, random features to prevent fully automated scripts.
At the moment it works 95% of the time but sometimes I will type "work", the list is received and the first job is not in @sollist and nothing happens. It doesn't matter how many times I re-list by typing "work" the commands do not fire because it checks the first job against @sollist which comes back FALSE and then it just stops. All I can do is wait until the list cycles and the first job is acceptable and then it runs ok.
I hope this makes sense. |
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Wed Feb 03, 2010 4:09 pm |
That's very weird. Yes, that script should do nothing on the first line when that job is not on the list. But then the next line should be read by Cmud, which should start the trigger again, on the new line. This script should be running on _every_ line that matches. In my own test, it works fine.
However, I do see an error in your trigger pattern. Some of your planets have two words in their name. %w won't work for that. Perhaps that is the real problem? Use this pattern instead:
| Code: |
| (%d). From (*) to (*) - |
Now, to keep this from running on _every_ line, you need to have the trigger turn itself off once it has found a job it likes. Give your trigger an ID, like jobtrigger. Then, add a line inside the #if statement to turn the trigger off. It will look like this:
| Code: |
#variable jobno %1
#variable fromplanet %2
#variable toplanet %3
#if (%ismember(@fromplanet,@sollist)) {
#t- jobtrigger
board
goto @fromplanet
...etc...
|
Finally, you need to do "#t+ jobtrigger" when you execute the "work" command, so that the trigger will start running again. |
|
|
|
 |
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Thu Feb 04, 2010 7:38 pm |
Thanks a lot for the help, I really appreciate it.
|
|
|
|
 |
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Sat Feb 06, 2010 5:48 pm |
If @fromplanet it not in @sollist then the #if evaluation is false and the script does nothing.... exactly as expected. The problem then is that the trigger will not fire until the top line of the work list is evaluated by the #IF evaluation as true.
Is there a way to make the trigger look to the next line of the work list and so on until it evaluates the #IF command as true and fires the commands? |
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Feb 08, 2010 3:27 pm |
I don't understand. What you presented as the mud output is a series of lines with a particular format. Your trigger matches that format, so it should fire on _every_ line that matches, not just the top one. This is what you said the mud outputs:
| Code: |
1664. From Venus to Titan - 75 tons of Fruit - 7gtu 11ig/tn 2hcr
1665. From Earth to Paradise - 75 tons of Weapons - 6gtu 11ig/tn 2hcr
1666. From Arovia to Tropicana - 75 tons of Holos - 7gtu 11ig/tn 2hcr
1667. From Brass to Mercury - 75 tons of Nickel - 7gtu 11ig/tn 2hcr
1668. From Brass to Mars - 75 tons of RNA - 7gtu 10ig/tn 2hcr
1669. From Sumatra to Earth - 75 tons of TQuarks - 6gtu 8ig/tn 2hcr
1670. From Roblox to St Thomas - 75 tons of Probes - 8gtu 8ig/tn 2hcr
1671. From Mars to Doris - 75 tons of Spices - 6gtu 9ig/tn 2hcr
1672. From Battle School to Razorsharp - 75 tons of Musiks - 9gtu 10ig/tn 2hcr
1673. From Phobos to Rhea - 75 tons of Hides - 7gtu 9ig/tn 2hcr
1674. From Phobos to Brass - 75 tons of BioChips - 7gtu 8ig/tn 2hcr
1675. From Mars to Venus - 75 tons of Weapons - 7gtu 10ig/tn 2hcr
1676. From Selena to Rhea - 75 tons of Polymers - 9gtu 9ig/tn 2hcr
1677. From Selena to Rhea - 75 tons of Cereals - 9gtu 10ig/tn 2hcr
1678. From Mercury to Magellan - 75 tons of Weapons - 4gtu 55ig/tn 2hcr
1679. From Evil to Stormy - 75 tons of Nickel - 6gtu 10ig/tn 2hcr
1680. From Mars to Brass - 75 tons of Alloys - 6gtu 8ig/tn 10hcr |
I have tested my trigger by inputting exactly those lines, and the trigger does test every single line. If it is only firing on the first line for you, then either you are doing something else, or the mud output is not quite what you said. |
|
|
|
 |
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Mon Feb 08, 2010 8:52 pm |
Yes that output is exactly what the MUD produces. I think I might know what it is....
I have set the trigger up as a #COND of a previous trigger that matches "Work available from Armstrong Cuthbert:"
Is that what is blocking the trigger from firing again? |
|
|
|
 |
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: Mon Feb 08, 2010 9:29 pm |
Yes, that is your problem. What you have is not a separate trigger, but a substate of the multistate trigger you have created. You should have given us the entire trigger, not just the substate. A multistate trigger works like this: The first state is active, and tested against lines. If it matches, it performs its actions and switches to the next state, and the second state is tested against lines. Once that one matches, it performs its actions and goes on to the next state, and so on. Only one state of a multistate trigger is active at a time. Once the last state matches, it goes back to the first state.
There are several ways you could fix this. First, you could give up on using a multistate trigger. Make the condition into a separate trigger, normally disabled. Have the first trigger enable the second, and have the second disable itself once it finds a job it likes. This is the method as I described above. This is the easier method if you don't really understand multistate triggers.
Another way you could do it is to keep it as a multistate trigger, but change the type of the second state from "pattern" to "manual". In this case, you put a command within the #if statement to manually change the state back to the first state. The command would be something like:
|
|
|
|
 |
Altman Beginner
Joined: 02 Feb 2010 Posts: 16
|
Posted: Tue Feb 09, 2010 7:03 pm |
Thanks for the continued help and apologies for not giving you the full trigger details at the outset.
|
|
|
|
 |
|
|
|