Fandom

Foldit Wiki

Lua Scripting Tutorial (Beginner 1)

1,452pages on
this wiki
Add New Page
Comments3 Share
Recipes page

The recipes page lists the most recent recipes first.

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 Edit

Cookbook original

In the original interface, the cookbook located on the left side of the screen.

When 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".
Cookbook selection

In the selection interface, the cookbook is a floating window which can be moved around the screen.

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:

Recipe detail page

Recipe detail page. The "Add to Cookbook!" button works if your Foldit client is connected to chat. Otherwise, use the recipe number to manually download the recipe.

  1. Start Foldit and load a puzzle. For this tutorial, use one of the beginner puzzles or a "revisiting" puzzle.
  2. Make sure your Foldit client is connected to chat. Check the "Chat - Global" area in the lower right of the screen.
  3. Log in the the Foldit website and go to the recipes page. All the recipes listed have been written and shared by Foldit players.
  4. 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
  5. Click on the green box in the upper right marked "Add to Cookbook!"
  6. 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.
  7. Look through the recipes and you will find the script you downloaded, "Beginner Rebuild SCRIPT 1.01".
Cookbook browse download recipes

The blue folder icon in the cookbook lets you manually download recipes. It takes you to the Foldit website if the client is connected to chat.

  1. 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.
  2. 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.
  3. The "Download Manually" window should appear if the client is not connected to chat.
  4. 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.)
  5. The recipe should now be available in the cookbook.

Running a recipe Edit

Cookbook recipe 1.01 detail

Hovering over a recipe in the cookbook shows you additional options. Click on the recipe name to run it. The small green arrow or "play" icon on the right also runs the recipe.

Now that you've loaded a script from the web, it's time to run it.

  1. Locate "Beginner Rebuild SCRIPT 1.01" in your recipes list, and hover over it with your mouse.
  2. Click the recipe name or (or the small green arrow to its right) to run it.
  3. 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

Cookbook show recipe output

The "DOS prompt" icon on the cookbook opens the recipe output window.

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.

  1. 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.
Recipe cancel

While a recipe is running, a small window showing the recipe name and a cancel button appears. "Show output" from this window also opens the recipe output window.

  1. While the recipe is running, you can also click on "Show Output" button in the small window that appears.
  2. The Recipe Output window appears. If you've already run the recipe, you'll see its output in the window.
  3. Move the recipe output window to a good location, where it doesn't obstruct the view of your protein.
  4. Rerun the same beginner script.
  5. 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)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.