Foldit recipes can be written using Lua Scripting.
This tutorial discusses how to find and run existing Lua recipes. Lua recipes are often called scripts.
In the next tutorial, you'll begin to write your own Lua recipes.
Downloading a recipe EditWhen starting a new recipe, it's usually best to start with an existing recipe. The Foldit website has thousands of recipes, all of them written by Foldit players. The website has a list of recipes, but you need to be running Foldit to run these recipes or look at their "source code".
For this tutorial you should know your Foldit username and password. You'll use that both when starting the game (also known as the "Foldit client"), and when logging into the website, http://fold.it.
Downloading recipes is easiest when your Foldit client is connected to chat. Sometimes connecting to chat can be a problem. The reasons include:
- the Foldit chat server is down (somewhat rare, but it happens)
- your internet provider blocks chat (schools and offices may block IRC, which is what Foldit uses)
- you have more than one Foldit client running (only one can be connected to chat)
If chat is just not working for you, you can still download recipes. You just have to use the recipe number, which can be found on the recipe's page on the Foldit website.
To get started with downloading recipes:
- Start Foldit and load a puzzle. For this tutorial, use one of the beginner puzzles or a "revisiting" puzzle.
- Make sure your Foldit client is connected to chat. Check the "Chat - Global" area in the lower right of the screen.
- Log in the the Foldit website and go to the recipes page. All the recipes listed have been written and shared by Foldit players.
- Go ahead and browse some of the scripts, and when you're ready, go to the page for the script we're going to work with: Beginner Rebuild SCRIPT 1.01
- Click on the green box in the upper right marked "Add to Cookbook!"
- Switch to your Foldit client and open the cookbook.
- In the original Foldit interface, the cookbook is located on the left side of the screen.
- In the selection interface, the cookbook is floating window which is available by the "c" keyboard shortcut.
- Look through the recipes and you will find the script you downloaded, "Beginner Rebuild SCRIPT 1.01".
- If you don't see the recipe, make sure your Foldit client is connected to chat (try typing "hello" in global or group chat). Also, on the Foldit website, you should see a "Welcome" message and a link to "My Page" on the top right, which means you're logged in.
- The recipe can also be downloaded by using the recipe number. Click on the blue folder icon to "Browse/Download shared recipes".
- In the original interface, the blue folder icon is on the left edge of the Foldit window.
- In the selection interface, the blue folder icon is on the lower edge of the Cookbook window.
- The "Download Manually" window should appear if the client is not connected to chat.
- Enter the recipe number, 102313, and click "Download". (The recipe number can be found in the "ID" field on the recipe page, and it's also part of the recipe's URL.)
- The recipe should now be available in the cookbook.
Running a recipe Edit
Now that you've loaded a script from the web, it's time to run it.
- Locate "Beginner Rebuild SCRIPT 1.01" in your recipes list, and hover over it with your mouse.
- Click the recipe name or (or the small green arrow to its right) to run it.
- You should see something start happening to your protein. If you watch carefully, you'll find that the first part of the protein is being rebuilt. After it settles into position, there is a shake, then a wiggle, and then another shake.
This script applies the rebuild tool to rebuild the first 10 segments the protein, and then settle them using shake and wiggle. In a later tutorial, we're going to extend that to rebuild any part of the protein automatically.
Opening the recipe output window Edit
So you've successfully run your first script and were able to automatically rebuild your protein. Let's see how we can get more information about the process that's going on as the script runs. The recipe output window shows the results of running the recipe.
- Click the “Show Recipe Output” (small "DOS prompt" icon) button in the cookbook.
- In original interface, the "Show Recipe Output" button is again on the left edge of the screen.
- In the selection interface, the button is located on the bottom edge of the cookbook window.
- While the recipe is running, you can also click on "Show Output" button in the small window that appears.
- The Recipe Output window appears. If you've already run the recipe, you'll see its output in the window.
- Move the recipe output window to a good location, where it doesn't obstruct the view of your protein.
- Rerun the same beginner script.
- As the recipe runs, watch the output window. The output may not mean much as this point, you'll be able to follow along as the recipe runs.
The recipe output window contains messages written by the recipe using the Lua "print" command. Also, if you check "Show script commands" at the bottom of the window, you'll see which specific Lua commands running at each point.
We'll do more with the output window in the next tutorial.
In general, it's a good idea to keep an eye on the output while running scripts. They can be trying to tell you something!
Summing up Edit
You should now be able to download recipes from the Foldit website and run them.
You should also be able to open the recipe output window to see what the recipe has to say while running.
Feel free to download additional recipes and play with them -- just keep in mind that you may not always know what they do ahead of time and if they will work properly.
For more detail on the sample recipe, see Lua Scripting Tutorial (Beginner 1 Tech Supplement).
|Continue with Lua Scripting Tutorial (Beginner 2)|