These are the old foldit lua command, refer to here for new function
Below you'll find the list of all the commands we work on in the Beginner Scripting Tutorials (most are covered in Beginner 3). Note that a few of the more complex and infrequently used commands in the Command Set are intentionally omitted.
Organization of the Simplified List
Lua Commands have been divided into three basic categories following the organization of the Beginner 3 Tutorial: do commands, get commands, and set commands (or doers, getters, and setters). Each command is stated (semi) formally, briefly described and an example (or several) given.
Using the Simplified List
One way to make use of this list might be to cut and paste from the blue boxes and insert your own parameters. Parameters are the things inside the parentheses -- they are italicized in this list to make it easier for you to identify them. There can be zero, one, two, or more parameters depending on the command, so read the description and look at the examples! When a parameter is surrounded by brackets [like this], that means it's optional whether you include it or not.
Remember that you can paste into the foldit editor with control-V – you may notice a character that looks like an envelope at the end of pasted lines, which is a byproduct of pasting. Don't worry – this wont affect your script – delete the “envelopes” or leave them in as desired!
Note for Programmers and Advanced Users
A note for more advanced users: this list is designed for beginners, and as such I've removed type declarations, renamed some variables to sound less funky, and changed the notation for optional parameters. I've also rewritten some command descriptions to be easier for beginners. Please let me know or make edits if you find that my manipulation of the commands is incorrect, confusing, or unwise in some way.
Do Commands ("doers")
Do commands ("doers") "do something" to the protein.
Mutates the protein (for design puzzles only, of course!). If nothing is put in the parentheses, mutate runs forever (until stopped by user). If a number (must be a whole number) is put in the parentheses, mutate runs for iterations rounds.
do_mutate() -- mutates forever until stopped by user do_mutate(3) -- mutates for three rounds
Rebuilds the current selection. If nothing is selected, it won't work! If nothing is put in parentheses, it rebuilds forever (until stopped by user). If a whole number is put in the parentheses, it rebuilds for iterations rounds.
do_local_rebuild() -- rebuilds selection forever until stopped by user do_local_rebuild(5) -- rebuilds selection for five rounds
Shakes the protein. If nothing is put in parentheses, it shakes forever (until stopped by user.) If a whole number is put in the parentheses, it shakes for iterations rounds.
do_shake() -- shakes forever until stopped by user do_shake(2) -- shakes for two rounds
Global wiggles sidechains. If nothing is put in parentheses, it global wiggles the sidechains forever (until stopped by user). If a whole number is put in the parenthese, it shakes for iterations rounds.
do_global_wiggle_sidechains() -- global wiggles sidechains forever until -- stopped by user do_global_wiggle_sidechains(6) -- global wiggles sidechains for six rounds
Global wiggles backbone. If nothing is put in parentheses, it global wiggles the backbone forever (until stopped by user). If a whole number is put in the parentheses, it shakes for iterations rounds.
do_global_wiggle_backbone() -- global wiggles backbone forever until -- stopped by user do_global_wiggle_backbone(4) -- global wiggles backbone for four rounds
Global wiggles both sidechains and backbone. If nothing is put in parentheses, it global wiggles all forever (until stopped by user). If a whole number is put in the parentheses, it shakes for iterations rounds.
do_global_wiggle_all() -- global wiggles all forever until stopped by user do_global_wiggle_all(3) -- global wiggles all for three rounds
Set Commands ("setters")
Set commands ("setters") set or store information about, the condition of, or the state of the protein. They don't directly alter a protein like "doers". Saving, loading, banding, and setting secondary structures are all setters because they don't directly change the protein itself. The distinction is a bit tricky -- as one example, consider the fact that bands don't actually change the protein, so adding bands is a set command; but wiggling with bands on does change the protein, so wiggle is a do command.
Restore to the point in the game when you had the absolute best score.
Saves the current game as your "recent best". You can later restore to this point using restore_recent_best().
Restore to the point in the game when you had the recent best score. (Note that the recent best must be set first, either by hand or earlier in the script)
Reset the puzzle, including the secondary structures (loops, helixes, sheets) it had in the beginning.
Save the puzzle into the saveslot. There are 10 saveslots you can use.
quicksave(1) -- save the puzzle into save slot 1
Load the puzzle last saved in saveslot. There are 10 saveslots you can use.
quickload(1) -- load the puzzle from save slot 1
Add a band between segment1 and segment2. Note that both segment1 and segment2 are required!
band_add_segment_segment(1, 5) -- add band between first and fifth segments
Set a band's length. Length must be between 0 and 20.
band_add_segment_segment(1, 5) -- add band between first and fifth segments band=get_band_count() -- find the band's index number band_set_length(band,5) -- set the band to length 5
Set a band's strength. Strength must be between 0 and 10.
band_add_segment_segment(1, 5) -- add band between first and fifth segments band=get_band_count() -- find the band's index number band_set_strength(band,5) -- set the band to strength 5
band_disable(band1[, band2] [ ,...] [band_n])
Disable the bands at the specified locations. You must include at least one parameter (band1). If desired, you can include as many more parameters as you like (band1, band2, band3 ...), but it is not required. Note that this command will only work if there are actually bands at these locations!
band_disable(7) -- disable band at index 7 band_disable(3,4,5,6,10) -- disable bands at indexes 3, 4, 5, 6, and 10
band_enable(band1[, band2] [ ,...] [band_n])
Enable the bands at the specified locations. You must include at least one parameter (band1). If desired, you can include as many more parameters as you like (band1, band2, band3 ...), but it is not required. Note that this command will only work if there are actually disabled bands at these locations to enable!
band_enable(4) -- enable band at index 4 band_enable(12, 24, 36) -- enable bands at index 12, 24, and 36
band_delete(band1[, band2] [ ,...] [band_n])
Delete the bands at the specified index. If desired, you can include as many more parameters as you like (band1, band2, band3 ...), but it is not required. Note that there must actually be bands at these indexes to delete!
Use get_band_count() to find out how many bands exist. Don't delete bands one wants to reference because the index on bands added later will be moved up. Instead, disable them until you want to delete the full set.
band_delete(25) -- delete band 25 band_delete(4, 7, 9, 12) -- delete bands 4, 7 , 9, and 12 band_delete() -- delete all bands
do_freeze(boolean backbone, boolean sidechain)
Freeze previously selected segments. If 'backbone' or 'sidechain' is true, freeze that part of the segment
deselect_all() -- limit segments to only the following select_index(2, 4, 6) -- select segments 2, 4, and 6 do_freeze() -- freeze the selected segments do_freeze(true,false) -- freeze the backbone on the selected segments do_freeze(false,true) -- freeze the sidechains of the selected segments
Unfreeze all segments
do_unfreeze_all() -- unfreeze all segments and sidechains
Set the "behavior" slider to importance. Importance needs to be a number between 0 and 1 (0 for least important, 1 for most important).
set_behavior_clash_importance(1) -- set behavior to 1 (high) set_behavior_clash_importance(0) -- set behavior to 0 (low) set_behavior_clash_importance(.25) -- set behavior to .25 -- (somewhere in the middle)
deselect_index(segment1 [, ...] [, segment_n])
Deselect segment 1, and optionally, deselect as many more segments as you like.
deselect_index(14) -- deselect index 14 deselect_index(30, 31, 35) -- deselect indexes 30, 31, and 35
select_index(segment1 [, ...] [, segment_n])
Select segment 1, and optionally, select as many more segments as you like.
select_index(14) -- select index 14 select_index(30, 31, 35) -- select indexes 30, 31, and 35
Select all the indexes in between segment 1 and segment 2 (inclusively)
select_index_range(14, 18) -- select indexes 14, 15, 16, 17, and 18.
Select all segments in the protein.
Deselects all segments in the protein.
For the selected segment or segments, replaces its current secondary structure (helix, loop, or sheet) with another secondary structure of your choice. Use 'H' for helix, 'L' for loop and 'E' for sheet.
replace_ss('H') -- replace selected indices with helixes replace_ss('L') -- replace selected indices with loops replace_ss('E') -- replace selected indices with sheets
Get Commands ("getters")
Get commands don't concretely change the protein, information about it, or the state of the game. Rather, they simply provide you with some information about the protein or game. A simple way of using getters is to use them to output information to the screen, so all our examples here are going to use print().
As you might expect, get_score provides you with your overall game score.
get_segment_score(segment1 [, ...] [,segment_n])
Gives you the score of a specific segment. You must specify at least one segment index, but optionally you can specify as many as you want.
print(get_segment_score(18)) -- prints score of segment 18 print(get_segment_score(18, 20, 22)) -- prints scores of segments 18, -- 20, and 22
get_ss(segment1 [,segment2] [,...] [,segment_n])
Gives you the secondary structure type at the given segment or segments. Remember that secondary structure means a helix ('H'), loop('L'), sheet('E'), or ligand('M'). Inside the parentheses, put a whole number representing a segment index. Optionally, you can put as many more segment indices as you like separated by commas.
print(get_ss(5)) -- prints secondary structure type at segment 5 print(get_ss(2, 4, 6)) -- prints secondary structure types at -- segments 2, 4, and 6.
This is functionality unique to scripting! Gives you the distance between any two segments.
print(get_segment_distance(12, 20)) -- prints the distance between -- segments 12 and 20
Gets the total number of segments in the protein.
Gives you the total number of bands that have been placed.
get_segment_score_part(score_part, segment1[, ... segment_n])
This command is a bit tricky (see Get segment score part for a more detailed description!) We can use it to give us part of the current backbone score of segment1, and optionally, segment 2, segment 3, and so on. The parameter score_part refers to a particular part of the segment's score -- possibilities include "clashing", "packing", "hiding", "bonding, "backbone", "sidechain", "reference", "disulfides" and "other". These are the same as the individual components of a score that pop up if you tab over a segment in the game.
print(get_segment_score_part("clashing", 5)) -- prints the "clashing" -- part of the score of segment 5 print(get_segment_score_part("bonding", 20, 30, 40)) -- prints the "bonding" -- part of the score of segment -- 20, segment 30, and segment 40
Return true if the segment is hydrophobic.
seg=4 if is_hydrophobic (seg) then print("segment ",seg," is hydrophobic") else print("segment ",seg," is hydrophilic") end
Prints the complete list of commands to the output window.