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


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Jan 06, 2008 5:52 am   

Cmud[2.18] Access Violation in Lua when using zs.cmd.call
 
I created 2 aliases Alias A and Alias B.

This error occurs when you use zs.cmd.call twice on zs.func.vartype.

The following is the xml for them.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="a" language="Lua">
    <value>print("Alias A")
zs.cmd.unvar("data")
zs.cmd.var("data","test=1")
print(zs.func.vartype("data"))
zs.cmd.call(zs.func.vartype(var,5))
print(zs.func.vartype("data"))
zs.cmd.call(zs.func.vartype(var,5))</value>
  </alias>
  <alias name="b" language="Lua">
    <value>print("Alias b")
zs.cmd.unvar("data")
zs.cmd.var("data","test=1")
print(zs.func.vartype("data"))
zs.func.vartype(var,5)
print(zs.func.vartype("data"))
zs.func.vartype(var,5)
print(zs.func.vartype("data"))</value>
  </alias>
</cmud>


First I ran alias b then I ran alias a.

Running A always creates the error. Running B never does.

I tried sending an automated error report but it would not work this go round.
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Sun Jan 06, 2008 6:55 am   
 
The #call command recieves an expression argument. In terms of calling zScript from Lua, this argument will be a string, albeit one that's later parsed by the zScript parser. Your code, when used in conjunction with the #call command, must be in zScript. What you're passing there is a Lua function object, which the #call command has no idea how to handle, hence the error. Your second one is the correct way to do this, so there's no error. An illustrative example:

Code:
zs.cmd.call('%vartype(somevar,5)')
should work
zs.cmd.call(zs.func.vartype("somevar",5))
won't


But also, why are you using a CMUD variable (and a database variable especially)? If your code's in Lua, use a Lua table.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Arminas
Wizard


Joined: 11 Jul 2002
Posts: 1265
Location: USA

PostPosted: Sun Jan 06, 2008 7:50 am   
 
My point was that if I alter the A alias to only using the call once it DOES work. If I use it twice in the same alias
it throws the error.

And as I have been trying to make something that I will post in the General discussion forum shortly I attempted to use call to call a function silly me. Rolling Eyes
_________________
Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram
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