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


Joined: 15 Apr 2013
Posts: 24

PostPosted: Wed Nov 03, 2021 7:13 pm   

Lua Script in Alias causing illegal token error
 
Hello all, wrote a script in luaEdit and then brought it into cmud but I'm unable to get it to run and wonder if anyone has some insight.

The variable holding a string list is defined in cmud.

c = zs.var.c
d = zs.var.d
w = {}
n = 0

for k,v in ipairs(c) do
n=n+1
w[n] = v
end

This code throws an illegal token error on the for k,v line, specifically saying (c) ... if I remove the brackets the error will shift to the n+1 section.

I could easily rewrite this all to zscript, but that wasn't the point, this was an attempt to use the built in lua support.

Any thoughts?
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Wed Nov 03, 2021 8:54 pm   
 
Did you set the language of the script to lua?
Should be a drop down list just to the right of the alias name
_________________
Discord: Shalimarwildcat
Reply with quote
Tharius
Beginner


Joined: 15 Apr 2013
Posts: 24

PostPosted: Wed Nov 03, 2021 10:15 pm   
 
shalimar wrote:
Did you set the language of the script to lua?
Should be a drop down list just to the right of the alias name


Yes, absoutely.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4691
Location: Pensacola, FL, USA

PostPosted: Wed Nov 03, 2021 10:21 pm   
 
Can you print c and see the correct value before doing ipairs?
Have you tried just using pairs?
_________________
Discord: Shalimarwildcat
Reply with quote
Tharius
Beginner


Joined: 15 Apr 2013
Posts: 24

PostPosted: Wed Nov 03, 2021 10:25 pm   
 
shalimar wrote:
Did you set the language of the script to lua?
Should be a drop down list just to the right of the alias name


Very odd, I moved it to a function and the script ran without an error.
Reply with quote
Tharius
Beginner


Joined: 15 Apr 2013
Posts: 24

PostPosted: Wed Nov 03, 2021 10:28 pm   
 
Yes, I did and could see c correctly ... and d as well. The zs object was alive and well.

I think this may be some sort of UI bug. I changed the language to Lua and then pasted my script into an alias, and it works.

Thanks for trying to help debug this, Now I just need to remember that Lua's 0th element is null in a cmud stringlist and I"ll be ok.
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