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


Joined: 22 Dec 2008
Posts: 5

PostPosted: Mon Dec 22, 2008 1:59 am   

Buttons & Lua
 
I'm not having much luck making buttons work with Lua.
I change the language to Lua, but that only seems to affect the script that runs when I click the button.
I'd like to set the caption with a Lua expression. Same thing with the various expressions expected in gauges--using Lua expressions just doesn't work.

Am I not seeing something, or is it even possible at the moment?
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Mon Dec 22, 2008 2:52 am   
 
The language selection applies only to the button's script at the moment, not any of its captions. It's perhaps something that could be looked at in the future, but it has a number of associated problems, chief of which is that CMUD monitors its own variables when they're used in captions or gauges so that the GUI can be updated when they change - it doesn't do this kind of monitoring with Lua variables.

There're two possible workarounds - either your expression is simple, in which case using zScript for the caption would probably be better in the first place, or it's complex and needs to use Lua, in which case you're probably best to have your script update a zScript variable every time the expression in question changes, and then use that variable in the caption.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
derekperrault
Newbie


Joined: 22 Dec 2008
Posts: 5

PostPosted: Mon Dec 22, 2008 3:55 am   
 
That makes sense about CMUD monitoring and updating the captions/gauges as variables change.

And to be honest, I was just trying to keep my classes free of clutter. I don't really care to see all those simple numeric variables my prompt creates... I'd rather have them in a Lua "stats" table.

I think it'd make a great addition. Thanks for the workarounds.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Dec 22, 2008 5:58 pm   
 
There are other ways to keep your classes free from clutter. For instance, perhaps a database variable would work to hold the values from your prompt?
Reply with quote
derekperrault
Newbie


Joined: 22 Dec 2008
Posts: 5

PostPosted: Mon Dec 22, 2008 7:51 pm   
 
Database variable? I play a pretty involved combat mud. I'm not one to prematurely optimize, but that really seems like a recipe for slow-down. It's a good idea, but I think I'd rather just clutter up a "Gauge" class with some variables I won't use elsewhere.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Dec 22, 2008 9:34 pm   
 
Ah. Yes, I forgot you were talking about gauges. Values within a database variable won't work for a gauge.
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