|
Ashur Novice
Joined: 25 Jul 2011 Posts: 39
|
Posted: Mon Jul 25, 2011 4:24 pm
Trigger help |
Hello,
I'm attempting to write a trigger with some conditionals in it. Whenever the trigger attempts to fire I get the message "ERROR: Trigger "You have finished forging the" fired but did not compile"
I was wondering if anyone could help me determine why the trigger is not compiling. I haven't been able to find any good examples to learn from.
The trigger looks like this
Code: |
#TRIGGER{You have finished forging the longsword.}{put sword in pack; get bar}
#IF( %line =~ "Get what?")
{
get pack;
drop tools;
}
//else
{
get leather;
drink from large barrel;
forge longsword;
} |
Any assistance would be fantastic and greatly appreciated.
Thank you in advance.
} |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Jul 25, 2011 8:49 pm |
Your spacing is a bit messed up, and most of the code isn't even in the trigger... but your code doesn't really make sense either, if the line matches You have finished forging the longsword. it likely won't also match Get what?. I think you're trying to match the Get what? on a separate line? If that's the case, you should look into multistate triggers. If not, this code should fix the spacing issues:
Code: |
#TRIGGER {You have finished forging the longsword.} {put sword in pack;get bar
#IF ( %line =~ "Get what?")
{
get pack
drop tools
}
//else
{
get leather
drink from large barrel
forge longsword
}
} |
|
|
|
|
Ashur Novice
Joined: 25 Jul 2011 Posts: 39
|
Posted: Mon Jul 25, 2011 9:03 pm |
Ah, I suppose I should explain what I'm going for then. I thought I understood the basic concept, but it seems I'm still a bit off.
-On "You have finished ...." I want to 'put sword in pack; get bar;'
Then,
-if I get "Get what?" back, I want to 'get pack;drop tools'
-otherwise (specifically if I get "You get an iron bar" but I wanted to get a basic working trigger in place before I added a second "if") I want to 'get leather;drink from large barrel; forge longsword'.
Hopefully that makes sense...Thank you for your help so far. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Jul 25, 2011 9:17 pm |
Yeah, you want a multistate trigger for that.
|
|
|
|
Ashur Novice
Joined: 25 Jul 2011 Posts: 39
|
Posted: Mon Jul 25, 2011 9:21 pm |
Okay, so the first state will be the "You have finished" portion ... and the second state will contain my conditional?
Is this correct? I'm still fairly new to this scripting thing, and I can't find any good examples on the web. |
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: Mon Jul 25, 2011 9:25 pm |
Right...the problem with your code is that %line, when used in that first trigger, is still the 'You have finished' line. You need a second trigger for the get what line. As for examples, check out this page from the CMUD documentation, about multistate triggers.
|
|
|
|
Fizgar Magician
Joined: 07 Feb 2002 Posts: 333 Location: Central Virginia
|
Posted: Mon Jul 25, 2011 10:01 pm |
If after reading the help on multi-state triggers, if you are still lost here is an example that relates to your situation.
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<trigger name="forge_longsword" param="3" priority="10" copy="yes">
<pattern>^You have finished forging the longsword.</pattern>
<value>put sword in pack
get bar</value>
<trigger type="Manual" param="6">
<pattern>(*)</pattern>
<value>#switch (%1 =~ "You get an iron bar") {get leather;drink from large barrel;forge longsword;#state forge_longsword 0}
(%1 =~ "Get What?") {get pack;drop tools;#state forge_longsword 0}</value>
</trigger>
</trigger>
</cmud> |
Edit: I forgot the command to reset the state after the conditionals were met.
Edit2: I changed the trigger ID to something more sensible. This should be the last edit. |
|
_________________ Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34 |
|
|
|
|
|