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


Joined: 21 Sep 2008
Posts: 10

PostPosted: Sun Oct 12, 2008 6:25 pm   

Lua and %x1..%x99 predefined variables
 
How can I get %x1..%x99 values inside of Lua script? I want to call zs.cmd.pcol().
Reply with quote
yawdoolf
Beginner


Joined: 21 Sep 2008
Posts: 10

PostPosted: Sun Oct 12, 2008 11:10 pm   
 
I've solved this problem by zs.cmd.execute (or zs.exec).
This command lets you do anything, but I don't think that it's efficient due to additional parsing.

I think that there could be functions zs.sys.x1() .. zs.sys.x99() returning two values (XStart XEnd).
Then Lua code could be like that:
Code:
xstart, xend = zs.sys.x1()
zs.cmd.pcol(color, xstart, xend)
or
Code:
zs.cmd.pcol(color, zs.sys.x1())

What do you think?
Reply with quote
Daagar
Magician


Joined: 25 Oct 2000
Posts: 461
Location: USA

PostPosted: Mon Oct 13, 2008 3:06 am   
 
From what I'm seeing in the docs, it appears you can get at those predefined variables simply via zs.x1(), zs.x2(), etc. When using the zs object, it will look for commands first of that name, then functions, then predefined variables. So long as you haven't created any commands or functions with the name x1, zs.x1() should find it - or you can get at it specifically just as you described via zs.sys.x1().
Reply with quote
yawdoolf
Beginner


Joined: 21 Sep 2008
Posts: 10

PostPosted: Mon Oct 13, 2008 7:17 pm   
 
I doesn't work. I've just used "print(zs.sys.x1())" and got error.

Does it work with you?
Reply with quote
Seb
Wizard


Joined: 14 Aug 2004
Posts: 1269

PostPosted: Tue Sep 05, 2023 9:06 pm   
 
Thank you Daagar for putting me on a track to finding the solution. For anyone else searching for this, this does work in Lua for GMCP (if you have GMCP enabled and the GMCP package on your MUD is like this of course):
Code:
local channel = zs.gmcp.Comm.Channel.Text.channel

The predefined variable equivalent would be %gmcp.Comm.Channel.Text.channel in zScript. So this is an example as a guide.
Note, this does not work with the parentheses:
Code:
local channel = zs.gmcp.Comm.Channel.Text.channel()
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