How to Use - espertus/blockly-lua GitHub Wiki
-
Buy and install the PC or Mac version of Minecraft. :-)
-
Download and install ComputerCraft 1.57, which adds computers and turtles to Minecraft. Work through one of the provided tutorials, but don't worry too much about how to create Lua programs.
-
Get familiar with Blockly by playing with its Puzzle or Maze apps.
-
Visit the Blockly Lua application, and create this simple program with blocks from the "Text" category:
-
Click "Lua". You should see this Lua code:
print('I am a turtle.') -
Click on
on the upper-right.
-
You should see this window:
Change the name and expiration date to whatever you like, then click on "Save program to Pastebin". This will store your program on the Pastebin website. (If you're already a Pastebin member, you may prefer to copy and paste it using your own account.) After a short delay, you should see the URL for your program, as in this picture:
You can use the URL to view or share your program, but what's most important is the part after "http://pastebin.com/". That's your program's ID ("tMmuyKmP" in this example). -
Find a file named
ComputerCraft.cfgon your computer, and find a lineB:enableAPI_http=false. Replacefalsewithtrue, and save the file. This will enable you to usepastebinin the following step. You only need to do this once (unless you reinstall ComputerCraft). -
Create a mining turtle in Minecraft (which you should have learned to do in step 2). Right-click on it and enter
get pastebin XXX hello, but replace XXX with your program's ID from the end of step 7. This should fetch the program from the Pastebin website, put it onto the turtle, and name it "hello". -
Type "hello" (and press enter/return) into the turtle in Minecraft. It should print "I am a turtle."
[To be added.]
You can ask for help at the Blockly Lua thread at the ComputerCraft forum.
You can save your Blockly programs for sharing or later modification by clicking on the chain button on the upper right. You will be provided a URL you can use to revisit your program or share it with with others.
Read through existing programs, such as spiral staircase and dig. Feel free to modify them. Only you will see the changes (unless you save them and share the URL).
One important thing to know is that blocks can either represent expressions or statements. Expression blocks (such as numbers and addition) have a plug on the left side for providing the value, while statement blocks (such as print statements) do not produce a value. Note that statement blocks generally have a notch on top and a bump on bottom to connect to other statements; expression blocks never do.
Many of the [Turtle API](http://computercraft.info/wiki/Turtle_(API\)) functions, such as Turtle.forward return a boolean value indicating success or failure, which is frequently ignored. If you don't want to use the return value, you can convert the expression to a statement through the context menu, which can be reached by right-clicking on the block. Specifically, the bottom-most option on the expression version (left) is "Remove Output" (not shown), while the statement version (right) has the option "Add Output" (shown).

on the upper-right.


