String format syntax question

I’ve been looking through the XRNX code repository just to get an idea of how people are scripting their tools. I know lua reasonably well, but have come across a type of syntax i’ve never seen before. As an example:

print((“This is an example which has a string in it: %s and a decimal: %d”):format(the_string, the decimal))

So, basically i understand it’s a way of formatting a string, but how does it differ from the standard string.format(), and is there any benefit of doing it this way?

Also is this only part of the Renoise lua implementation?

Thanks for any help yall.

You can quickly figure out if something is “vanilla” lua by running the code on the online demo:

http://www.lua.org/cgi-bin/demo

In this case, your example works just fine. I think it’s simply shorthand syntax :slight_smile:

A more detailed description of the Renoise-added customizations to the lua runtime are located here:

https://github.com/renoise/xrnx/blob/master/Documentation/Lua.Standard.API.lua

Of special note: many useful additions to “table” (the single most powerful aspect of lua).

Thanks danoise.

I was looking through the docs to find the language extensions added by Renoise but missed that file…

Cool to know lua has many ways to get to the same result, although it can be confusing for beginners!