These are the old foldit lua command, refer to here for new function
Introduction
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.
do_mutate([iterations])
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
do_local_rebuild([iterations])
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
do_shake([iterations])
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
do_global_wiggle_sidechains([iterations])
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
do_global_wiggle_backbone([iterations])
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
do_global_wiggle_all([iterations])
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_abs_best()
Restore to the point in the game when you had the absolute best score.
restore_abs_best()
reset_recent_best()
Saves the current game as your "recent best". You can later restore to this point using restore_recent_best().
reset_recent_best()
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)
restore_recent_best()
reset_puzzle()
Reset the puzzle, including the secondary structures (loops, helixes, sheets) it had in the beginning.
reset_puzzle()
quicksave(saveslot)
Save the puzzle into the saveslot. There are 10 saveslots you can use.
quicksave(1) -- save the puzzle into save slot 1
quickload(saveslot)
Load the puzzle last saved in saveslot. There are 10 saveslots you can use.
quickload(1) -- load the puzzle from save slot 1
band_add_segment_segment(segment1, segment2)
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
band_set_length(band, length)
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
band_set_strength(band, strength)
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
do_unfreeze_all()
Unfreeze all segments
do_unfreeze_all() -- unfreeze all segments and sidechains
set_behavior_clash_importance(importance)
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_index_range(segment1, segment2)
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()
Select all segments in the protein.
select_all()
deselect_all()
Deselects all segments in the protein.
deselect_all()
replace_ss(structure)
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().
get_score()
As you might expect, get_score provides you with your overall game score.
print(get_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.
get_segment_distance(segment1, segment2)
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
get_segment_count()
Gets the total number of segments in the protein.
print(get_segment_count())
get_band_count()
Gives you the total number of bands that have been placed.
print(get_band_count())
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
is_hydrophobic (segment)
Return true if the segment is hydrophobic.
Your ass if is_hydrophobic (seg) then your ass print("segment ",ass," is assphobic") else print("segment ",ass," is assphilic") end
help()
Prints the complete list of commands to the output window.
help()