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
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Mon Dec 21, 2009 7:40 am   

z.var to access a db variable?
 
What is the syntax to access a db variable value through Lua?
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Mon Dec 21, 2009 1:11 pm   
 
Code:
#lua {print(zs.var["<DB Record name>"]["<DB Record Key>"])}

_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Mon Dec 21, 2009 6:16 pm   
 
Good grief. I was trying zs.var.db["key"].

Thanks
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Mon Dec 21, 2009 7:55 pm   
 
Hmmm it would be possible to use the %db function from lua, but there is no reason, (and in fact would be slower). The zs interface is very nice and converts hash tables for Db records to ones compatible with lua. additional string lists become numerical keyed hash tables so there is no need to use %item.
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Tue Dec 22, 2009 10:45 am   
 
I noticed it won't let me assign a value with zs.var["db"]["key"] = "blah blah".
Reply with quote
Zugg
MASTER


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

PostPosted: Mon Jan 04, 2010 6:03 pm   
 
Well, it Lua should allow the above syntax, but it will only update the local Lua copy of the table and not the stored CMUD database variable. There is no way to intercept the above Lua assignment to cause CMUD to update the underlying CMUD variable. It's just a restriction in the way the Lua API is handled in CMUD.
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