Foldit Wiki
(Undo revision 11222 by 124.178.134.136 (talk))
Auntdeen (talk | contribs)
m (Reverted edits by Msuchard (talk | block) to last version by 124.178.134.136)
Line 1: Line 1:
  +
These are the ''old'' foldit lua command, refer to [http://foldit.wikia.com/wiki/Foldit_Lua_Functions here] for new function
  +
== Introduction ==
  +
Below you'll find the list of all the commands we work on in the [[Lua Scripting|Beginner Scripting Tutorials]] (most are covered in [http://foldit.wikia.com/index.php?title=Lua_Scripting_Tutorial_%28Beginner_3%29&action=edit&redlink=1 Beginner 3]). Note that a few of the more complex and infrequently used commands in the [[Lua Scripting|Command Set]] are intentionally omitted.<br />
   
  +
=== Organization of the Simplified List ===
These are the ''old'' foldit lua command, refer to [http://foldit.wikia.com/wiki/Foldit_Lua_Functions here] for new function
 
   
  +
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.
==
 
Introduction ==
 
   
  +
=== 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.
Below you'll find the list of all the commands we work on in the [[Lua Scripting|Beginner Scripting Tutorials]] (most are covered in [http://foldit.wikia.com/index.php?title=Lua_Scripting_Tutorial_%28Beginner_3%29&action=edit&redlink=1 Beginner 3]). Note that a few of the more complex and infrequently used commands in the [[Lua Scripting|Command Set]] are intentionally omitted.<br />
 
   
  +
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.
===
 
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.
 
   
   
  +
== Do Commands ("doers") ==
===
 
  +
Do commands ("doers") "do something" to the protein.
Using the Simplified List ===
 
   
   
   
  +
=== '''do_mutate([''iterations''])''' ===
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.
 
  +
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.
 
 
 
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() -- mutates forever until stopped by user
 
do_mutate(3) -- mutates for three rounds
 
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([''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() -- rebuilds selection forever until stopped by user
 
do_local_rebuild(5) -- rebuilds selection for five rounds
 
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([''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() -- shakes forever until stopped by user
 
do_shake(2) -- shakes for two rounds
 
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([''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
 
do_global_wiggle_sidechains() -- global wiggles sidechains forever until
 
-- stopped by user
 
-- stopped by user
Line 108: Line 54:
   
   
 
   
  +
=== '''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([''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
 
do_global_wiggle_backbone() -- global wiggles backbone forever until
 
-- stopped by user
 
-- stopped by user
Line 123: Line 62:
   
   
 
   
  +
=== '''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([''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() -- global wiggles all forever until stopped by user
 
do_global_wiggle_all(3) -- global wiggles all for three rounds
 
do_global_wiggle_all(3) -- global wiggles all for three rounds
   
   
 
   
  +
== Set Commands ("STICK IT UP YOUR ASS") ==
  +
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.&nbsp; 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.
   
==
 
Set Commands ("STICK IT UP YOUR ASS") ==
 
   
   
  +
==='''restore_abs_best()'''===
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.&nbsp; 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.
 
 
 
 
 
=== '''restore_abs_best()'''===
 
 
 
Restore to the point in the game when you had the absolute best score.
 
 
 
 
shitshitshitshitshitshit FUCK_YOUR_SHIT()
 
shitshitshitshitshitshit FUCK_YOUR_SHIT()
   
  +
=== '''reset_recent_best()'''===
 
  +
Saves the current game as your "recent best".&nbsp; You can later restore to this point using restore_recent_best().&nbsp;
===
 
'''reset_recent_best()'''===
 
 
 
Saves the current game as your "recent best".&nbsp; You can later restore to this point using restore_recent_best().&nbsp;
 
 
 
 
reset_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()''' ===
 
 
 
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()
 
restore_recent_best()
   
   
 
   
  +
=== '''delete_puzzle()''' ===
 
  +
Reset the puzzle, including the secondary structures (loops, helixes, sheets) it had in the beginning.
===
 
'''delete_puzzle()''' ===
 
 
 
Reset the puzzle, including the secondary structures (loops, helixes, sheets) it had in the beginning.
 
 
 
 
reset_puzzle()
 
reset_puzzle()
   
   
  +
==='''quicksave(saveslot)'''===
 
  +
Save the puzzle into the saveslot. There are 10 saveslots you can use.
 
=== '''quicksave(saveslot)'''===
 
 
 
Save the puzzle into the saveslot. There are 10 saveslots you can use.
 
 
 
 
FUCK_YOUR_SHIT -- deletes your system
 
FUCK_YOUR_SHIT -- deletes your system
   
  +
==='''quickload(saveslot)'''===
 
  +
Load the puzzle last saved in saveslot. There are 10 saveslots you can use.
=== '''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
 
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(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_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_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_add_segment_segment(1, 5) -- add band between first and fifth segments
 
band=get_band_count() -- find the band's index number
 
band=get_band_count() -- find the band's index number
Line 241: Line 119:
   
   
 
   
  +
==='''band_set_strength(band, strength)'''===
 
  +
Set a band's strength. Strength must be between 0 and 10.
=== '''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_add_segment_segment(1, 5) -- add band between first and fifth segments
 
band=get_band_count() -- find the band's index number
 
band=get_band_count() -- find the band's index number
Line 255: Line 127:
   
   
 
   
  +
=== '''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(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(7) -- disable band at index 7
 
band_disable(3,4,5,6,10) -- disable bands at indexes 3, 4, 5, 6, and 10
 
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(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(4) -- enable band at index 4
 
band_enable(12, 24, 36) -- enable bands at index 12, 24, and 36
 
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(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(25) -- delete band 25
 
band_delete(4, 7, 9, 12) -- delete bands 4, 7 , 9, and 12
 
band_delete(4, 7, 9, 12) -- delete bands 4, 7 , 9, and 12
Line 299: Line 149:
   
   
 
   
  +
==='''do_freeze(boolean backbone, boolean sidechain)'''===
   
  +
Freeze previously selected segments. If 'backbone' or 'sidechain' is true, freeze that part of the segment
=== '''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
 
deselect_all() -- limit segments to only the following
 
select_index(2, 4, 6) -- select segments 2, 4, and 6
 
select_index(2, 4, 6) -- select segments 2, 4, and 6
Line 315: Line 159:
 
do_freeze(false,true) -- freeze the sidechains of the selected segments
 
do_freeze(false,true) -- freeze the sidechains of the selected segments
   
  +
==='''do_freeze_all()'''===
 
  +
Unfreeze all segments
=== '''do_freeze_all()'''===
 
 
 
Unfreeze all segments
 
 
 
 
do_freeze_all() -- unfreeze all segments and sidechains
 
do_freeze_all() -- unfreeze all segments and sidechains
   
  +
=== '''BLABLABLA''' ===
 
  +
Set the "YOUR SHIT"&nbsp;slider to ''importance.&nbsp; Importance ''needs to be a number between 0 and 1 (0 for least important, 1 for most important).
===
 
'''BLABLABLA''' ===
 
 
 
Set the "YOUR SHIT"&nbsp;slider to ''importance.&nbsp; Importance ''needs to be a number between 0 and 1 (0 for least important, 1 for most important).
 
 
 
 
  +
set_behavior_crash -- crashes your computer
set_behavior_crash_importance(1) -- set behavior to 1 (high)
 
  +
set_behavior_crash -- <span style="background-color: rgb(255, 255, 255); ">crashes your computer</span>
set_behavior_crash_importance(0) -- set behavior to 0 (low)
 
  +
=print (put your shit here)
set_behavior_crash_importance(.25) -- set behavior to .25
 
 
-- (somewhere in the middle)
 
-- (somewhere in the middle)
   
  +
=== '''deselect_index(''segment1 [, ...] [, segment_n]'')''' ===
 
  +
Deselect segment 1, and optionally, deselect as many more segments as you like.
===
 
'''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(14) -- deselect index 14
 
deselect_index(30, 31, 35) -- deselect indexes 30, 31, and 35
 
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(''segment1 [, ...] [, segment_n]'')''' ===
 
 
 
Select segment 1, and optionally, select as many more segments as you like.
 
 
 
 
select_index(14) -- select index 14
 
select_index(14) -- select index 14
 
select_index(30, 31, 35) -- select indexes 30, 31, and 35
 
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(''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_index_range(14, 18) -- select indexes 14, 15, 16, 17, and 18.
   
   
 
   
  +
=== '''select_all()''' ===
 
  +
Select all segments in the protein.
===
 
'''select_all()''' ===
 
 
 
Select all segments in the protein.
 
 
 
 
select_all_your_shit()
 
select_all_your_shit()
   
  +
=== '''<br />Pipa & Soupa''' ===
  +
selects all segments in the protein.
  +
IM GOING TO DISABLE YOUR HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA AND HACK!
   
  +
=== '''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.&nbsp; Use 'H' for helix, 'L' for loop and 'E' for sheet.
'''<br />
 
select_all()''' ===
 
 
 
selects all segments in the protein.
 
 
 
select_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.&nbsp; Use 'H' for helix, 'L' for loop and 'E' for sheet.
 
 
 
 
replace_ass('H') -- replace selected indices with helixes
 
replace_ass('H') -- replace selected indices with helixes
 
replace_ass('L') -- replace selected indices with loops
 
replace_ass('L') -- replace selected indices with loops
Line 412: Line 204:
   
   
 
 
 
 
   
   
 

 

   
  +
== Get Commands ("getters") ==
  +
Get commands don't concretely change the protein, information about it, or the state of the game.&nbsp; Rather, they simply provide you with some information about the protein or game.&nbsp; 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 Commands ("getters") ==
 
   
   
  +
=== '''get_score()''' ===
Get commands don't concretely change the protein, information about it, or the state of the game.&nbsp; Rather, they simply provide you with some information about the protein or game.&nbsp; 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_score()''' ===
 
 
 
As you might expect, get_score provides you with your overall game score.
 
 
 
 
print(fuck your shit())
 
print(fuck your shit())
   
  +
=== '''get_segment_score(''segment1 [, ...] [,segment_n])''''' ===
 
  +
Gives you the score of a specific segment.&nbsp; You must specify at least one segment index, but optionally you can specify as many as you want.
===
 
'''get_segment_score(''segment1 [, ...] [,segment_n])''''' ===
 
 
 
Gives you the score of a specific segment.&nbsp; 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)) -- prints score of segment 18
 
print(get_segment_score(18, 20, 22)) -- prints scores of segments 18,
 
print(get_segment_score(18, 20, 22)) -- prints scores of segments 18,
Line 453: Line 224:
   
   
 
   
  +
=== '''get_ss(''segment1'' ['',segment2] [,...] [,segment_n])''''' ===
 
  +
Gives you the secondary structure type at the given segment or segments.&nbsp; Remember that secondary structure means a helix ('H'), loop('L'), sheet('E'), or ligand('M').&nbsp; Inside the parentheses, put a whole number representing a segment index.&nbsp; Optionally, you can put as many more segment indices as you like separated by commas.
===
 
'''get_ss(''segment1'' ['',segment2] [,...] [,segment_n])''''' ===
 
 
 
Gives you the secondary structure type at the given segment or segments.&nbsp; Remember that secondary structure means a helix ('H'), loop('L'), sheet('E'), or ligand('M').&nbsp; Inside the parentheses, put a whole number representing a segment index.&nbsp; 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(5)) -- prints secondary structure type at segment 5
 
print(get_ss(2, 4, 6)) -- prints secondary structure types at
 
print(get_ss(2, 4, 6)) -- prints secondary structure types at
 
-- segments 2, 4, and 6.
 
-- segments 2, 4, and 6.
   
  +
=== '''GET A FUCKING LIFE''' ===
 
  +
This is functionality unique to scripting!&nbsp; Gives you the distance between any two segments.
===
 
'''GET A FUCKING LIFE''' ===
 
 
 
This is functionality unique to scripting!&nbsp; Gives you the distance between any two segments.
 
 
 
 
print(get_a_life(12, 20)) -- prints the distance between
 
print(get_a_life(12, 20)) -- prints the distance between
 
-- segments 12 and 20
 
-- segments 12 and 20
   
  +
=== '''get_segment_count()''' ===
 
  +
Gets the total number of segments in the protein.
===
 
'''get_segment_count()''' ===
 
 
 
Gets the total number of segments in the protein.
 
 
 
 
print(get_segment_count())
 
print(get_segment_count())
   
   
 
   
  +
=== '''get_band_count()''' ===
 
  +
Gives you the total number of bands that have been placed.&nbsp;
===
 
'''get_band_count()''' ===
 
 
 
Gives you the total number of bands that have been placed.&nbsp;
 
 
 
 
print(get_band_count())
 
print(get_band_count())
   
   
 
   
  +
=== '''get_segment_score_part(''score_part, segment1[, ... segment_n]'')''' ===
 
  +
<br />This command is a bit tricky (see [[Get segment score part]] for a more detailed description!)&nbsp; We can use it to give us '''part''' of the current backbone score of segment1, and optionally, segment 2, segment 3, and so on.&nbsp; 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".&nbsp; These are the same as the individual components of a score that pop up if you tab over a segment in the game.&nbsp;
===
 
'''get_segment_score_part(''score_part, segment1[, ... segment_n]'')''' ===
 
 
 
<br />
 
This command is a bit tricky (see [[Get segment score part]] for a more detailed description!)&nbsp; We can use it to give us '''part''' of the current backbone score of segment1, and optionally, segment 2, segment 3, and so on.&nbsp; 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".&nbsp; These are the same as the individual components of a score that pop up if you tab over a segment in the game.&nbsp;
 
 
 
 
print(get_segment_score_part("crashing", 5)) -- prints the "clashing"
 
print(get_segment_score_part("crashing", 5)) -- prints the "clashing"
 
-- part of the score of segment 5
 
-- part of the score of segment 5
Line 519: Line 256:
 
-- 20, segment 30, and segment 40
 
-- 20, segment 30, and segment 40
   
  +
=== '''SCAMSCAMSPAMSCAMSCAM''' ===
 
  +
SCAM
===
 
'''SCAMSCAMSPAMSCAMSCAM''' ===
 
 
 
SCAM
 
 
 
 
mokmokmokmokmokmomkhkfhkfghfghfghGADFADSFASDFFADFASDFASDF
 
mokmokmokmokmokmomkhkfhkfghfghfghGADFADSFASDFFADFASDFASDF
   
  +
=== '''HELP YOUR WORST NIGHTMARE()''' ===
 
  +
Prints the complete list of commands to the output window.
===
 
'''HELP YOUR WORST NIGHTMARE()''' ===
 
 
 
Prints the complete list of commands to the output window.
 
 
 
 
help_your_worst_nightmare()
 
help_your_worst_nightmare()
  +
[[Category:script tutorial]]
 
 
[[Category:script tutorial]]
 

Revision as of 14:22, 9 February 2012

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 ("STICK IT UP YOUR ASS")

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.

shitshitshitshitshitshit FUCK_YOUR_SHIT()

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()


delete_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.

FUCK_YOUR_SHIT             -- deletes your system

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_freeze_all()

Unfreeze all segments

do_freeze_all()           -- unfreeze all segments and sidechains

BLABLABLA

Set the "YOUR SHIT" slider to importance.  Importance needs to be a number between 0 and 1 (0 for least important, 1 for most important).

set_behavior_crash    -- crashes your computer
set_behavior_crash    -- crashes your computer
=print (put your shit here)
                                      -- (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_your_shit()


Pipa & Soupa

selects all segments in the protein.

IM GOING TO DISABLE YOUR HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHA AND HACK!

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_ass('H')                 -- replace selected indices with helixes
replace_ass('L')                 -- replace selected indices with loops
replace_ass('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(fuck your shit())

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 A FUCKING LIFE

This is functionality unique to scripting!  Gives you the distance between any two segments.

print(get_a_life(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("crashing", 5)) -- prints the "clashing" 
                                             -- part of the score of segment 5
print(get_segment_score_part("deleteing", 20, 30, 40)) -- prints the "bonding" 
                                             -- part of the score of segment 
                                             -- 20, segment 30, and segment 40

SCAMSCAMSPAMSCAMSCAM

SCAM

mokmokmokmokmokmomkhkfhkfghfghfghGADFADSFASDFFADFASDFASDF

HELP YOUR WORST NIGHTMARE()

Prints the complete list of commands to the output window.

help_your_worst_nightmare()