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


Joined: 10 Jun 2008
Posts: 1

PostPosted: Tue Jun 10, 2008 12:08 pm   

LUA: How it interacts with CMUD
 
Hello,

I'm new to cmud and would like to write my scripts using lua, but the tutorial ends right where it got interesting.
I can't seem to find any info on how to capture text from the mud using lua.

To be specific:
If I wanted to capture the text 'You are hungry.' in a variable, how would I go about it?

Thanks in advance,
Nongolf.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Jun 10, 2008 12:15 pm   
 
Hah, yes. Sorry about that - I keep meaning to get around to finishing it, and never do. It depends what you want to do with the text, of course.

If you want to just run some Lua code whenever you get the text "You are hungry", just make a trigger where the pattern is "You are hungry" and the script is whatever code you want run (with Lua selected from the script dropdown). If you want to do some sort of parsing on the text - say, when you receive "You get 285 gold." where 285 is any number, you use a pattern of "You get (%d) gold" (see also) and then refer to the value inside the brackets with the function zs.param(1), which works exactly the same as the %param zScript function. You could, say, add it to a variable with var=var+zs.param(1).

Full documentation of CMUD's lua interface is here.
_________________
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