Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Metho
Beginner


Joined: 10 Jul 2005
Posts: 28

PostPosted: 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.
Reply with quote
iljhar
GURU


Joined: 10 Oct 2000
Posts: 1116
Location: USA

PostPosted: 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
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: 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.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
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

© 2009 Zugg Software. Hosted by Wolfpaw.net