Home › Forums › General › Programming › how to write a right Lua script (in general)
- This topic has 8 replies, 2 voices, and was last updated 11 years, 2 months ago by atom.
-
AuthorPosts
-
February 9, 2013 at 2:15 pm #6283
I wanted to write a Lua script to open a file from a panel, so I turned to the documentation and found CtrlrLuaUtils > openFileWindow(). Just what I needed, I thought. I even found out how to format the necessary parameters (4 in this case). But then I was stuck. I tried “panel: CtrlrLuaUtils():openFileWindow (“Open File”, File(“”),”*.*”,true) and this compiled OK, but gave ‘a nil value’ error and the method was disabled. Then I looked further on this forum and found this thread: “Home › Forums › General › Programming › saving/loading data to a file” and this helped me to write the right script format, being file = utils.openFileWindow(….. etc. My question now is where can I find that one has to put (in this case) specifically ‘utils’ with a dot before ‘openFileWindow’ or more in general how to ‘compose’ the right sequence of ‘statements’ using the right prefixes or suffixes?
February 12, 2013 at 11:23 am #6323Maybe my question is not clear. So let me rephrase the question 😉 Is the syntax of Lua for Ctrlr documented or is ‘utils.’ an exception?
February 12, 2013 at 12:08 pm #6324It’s not, it used to be but ever since i moved to JUCE classes (not my own ones), all the documentation is on the JUCE website (for the classes), http://www.rawmaterialsoftware.com/juce/api/annotated.html but there are execptions from this rule and that’s a bigger problem.
The list of currently supported classes are always visible as files: https://sourceforge.net/p/ctrlrv4/code/1284/tree/nightly/Source/Lua/JuceClasses/ if a class name is not here, it’s not bound to Ctrlr yet (or never will be), inside the .cpp file of the file there is a list of methods that are available in Ctrlr.
In LUA itself when you run Ctrlr, execute a function in the LUA Console
how()
to see all the available classes and if you want information about a list of method for an object, run (for example, you can do that for any already existing variable in LUA)
mb = MemoryBlock() debug (what(mb))
February 12, 2013 at 3:09 pm #6328Thanks for your reply, but sorry those links didn’t lead to an answer and maybe you over estimate the intelligence of my questions ;-). I’m just looking for information on using the right syntax for writing Lua scripts in/for Ctrlr. For example (again) the ‘convention’ for writing ‘utils.’ instead of ‘panel: CtrlrLuaUtils: etc.’ (or something similar) I did find in this case by searching the forum. If the information hadn’t been on this forum I guess I never had found the answer… Knowing where to look for these things may save me (and others?) a lot of time.
February 12, 2013 at 3:34 pm #6329Start with luabind docs: http://www.rasterbar.com/products/luabind/docs.html
February 12, 2013 at 3:54 pm #6330Thanks again. I will study this documentation and hopefully it gives me a better understanding of Lua in Ctrlr!
February 12, 2013 at 4:29 pm #6331As for the language itself LUA, there is a nice manual: http://www.lua.org/manual/5.1/ with examples and stuff.
February 12, 2013 at 4:47 pm #6333Yeah, I did use it. I have also ‘Programming in Lua’ by Roberto Ierusalimschy and ‘Beginning Lua Programming’ by Kurt Jung & Aaron Brown. So I start understanding Lua in general, but as always the devil is in the details… BTW (and sincerely not to offend you) but the authors of Lua like you to write Lua and not LUA, because the name refers to Lua meaning ‘moon’ and not to an acronym or so (http://www.lua.org/about.html).
February 12, 2013 at 5:31 pm #6334heh allright 🙂 i didn’t get that deep into what it means, i have no idea why is C++ called that either but i’ll remember 🙂
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.