The first tutorial, Lua Scripting Tutorial (Beginner 1), mainly discussed how to download recipes from the Foldit website, and avoided technical details to keep things simple.

Here's a little more background on the actual script used in the tutorial. Programming terms are in italics. The Lua manual gives more detailed definitions of all the programming terms. For a less technical introduction, Programming In Lua is a good place to start.

The first tutorial used Beginner Rebuild SCRIPT 1.01 as a sample recipe. The recipe can be viewed in the Foldit recipe editor, as covered in Lua Scripting Tutorial (Beginner 2).

Going through the recipe line-by-line, here are some of the technical highlights.

-- this is a comment!  You can put comments anywhere.

When two dashes appear together outside of quotes, Lua treats the rest of the line as a comment. So a comment can start at the beginning of a line, or after other statements. Inside of quotes, two dashes are just text.

print ( "You're running your first script!" )

The print statement is built into Lua. Foldit uses a slightly modified version of print, but it's really hard to tell the difference. Technically, print is a function, and a statement like this a function call. In this case, we're passing one argument or parameter to the function, a string.

In Foldit, a string is enclosed in either double or single quotes. "You're running your first script!" and 'You're running your first script!' are the same in Lua.

The following statements are more function calls:

selection.DeselectAll ()
selection.SelectRange ( 1, 10 )
structure.RebuildSelected ( 2 )
structure.ShakeSidechainsAll ( 2 )
structure.WiggleAll ( 7 )
selection.DeselectAll ()

These functions are part of the Foldit Lua Interface. They're what allow a recipe to work with a protein in Foldit. See the complete list at Foldit Lua Functions. These functions are from version 2 (V2) of the interface. You may also see some V1 recipes, which have functions with names like "do_global_wiggle".

Functions that begin with "selection" select and de-select segments, which you can also do manually in the Selection Interface. Recipes work the same way in the original and selection interfaces.

The statement "selection.SelectRange ( 1, 10 )" is an example of passing more than one argument to a function.

Functions that begin with "structure" work with the structure of protein in some way. This includes the most important tools, shake, wiggle, rebuild, and remix, which actively change the shape of the protein. The structure category also includes mutate functions, which change the amino acids of the protein in design puzzles. Many other "structure" functions return information about the protein, including the score.

The function calls "structure.RebuildSelected ( 2 )", "structure.ShakeSidechainsAll ( 2 )", and "structure.WiggleAll ( 7 )", all include one argument, "number of cycles". The Foldit Lua Interface never specifies what this argument means, and the meaning is different on each function.

For shake, normally one cycle is enough, and no further change occurs after that. It's common to specify two cycles just to be on the safe side.

For wiggle, a larger number of cycles is typically useful. Specifying up to 10 cycles is common, and even as many as 30 cycles may still produce results. For manual wiggles, the counter in the upper left starts to "spin" when wiggle has run out of things to do, but there's no way to detect this in a recipe.

For rebuild, the number of cycles may relate to the number of different shapes tried, but its exact meaning is not clear.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.