How to program on computercraft
It is possible to craft all three without ever writing an actual program, just using the built-in programs provided by the mod This guide assumes that the user has no to little experience with Lua , the programming language used by ComputerCraft and will give some basics as it progresses. Please also note that this guide is only going to touch on some of the basic concepts and components of ComputerCraft ; additional information can be found at ComputerCraft's Official Site as well as throughout this wiki and guides that will come at later dates.
The first and most basic component of ComputerCraft is the Computer. The recipe is fairly inexpensive and can be made relatively early if one lucks out finding redstone. The computer may be placed down wherever the player likes and can be picked up again by breaking it with any tool. Right-clicking on the Computer brings up the CraftOS command line CraftOS is the default operating system for computers ; it's from here where most users run programs on their computers.
All commands are run from the CraftOS. Note that parameters in italics are considered optional. Retrieves the contents of the supplied Pastebin code and saves it as the file specified.
This command is immensely useful for sharing code that one has created as well as allowing one to write code in an external editor and importing it into the game. Pastebin has 2 main arguments, put and get. There are many more commands, but one can easily read up on those by using the help command. The following keyboard shortcuts can be used to control the computer and are handy for escaping from an infinite loop or testing startup scripts. To start a new program, simply type edit followed by a file name.
This guide will start with the first two obvious programs to get the user's feet wet, but will quickly move to specific examples that apply to CraftOS and ComputerCraft 's interaction with other objects in the world. Functions and API methods used in examples will have links that will explain them further. The traditional first step in almost any programming language is learning how to output a simple line of text usually "Hello world.
This example will show the reader how to do that via basic use of the print function. Simple, right? Save the file and exit the editor, then type in the name of the program. All going well, the following will appear in the CraftOS window:.
Congratulations on taking the first step in any programming language. Although only one line, this program demonstrates how to output text to the window. Mar 30, , am by Siftos. Started by Flexico. Mar 29, , am by QuickMuffin Started by RubenKnijn. Mar 14, , am by RubenKnijn. Started by SamH. Jan 20, , am by SamH. Started by Joob. Jan 10, , pm by Joob. Oct 20, , pm by QuickMuffin Started by keplerc. Sep 28, , am by cynagen. Started by JakobDev. Sep 15, , pm by Tomodachi Started by LDDestroier.
Aug 25, , am by LDDestroier. Poll Moved Topic. Locked Topic Sticky Topic. Forums Wiki Discord Donate. Mobile Main Menu. Turtle Programs Programs specifically designed to run on Turtles. For a better experience, please enable JavaScript in your browser before proceeding.
Zerro New Member. Jul 29, 0 0. Greetings, I am having problems trying to get my turtles to terminate their programs. The turtle is a mining turtle with a wireless modem. I am running Direwolf20's 'awaitCommand' prog on my turtles and a 'startup' prog. CenturionArcher New Member.
Jul 29, 22 0 0. EDIT: Sorry missed the end of the first sentence. I'm not sure what to do then. CenturionArcher said:. Bomb Bloke New Member.
0コメント