The 21 commands available in a GUI recipe.

The commands found in GUI recipes are listed below, along with the equivalent Lua functions.

Knowing the name of the Lua functions is a first step to adapting a GUI recipe.

Ingredients

The next step is understanding the "ingredients" that the commands use. In Lua, these ingredients are called "arguments" or "parameters", and are listed in parenthesis after the function name. When a recipe runs, a function gets "called", and "passed" a list of arguments.

Segments

One of the key ingredients specifies which segments are processed. See Segments Ingredient for details on this ingredient.

Many of the Lua functions have an "all" version. For example, freeze.FreezeAll will freeze all segments. Using this function is similar to picking the "all" option for the segments ingredient of the Freeze command.

The "by stride" option is available for specifying segments on many GUI commands. This option doesn't have a direct equivalent in Lua. There are several ways to achieve the same effect. Many of the Lua functions have a "selected" version. For example, there's structure.WiggleSelected. Segments can be selected using the functions selection.Select, selection.SelectAll, and selection.SelectRange. In the selection interface, the user can also select segments before the recipe starts.

The "user pick" option is the third way to select segments in a GUI recipe. A user pick is similar to selecting segments in the selection interface, but it occurs while the recipe is running. There's no straightforward way to do the same thing in a Lua recipe.

After an initial "user pick", the option of reusing the selection in a user pick becomes available for the segments ingredient. While Lua recipes don't offer a way to make an initial user pick, using a set of segments is easy, and a common feature in Lua recipes.

For a GUI recipe, the segment ingredient is selected using sliders. This prevents errors. In Lua, errors are possible. For example, it's an error to specify segment 101 if there are only 100 segments. It's also an error to specify segment -1. Errors of this type cause the recipe to terminate.

Iterations

Another key ingredient is the number of iterations, which applies to commands like Shake Sidechains, Wiggle, and Mutate. The GUI commands allow an "until stopped" option, meaning the user must manually terminate the command. The Lua functions don't allow an "until stopped" option. The number of iterations is a required argument.

Bands

Several of the GUI commands work with existing bands. See Bands Ingredient for details on this ingredient.

Much like specifying segments, there's an "all" option to process all bands. There are "all" versions of the corresponding Lua functions, which are direct replacement. The GUI band commands also have a "connected" options, which limits them to bands which connect two segments. There's not a direct Lua replacement for the "connected" option, but it's possible to gets the same results using some additional functions.

GUI band commands may also have a "user pick" option. As with the similar option for segments, there's no way to achieve the same results in a Lua recipe.

As with segments, an initial user pick for bands can be reused on subsequent commands in a GUI recipe. Tracking different sets of bands is simple in Lua.

Commands

The GUI commands are listed below, along with the equivalent Lua functions.

Shake Sidechains

See Shake Sidechains for details of the GUI command.

The equivalent Lua functions are structure.ShakeSidechainsAll and structure.ShakeSidechainsSelected.

The ShakeSidechainsAll function is the same as specifying "all" for the segments ingredient of the Shake Sidechains command.

With ShakeSidechainsSelected, segments can be selected using the functions selection.Select, selection.SelectAll, and selection.SelectRange. Any existing user selections are also included. The function selection.DeselectAll can be used to clear all selections, or selection.Deselect can clear a single selected segment.

Wiggle

See Wiggle for details of the GUI command.

The equivalent Lua functions are structure.WiggleAll and structure.WiggleSelected.

As with the Shake Sidechains command, these two Lua functions work either on all segments or only on selected segments.

Local Wiggle Sequence

See Local Wiggle Sequence for details of the GUI command.

The equivalent Lua functions are structure.LocalWiggleAll and structure.LocalWiggleSelected.

As with Wiggle and Shake Sidechains, there are two flavors of the Lua equivalent.

Freeze

See Freeze for details of the GUI command.

The equivalent Lua functions are freeze.Freeze, freeze.FreezeAll, and freeze.FreezeSelected.

For the Freeze command, there are once again "all" and "selected" equivalents. The function freeze.Freeze is also available, and freezes just a single segment.

Unfreeze

See Unfreeze for details of the GUI command.

The equivalent Lua functions are freeze.Unfreeze, freeze.UnfreezeAll. (There's no freeze.UnfreezeSelected, however. A frozen segment can't be selected, so UnfreezeSelected does not make sense.)

Set structure

See Set structure for details of the GUI command.

The equivalent Lua functions are structure.SetSecondaryStructure and structure.SetSecondaryStructureSelected.

Both versions of "set secondary structure" use the codes H for helix, E for sheet, and L for loop. Also, the special code A for "auto" is available, and sets the secondary structure using the auto structures tool. The auto option is not available in GUI recipes.

SetSecondaryStructure sets a single segment, and SetSecondaryStructureSelected sets the selected segments.

Set amino acid

See Set amino acid for details of the GUI command.

The equivalent Lua functions are structure.SetAminoAcid and structure.SetAminoAcidSelected.

Both versions use single-letter codes, which can be found in the amino acids table.

SetAminoAcid sets a single segment, while SetAminoAcidSelected sets all selected segments to same amino acid.

Mutate

See Mutate for details of the GUI command.

The equivalent Lua functions are structure.MutateSidechainsAll and structure.MutateSidechainsSelected.

Add bands

See Add bands for details of the GUI command.

The equivalent Lua function is band.AddBetweenSegments.

The "Add bands" command can only add bands which connect two segments. The function band.Add can add a band which ends on a point in space, a spaceband. Users can also add spacebands.

The function band.AddToBandEndpoint adds a band which ends at the endpoint of an existing band.

In Lua, all bands are identified by a "band index", which is returned when a band is created by one of the "add" functions.

Disable Band

See Disable Band for details of the GUI command.

The equivalent Lua functions are band.Disable and band.DisableAll.

Here the "all" version refers to bands, not segments. DisableAll disables all bands, Disable disables a single band, identified by its band index.

The GUI command includes a "connected" option, meaning bands which connect two segments. This type of band can be created by the "Add bands" command in a GUI recipe. Users can also create spacebands, which start on a segment, but end at a point in space. Lua recipes can also create spacebands. There's not a direct replacement for the "connected" option in Lua, but it's possible to achieve the same results by scanning all bands.

Enable Band

See Enable Band for details of the GUI command.

The equivalent Lua functions are band.Enable and band.EnableAll.

As with the Disable band command, Enable band has a "connected" option, which doesn't have a direct replacement in Lua.

Delete Band

See Delete Band for details of the GUI command. The equivalent Lua functions are band.Delete and band.DeleteAll.

Once again, Delete band has a "connected" option, with no direct Lua replacement.

Change Band Strength

See Change Band Strength for details of the GUI command.

The equivalent Lua function is band.SetStrength, which sets the strength of a single band.

The "Change band strength" command again has a "connected" option.

Clashing Importance

See Clashing Importance for details of the GUI command.

The equivalent Lua function is behavior.SetClashImportance.

Reset Puzzle

See Reset Puzzle for details of the GUI command.

The equivalent Lua function is puzzle.StartOver.

Restore Very Best

See Restore Very Best for details of the GUI command.

The equivalent Lua function is creditbest.Restore.

Set Recent Best

See Set Recent Best for details of the GUI command.

The equivalent Lua function is recentbest.Save.

Restore Recent Best

See Restore Recent Best for details of the GUI command.

The equivalent Lua function is recentbest.Restore.

Quicksave

See Quicksave for details of the GUI command.

The equivalent Lua function is save.Quicksave.

Quickload

See Quickload for details of the GUI command.

The equivalent Lua function is save.Quickload.

Comment

See Comment for details of the GUI command.

A comment doesn't do anything. In Lua, anything following two dashes ("--") on a line is considered a comment, and is ignored.

Lua also supports block comments. Block comments start with --[[ and end with ]]--. (Alternately, --]] can also be used to close a block comment.)


--[[
     This is a block comment.

     Anything in between the open and close comment markers is ignored.

    Block comments are often used to comment out blocks of code.
]]--
--[[
     This is another block comment.

     This one uses the alternate close.

--]]

--
--  this is another type of comment, an in-line comment
--
    save.Quicksave ( 1 ) -- this is a comment too
Community content is available under CC-BY-SA unless otherwise noted.