There’s a library on github called Inspect (https://github.com/kikito/inspect.lua) which looks like it could be handy for inspecting objects, however I’ve not been able to get it to work in the Lua environment. I’ve tried importing it as suggested in the tool’s instructions, copying/pasting into the terminal, and all to no avail. It tells me inspect isn’t declared.
>>> local inspect = require 'inspect'
>>> inspect(renoise.song().instruments)
*** [string "inspect(renoise.song().instruments)"]:1: variable 'inspect' is not declared
*** stack traceback:
*** [C]: in function '_error'
*** [string "local mt = getmetatable(_G)..."]:29: in function <[string "local mt = getmetatable(_G)..."]:24>
*** [string "inspect(renoise.song().instruments)"]:1: in main chunk
Thanks! Looks like I was just using it incorrectly (apparently, if you just try to run the function on an object, it isn’t happy. You have to nest it in a print function).
Also, it doesn’t seem to do what I thought it would do, that being giving me some useful data about the complete table. Since it doesn’t do what I’m hoping it would do, could I ask: has anyone made a function that will print the entire structure of renoise.song()? Like, the tables, the properties, and the methods? I want to get a “feel” for the structure and how everything works so I can start making some useful utilities.
One way to get an idea of songs in general is to look at the Renoise song API listing. But I find it overwhelming. (What I really want is the API docs as dynamic tree that I can expand/collapse.)
renoise.song() does not return a table, I found some code that should do recursive table inspection:
The more complex thing about it is to view objects with properties and methods, like you say, but it should be totally doable by using objinfo, loadstring/pcall and string manipulation… I’m on it
joule, that sounds awesome. I understand a lot of the limitations of Lua are deliberate (so it could be more portable), but using Lua feels like programming blindfolded a lot of the time. Something like what you’re working on is absolutely brilliant.
What I think would really help though would be a slightly easier-to-navigate set of docs. They’re not the worst I’ve seen, but they could be better. Honestly, a webpage with a sidebar you can browse would do the job. I may end up trying to work on something like that once I get my head around Lua and Renoise.
Thank you Neurogami and joule for your help–there’s very few places to turn for help on Renoise/Lua (although the guys in the Lua Reddit have helped a bit as well).
Still wish they went with Python for the scripting language
Quick question: can you alter package.path? I have Lua 5.3 installed on my computer (OS X) and want it to search for libraries there (for debugging purposes).
Quick question: can you alter package.path? I have Lua 5.3 installed on my computer (OS X) and want it to search for libraries there (for debugging purposes).
Yes. It’s similar to $PATH in *nix environments, except it doesn’t store paths, exactly, but path/patterns.
What I think would really help though would be a slightly easier-to-navigate set of docs. They’re not the worst I’ve seen, but they could be better. Honestly, a webpage with a sidebar you can browse would do the job. I may end up trying to work on something like that once I get my head around Lua and Renoise.
Nice idea. I once made an extraction script for the Renoise LUA API that also extracted the hierarchy/structure of renoise.* with all comments.
I’ll try to use all this API data in the _G browser as well.
I think LUA is a very elegant and simple language really. But a doc interface like this should be able to help minimize the initial “scare factor”.