|
Metho Beginner
Joined: 10 Jul 2005 Posts: 28
|
Posted: Mon Dec 24, 2007 4:24 pm
Infinite loop - not sure why... |
Still getting used to CMUD, but I'm not sure why this sends me into an infinite loop. Note that the text the mud sends does match the trigger pattern, I've reconfirmed this.
Code: |
<alias name="tov" id="169">
<value>#VAR alldone 0
#T+ packTrig
#UNTIL (@alldone = 1) {take %1 from pack}
</value>
</alias>
<trigger name="packTrig" priority="1700" enabled="false" id="170">
<pattern>{A|An} * doesn't contain that.$</pattern>
<value>alldone = 1
#T- packTrig</value>
</trigger> |
An example of the text that occurs when you try to take something out of a container and it doesn't exist: An icy pack of frosted silver doesn't contain that.
Maybe I'm misunderstanding how #UNTIL works, but I thought I had it. |
|
|
|
iljhar GURU
Joined: 10 Oct 2000 Posts: 1116 Location: USA
|
Posted: Mon Dec 24, 2007 4:51 pm |
The problem is that CMUD is running the loop as fast as it can and you want it to run in terms of the information you receive from the mud, so you'll have to adjust your thinking a bit. Drop the #until loop inside the alias, then create a 2nd trigger that signals you've taken something out of your pack. Something like this:
Code: |
#alias tov {#T+ packClass;thing = %1;get @thing from pack}
#trigger {{A|An} * doesn't contain that.$} {#T- packClass} packClass
#trigger {You get * from *.$} {get @thing from pack} packClass
#variable thing "" _nodef packClass |
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Tue Dec 25, 2007 8:04 pm |
To explain in slightly more detail, CMUD is using up all its processing time on the #until loop - the alldone=1 line gets queued behind the until loop, waiting for the loop to finish before it executes. You could avoid this problem by running the alldone=1 line in a separate thread, but it's a much less robust solution that iljhar's. It also opens a whole new keg of problems, most of which, especially since you're still getting used to CMUD, you'll want to avoid.
|
|
|
|
|
|