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
onnoj
Newbie


Joined: 24 Jun 2011
Posts: 4

PostPosted: Sun Jul 17, 2011 3:54 pm   

Bug: #WAITFOR does not function in LUA (cMud 3.34)
 
The following code will immediately print 'Banana' when executed in the LUA console (or in any LUA script):
Code:
zs.cmd.waitfor(".*dragon.*"); print("Banana!");


Interestingly, zs.cmd.wait(x) does work.

I'm running CMud 3.34 on Windows 7 64-bit. It's the trial version (still considering a purchase).
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Sun Jul 17, 2011 4:16 pm   
 
The alias below uses waitfor in LUA with the code you had above just fine.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="test" language="Lua" copy="yes">
    <value>zs.cmd.waitfor(".*dragon.*")
print ("Banana!")</value>
  </alias>
</cmud>


Execute the alias then on the command line type:
Code:
#show {the .bluedragon.}

Banana! will then be printed.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
onnoj
Newbie


Joined: 24 Jun 2011
Posts: 4

PostPosted: Sun Jul 17, 2011 4:23 pm   
 
Ah, in that case the bug is when an alias or function is evoked from LUA; ie:
Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="testa" language="Lua" copy="yes">
    <value>zs.execalias("testb");</value>
  </alias>
  <alias name="testb" language="Lua" copy="yes">
    <value>print ("Waiting");
zs.cmd.waitfor(".*dragon.*")
print ("Banana!")</value>
  </alias>
</cmud>


Executing alias 'testa' (which invokes testb) shows that 'Banana' is immediately printed.
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Sun Jul 17, 2011 4:44 pm   
 
It seems like this is more of a problem with the way CMUD executes aliases using LUA. With what you just posted if you type testb on the command line then feed CMUD a string that will trigger the waitfor everything works fine. if you type testa, the testb alias fires but the waitfor is ignored. Likewise if you open the package editor and right click the testb alias then click the execute script option from the drop down menu, the script is run but the waitfor is ignored there as well. Something definitely seems buggy here.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Mon Jul 18, 2011 5:54 pm   
 
Yeah, it's going to be very difficult to make this work. All of the "thread" commands, such as #WAITFOR, #WAITSIGNAL, #WAIT, etc use threads within CMUD. Lua scripts themselves run in their own Lua thread. So it's very difficult to tie an additional CMUD thread back to the original Lua script. Basically, by the time your #WAITFOR matches, the original Lua script thread is gone. Also the #WAITFOR doesn't have any way to "pause" the original Lua script, so it just keeps running.

I'm afraid this is just one of those areas where you can't use Lua and need to use the zScript language to do what you want, sorry.
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