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
brrant
Beginner


Joined: 19 Nov 2008
Posts: 14

PostPosted: Sat Nov 22, 2008 10:12 pm   

Beginning lua scripting
 
Hi,

Can anyone point me to a resource or offer some tips on getting values say from a trigger passed into a lua script? I feel I'm missing something obvious so, sorry if that's the case.

If I have trigger that looks like
"^Contains the spells: (*)"
in the command line. Can I pass the value of the asterisk directly into a variable/table within a lua script? Or is the solution to have the trigger fire and capture the value into a #VA variable and then execute a lua based script when I've captured all of my #VA variables?

If the latter, or in either case for that matter :) could I get an example?

I've read the tutorial and I have a good book on Lua, just need some help working out how to pass data back and forth from lua scripts to the primary mud window.
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Nov 23, 2008 3:57 am   
 
Yeah, I need to finish that part of the tutorial. Basically, read this, that lets you access all of CMUD's normal functions. In this case you need the zs.param() function, or perhaps zs.params() for an alias.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
brrant
Beginner


Joined: 19 Nov 2008
Posts: 14

PostPosted: Sun Nov 23, 2008 5:11 am   
 
Slick. I've bookmarked the page.

I'll have to play with it to figure out how things work, but thanks for giving me the next breadcrumb. (or a bit more)

BTW.. Kudos on the tutorial. It's good reading and for our purposes (mud scripting, is very concise.) I picked up Programming Lua and while I'm less than 100 pages into it, everything you wrote agrees. (minus about 80 pages of who/what/when/where/why which when scripting, is a great thing.)

I'm too aware of how negative feedback stops me from offering more to my users, I'm in IT for a quote, living, unquote. Doc's are the least appealing part.

So thanks. :)
Reply with quote
brrant
Beginner


Joined: 19 Nov 2008
Posts: 14

PostPosted: Sun Nov 23, 2008 10:11 pm   
 
Ok, I'm now able to get lua code to function in an alias, but when I attempt a trigger with the pattern "^Contains the spells: (*)" it will not fire. The same trigger with zscript selected will fire so I believe I have the pattern correct, but when I select Lua as sthe scripting language it does not fire at all.

I even tried trimming it back to "^Contains the spells:" but still get nothing.

Is there a different syntax I need to use for trigger patterns if the scripting language is Lua?
Reply with quote
brrant
Beginner


Joined: 19 Nov 2008
Posts: 14

PostPosted: Mon Nov 24, 2008 12:21 am   
 
Now it's working.

I had default script language set to zscript. I had the script language for that trigger set to Lua though, odd that it didn't work. Once I changed the default language to Lua, deleted the old trigger and created new it began working.
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