Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Fizgar
Magician


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

PostPosted: Fri Oct 15, 2010 11:22 pm   

3.31 luaCOM: Passing class names to the GetVar() function
 
This is a continuation of this post:
http://forums.zuggsoft.com/forums/viewtopic.php?t=36112&sid=c13e768fbcfe252a73490549cf50e121

I am using lua 5.1 outside of CMUD to access variables from my CMUD session.

The GetVar() function that is a member of the cMUDSession class, doesn't seem to be handling the class name parameter correctly as listed in the object notes.

I am using CMUD 3.31 and LUA 5.1.

CMUD XML:
Code:
<window name="untitled">
  <uid>{189D4896-7EAC-4B2B-A43D-3D30FD973F19}</uid>
  <packages>untitled</packages>
  <class name="class" id="1"/>
  <var name="test" id="2">This is a test</var>
</window>


Lua Script:
Code:
require("luacom")
require("luacom5")

local data = 1

if data == 1 then
  cmud = luacom.CreateObject("cMUD.Application")
  cmuds = cmud.CurrentSession
  var = cmuds.GetVar("test", "test")
  val = var.value
end
 
print(val)


The test variable is not in a class called test. However this is still the only way I can access the value of the variable. If I go into CMUD and move the test variable to the class named class nothing I try will let me access it then.
_________________
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: Fri Oct 15, 2010 11:46 pm   
 
The name of your class is "class". So the correct code is:
Code:
  var = cmuds.GetVar("test", "class")
  val = var.value

To test this within CMUD itself, I just tried this test code:
Code:
  <class name="class" id="1">
    <var name="test" id="2">123</var>
  </class>
  <alias name="go" id="3">
    <value>var = %session.GetVar("test","class")
#SHOW @var.value</value>
  </alias>

and when I type "go" it properly displays 123 like it should.
Reply with quote
Fizgar
Magician


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

PostPosted: Sat Oct 16, 2010 12:04 am   
 
Any clue why it will not work outside of CMUD, using the correct class name in the function? I am running this lua script in a different program to access variables created in CMUD. So while your example works, it is CMUD specific which does not help much when trying to access the function from another program.
_________________
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 Oct 18, 2010 5:04 pm   
 
I have no idea. While my test script was written within CMUD, the %session variable is just a pointer to the COM cmud.CurrentSession variable. Maybe the Lua COM library isn't passing the string values using proper OLE strings or something like that. The CurrentSession.GetVar routine is part of the CMUD COM server and doesn't care if it's being called from within zScript or from an external program. That's the whole point of COM.

Maybe somebody else could try this in another programming language to see if the problem is with the Lua COM stuff or with CMUD. But the Session.GetVar code has actually been around a long time (since the zMUD days) and hasn't changed.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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