|
Tharius Beginner
Joined: 15 Apr 2013 Posts: 24
|
Posted: 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? |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4689 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
Tharius Beginner
Joined: 15 Apr 2013 Posts: 24
|
Posted: 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. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4689 Location: Pensacola, FL, USA
|
Posted: 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 |
|
|
|
Tharius Beginner
Joined: 15 Apr 2013 Posts: 24
|
Posted: 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. |
|
|
|
Tharius Beginner
Joined: 15 Apr 2013 Posts: 24
|
Posted: 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. |
|
|
|
|
|