ComputerCraft Computers, Programming and Robotics in Minecraft About ComputerCraft ComputerCraft is a modification for that’s all about. It allows you to build in-game and, and write programs for them using the. The addition of programming to Minecraft opens up a wide variety of new possibilities for automation and creativity. If you’ve never programmed before, it also serves as excellent way to learn a real world skill in a fun, familiar environment. ComputerCraft is funded by and. If you enjoy the mod, please consider making a donation, or buying a 3D printed pet turtle!
The more I get, the more time I can afford to spend making the mod even better! Original thread lies below. Introducing ComputerCraft! ComputerCraft is a Minecraft mod (with full multiplayer support) that adds in-game Computers. Each Computer has an operating system, a filesystem, a suite of builtin programs (including a text editor, a realtime Lua interpreter, and two games), and can be programmed to do anything you want with the easy-to-use Lua programming language.
Computers can interact with redstone wiring and bundled cables from the RedPower2 mod, meaning they can be used to fully automate and control your worlds. With peripheral devices, the capabilities of computers can be expanded further, with Disk Drives adding the ability to transfer files between computers and play music, Wireless Modems adding Wireless Networking between machines, Monitors adding external large external displays and Printers adding printing capabilities. But that's not all! Version 1.3 adds a new block to ComputerCraft: The Turtle. The Turtle is a small, portable robot, that can be programmed just as Computers, but with the added ability to move around the world, placing and destroying blocks as it goes.
A Turtle with the right programs can be used to build structures, kill monsters, mine resources, dig tunnels, control redstone on the move, craft, move and sort items, and a million and one things I haven't thought of yet. The machines have risen. Since the release of 1.0, many prominent mod reviewers have recorded spotlight videos of ComputerCraft, and many talented players have recorded videos of their creations.
Instead of cluttering up this thread with videos, here's some links to the best YouTube content: DOWNLOAD Current version: 1.53 (for Minecraft 1.5.2) ComputerCraft is provided completely free, with no adf.ly! If you enjoy the mod and would like to show your appreciation, visit our page. Or if that's not your thing: order a from our shapeways store!
All proceeds support the future development of the mod, plus they're really cool! Old versions: 1.52 (for Minecraft 1.5.1) 1.51 (for Minecraft 1.5) 1.5 (for Minecraft 1.4.7 or 1.4.6) 1.481 (for Minecraft 1.4.7 or 1.4.6) 1.48 (for Minecraft 1.4.6) 1.47 (for Minecraft 1.4.5 or 1.4.4) 1.46 (for Minecraft 1.4.2) 1.45 (for Minecraft 1.3.2) 1.41 (for Minecraft 1.2.5) 1.33 (for Minecraft 1.2.5) INSTALL. Install version 601 or above for Minecraft 1.5.1. Download ComputerCraft from one of the links above, and place it in the 'mods' folder in your minecraft directory. You're done! You should now be able to run the game, and start crafting and placing computers. (Optional) If you wish to edit or add to the programs that come installed with ComputerCraft, create a new folder called 'ComputerCraft' in your mods directory, extract ComputerCraft1.5.zip there, and delete the zip.
GET STARTED First, build a Computer (or its Advanced counterpart): Then right click on its screen to interact. You're now in the command prompt. Type 'help' for an introduction, then type 'programs' to see the list of programs you can run. Download free movie no sign up. Try running some of them. Type 'help' followed by the name of a program to find out what it does.
Don't miss 'worm' and 'adventure'! When you're ready to start creating your own programs, type 'help programming' for advice on learning the Lua programming language, then use 'edit' to create programs or 'lua' to just start entering code. All the programs and APIs on the system have their own help pages. Build a Disk Drive and Floppy Disks like so: Place the disk drive next to the computer, put a disk into the drive, and access your computer again. Type 'list', and you'll see that each Floppy Disk has it's own folder. Now you can use the 'copy' or 'move' commands to move your programs onto disks, and carry the disks around to transfer files between machines! For some light entertainment, try putting a record into a disk drive and running the 'dj' application.
Computer Disk Drives too static for you? Maybe you're ready to craft some Turtles: Access your Turtle like a computer, and you'll see the similarities. Turtles run programs just like Computers, but have access to new programs and a new API to make them move around and interact with the world. Add some coal to the turtle and fuel up your turtle with 'refuel', then try experimenting with the 'go', 'excavate' or 'craft' programs. To write your own turtle programs, use 'lua' or 'edit' just as with the computer, and call functions from the 'turtle' API. There's a lot these little guys can do! For truly advanced worlds, try building Wireless Modems and Wireless Turtles: Attach your modem to your computer (sneak-click to place it on the side), or craft it together with a Turtle, and you now have devices that can use the 'rednet' API to wirelessly send each other messages.
This is one of the more advanced areas of the Mod, and requires programming, but anybody who's used the internet knows the potential of wireless communication. New in ComputerCraft 1.31 is the Monitor peripheral, build it like so: Build lots of monitor blocks, and place them together, and you will see they expand to one contiguous display. If your computer is touching the display, it can be programmed to draw text to this screen, which will be visible to anyone who walks past. Try the monitor out by running the 'monitor' program, like 'monitor left hello'. Try to find the secret program added in 1.31 designed especially for monitors! New in ComputerCraft 1.42 is the Printer: Place a printer down next to your computer, supply it with paper and ink, or dye of any colour, and print messages for your friends! Either interact with the printer yourself using lua, or print documents using the 'edit' program!
Try feeding a printed page back into the input and changing the ink to print in different colours! That covers the basic features of ComputerCraft, and the potential for amazing automated creations should be clear.
Visit the forums at for help with Lua, programming, and to view and download programs and creations created by the community. If you make anything cool yourself, remember to share it with the world! VERSION HISTORY For the full list of program and API changes, type 'help whatsnew' at any computer ingame. 1.53. Ported to Minecraft 1.5.2. rs.setBundledOutput and rs.getBundledOutput now work with cables from Minefactory Reloaded, as well as RedPower. Monitors and Advanced Monitors can now be placed on floors and ceilings.
As always, plenty of bugfixes and stability improvements!
Extract from the: For syntactic reasons, a break or return can appear only as the last statement of a block (in other words, as the last statement in your chunk or just before an end, an else, or an until). For instance, in the next example, break is the last statement of the then block. Local i = 1 while ai do if ai v then break end i = i + 1 end Usually, these are the places where we use these statements, because any other statement following them is unreachable.
Sometimes, however, it may be useful to write a return (or a break) in the middle of a block; for instance, if you are debugging a function and want to avoid its execution. In such cases, you can use an explicit do block around the statement: function foo return.
Hey guys, I asked a question on here the other day and got a really good answer very quickly, so I thought I'd ask another question about some other stuff! I've seen some let's plays and some other Youtube videos that people have ComputerCraft setups that allow them to monitor they're bases' power systems and I think it's awesome. I've currently got a couple of MFSUs and nuclear reactors monitored with Nuclear Control's advanced panels but they're limited and have no controlling mechanisms (as far as I'm aware).
What I'd really love to do is to monitor my entire MFSU room - in each base - and be able to control my Nuclear Reactors based on what amounts of power they have. I'd also like to integrate into that, my BC power systems which includes a number of redstone energy cells. I have limited programming knowledge (I'm studying a degree in Computing and only one module is programming) so I don't really understand all the overly complicated systems that people have, but I seem to be able to learn programming pretty quickly. Anyways, all the tutorials and such that I've found online show you how to use the basic peripherals that come with the game and I can't find any tutorials that show me all these things. So, my questions are: How do I access the information on these different blocks? How do I use ComputerCraft to control the RedNet cables and thus switch on/off the reactors? How do I make a display showing total EUs and MJs stored and possibly even a GUI that allows me to manually override controls.
Thanks for help in advance! (I should probably have posted this on the CC forum, but since it's part of FTB and controlling non-CC things, I thought that here suited best) EDIT: I'm also curious about the turtles and how to set them up to mine a huge amount of materials in a group together. PC. Hi, unfortunately I don't know what modpack you are running but I am fairly confident that if it is anything that FTB put out since 1.5 you have open peripherals. There are a few APIs that you will need to take a look at from Vanilla Computercraft to start doing what you want.They are: peripheral - the peripheral.wrap method is needed for your computer to be able to talk to most peripherals, including monitors and MFSUs redstone - you can control rednet cable using the methods with 'bundled' in the name term - this has a few methods which will enable you to write stuff onto the monitor.When writing to the console you can just code. Code: print or write or term.write When writing to a monitor (or doing other things to a monitor) you need to remember the name of the variable to which you wrapped the monitor.
For the sake of argument I am going to assume it is monitor. For most of the methods in the term api replace the word term with monitor and then you can manipulate the monitor. If you want to use color on your monitor make sure to use advanced versions. You can find a list of all the basic Computercraft apis here - Don't be confused by the rednet one. In case you weren't already aware it is referring to computercrafts modem communication system. The mod Openperipherals allows your computers to interact at a closer level with many different blocks including modded and vanilla. That link will take you to the ic2 peripheral documentation where you should find methods to get information on the eu storage.
You need to wrap the MFSU as a peripheral before you can do any of this. If you can't, or just don't want to, attach your peripherals directly to your computer then you can do it with wired modems. Simply place a wired modem onto your peripheral and right click it.
It should turn red and there will be a chat message on your screen saying that peripheral x is connected. The name of the peripheral is important because you will use that string in lieu of a side for your peripheral.wrap command. You also need a wired modem on your computer and it all needs to be connected by the cable (I forget what its name is but there is only one in computercraft so pick that one). Open peripherals also works with Thermal Expansion and Buildcraft so check the documentation out for those too.
They are all on the same website as the IC2 ones. Hi, unfortunately I don't know what modpack you are running but I am fairly confident that if it is anything that FTB put out since 1.5 you have open peripherals. There are a few APIs that you will need to take a look at from Vanilla Computercraft to start doing what you want.They are: peripheral - the peripheral.wrap method is needed for your computer to be able to talk to most peripherals, including monitors and MFSUs redstone - you can control rednet cable using the methods with 'bundled' in the name term - this has a few methods which will enable you to write stuff onto the monitor.When writing to the console you can just code. Code: print or write or term.write When writing to a monitor (or doing other things to a monitor) you need to remember the name of the variable to which you wrapped the monitor. For the sake of argument I am going to assume it is monitor.
For most of the methods in the term api replace the word term with monitor and then you can manipulate the monitor. If you want to use color on your monitor make sure to use advanced versions. You can find a list of all the basic Computercraft apis here - Don't be confused by the rednet one. In case you weren't already aware it is referring to computercrafts modem communication system. The mod Openperipherals allows your computers to interact at a closer level with many different blocks including modded and vanilla. That link will take you to the ic2 peripheral documentation where you should find methods to get information on the eu storage.
You need to wrap the MFSU as a peripheral before you can do any of this. If you can't, or just don't want to, attach your peripherals directly to your computer then you can do it with wired modems. Simply place a wired modem onto your peripheral and right click it. It should turn red and there will be a chat message on your screen saying that peripheral x is connected. The name of the peripheral is important because you will use that string in lieu of a side for your peripheral.wrap command.
You also need a wired modem on your computer and it all needs to be connected by the cable (I forget what its name is but there is only one in computercraft so pick that one). Open peripherals also works with Thermal Expansion and Buildcraft so check the documentation out for those too. They are all on the same website as the IC2 ones.
Ehm using CC for this is way to complicated if you have access to the Nuclear Control mod. It adds Industrial information screens and energy sensor kits to let you monitor both EU storage and Redstone Energy cells. It also adds the Range Trigger that can output redstone signals depending on the energy level in in the monitored storage device.
Examples: Monitoring: -snip- Regulation of engines with Range Triggers: -snip- Regulation of MFSU for Geothermals to only run when solars isn't enough: -snip. Click to expand.Haha! Thanks, yeah. I doing some testing and got it to work with the computer touching but I couldn't figure out how to connect to the MFSU throught he wired modems (aww, why don't they make the old fashioned screechy noise)?
Turns out, that all I had to do was to right click the modem on the MFSU. I also automatically right clicked the one on the computer. I shall attempt to have some fun with this coding now and may have to redesign my MFSU room slightly.
I should show my server to someone who doesn't know about FTB (and some other mods) and show them that in Minecraft, you can build power stations, computers - to monitor and control things and finally all of that on a space station thanks to Galacticraft. Oh I imagine I'd be bored to death of MC by now if mods didn't exist. EDIT: I can't work Lua.
I've had the most experience in Java which is nothing like Lua. I've done a bit of bash and batch scripting which seems much more like Lua, but still not the same and I can't even figure out how to do a simple for loop to create the peripheral.wrap names for each of them.
I'm trying to put in something that will do the equivalent of. The mods keep me interested too, and I love controlling all the things with computercraft. Shameless self promotion incoming. I started a thread on community showcase that exhibits some cool computercraft control. It focuses on railcraft but in the attached imgur album there is a small mention of a tank monitoring program I wrote and also I had a bank of dartcraft engines that was computer controlled based on the storage in a Redstone energy cell. The less energy stored in the cell the more engines are made to run.
The railcraft stuff is quite interesting too (at least imho) and I reckon you might like it. If you are interested there is a link below.
The mods keep me interested too, and I love controlling all the things with computercraft. Shameless self promotion incoming. I started a thread on community showcase that exhibits some cool computercraft control. It focuses on railcraft but in the attached imgur album there is a small mention of a tank monitoring program I wrote and also I had a bank of dartcraft engines that was computer controlled based on the storage in a Redstone energy cell. The less energy stored in the cell the more engines are made to run. The railcraft stuff is quite interesting too (at least imho) and I reckon you might like it. If you are interested there is a link below.
Code: local data = 'Energy storage' = 1000000, 'Current Energy Stored' = 500000, 'Percentage Filled' = 50 for i,v in pairs(data) do - i = key and v = value. In pairs is just what you need to write in Lua so you can iterate through tables.
You put the name of the table you want to iterate through in the brackets in in pairs print(i.' : '.v) end - You end up with this printed to the console Energy storage: 1000000 Current Energy Stored: 500000 Percentage Filled = 50 If you want a for loop to wrap all your MFSUs (which is a good idea and I encourage it, it is more expandable) you can make a table called mfsu and have each key refer to a particular mfsu. I am putting how I would do it inside a spoiler because it already seems like you can work it out on your own now you know to use tables. But you can always look inside if you want. (btw, you can put tables inside of tables which can come in handy). Code: local mfsuID = 3 - in this example I am looking at the third mfsu in your array local energyStored = mfsumfsuID1.getStored local mfsuName = mfsumfsuID2 print('Energy Stored') print(mfsuName.' : '.energyStored) I could also use a generic for loop to iterate through each mfsu in the array.
In all honesty, if the only extra data you wanted to store was a name you could do it without making a subtable because you can easily generate the name when you are reading the main data. If however you wanted to get more data than from just one method then a subtable can come in handy. Omron cx-one trial.
Sorry if that makes no sense. However, in that other thread I made that I mentioned earlier I talk a bit about a program I wrote to get details about a group of tanks where I maybe explain myself a bit better, and with better code examples. Code: local data = 'Energy storage' = 1000000, 'Current Energy Stored' = 500000, 'Percentage Filled' = 50 for i,v in pairs(data) do - i = key and v = value. In pairs is just what you need to write in Lua so you can iterate through tables. You put the name of the table you want to iterate through in the brackets in in pairs print(i.' : '.v) end - You end up with this printed to the console Energy storage: 1000000 Current Energy Stored: 500000 Percentage Filled = 50 If you want a for loop to wrap all your MFSUs (which is a good idea and I encourage it, it is more expandable) you can make a table called mfsu and have each key refer to a particular mfsu. I am putting how I would do it inside a spoiler because it already seems like you can work it out on your own now you know to use tables.
But you can always look inside if you want. (btw, you can put tables inside of tables which can come in handy). Code: local mfsuID = 3 - in this example I am looking at the third mfsu in your array local energyStored = mfsumfsuID1.getStored local mfsuName = mfsumfsuID2 print('Energy Stored') print(mfsuName.'
: '.energyStored) I could also use a generic for loop to iterate through each mfsu in the array. In all honesty, if the only extra data you wanted to store was a name you could do it without making a subtable because you can easily generate the name when you are reading the main data. If however you wanted to get more data than from just one method then a subtable can come in handy. Sorry if that makes no sense. However, in that other thread I made that I mentioned earlier I talk a bit about a program I wrote to get details about a group of tanks where I maybe explain myself a bit better, and with better code examples.
Click to expand. Both of you are telling me exactly what I should've thought of! It's been a while since I've done much programming so I'd basically forgotten about tables and I don't think any of the tutorials I watched spoke about them at all. I'm a little confused as to exactly what everything's doing in your example, casilleroatr, but it certainly will allow me to get this working and hopefully figure it out from there. What I'm going to want to do is have a program running that monitors the overall storage and if i goes below a certain amount, the reactors will kick in and they'll cut off when it hits a certain percentage filled and such.
How To Terminate A Program In Matlab
Now to do some more testing with my extra knowledge and this as reference, and then on to converting my bases to work with this as I want it to when I've figured it out. I'll post here with any more issues I have or if I manage to succeed! Thanks for the help so far! Well I think I'm getting somewhere. I had a bit of a brainfart when trying to work out percentages but I just thought about it for a minute and got it. Anyways, I now have a system which asks you to enter the number of MFSUs, from that it works out the current, max and percentage filled (sort of) of the totals and then displays it to the terminal.
It doesn't have a loop so won't keep updated, though. Would the best and most efficient way to do that to make it sleep for 1 or 2 seconds and then repeat the for loop or would some other way work better? Finally, how do you multiply a number without it breaking?
'x' and '.' don't work. It errors out my code before it even runs and says 'multiple points'.
EDIT: Finally found on the wiki the operators, but it seems that '.' should work. EDIT2: Well it seems that putting it into a variable first works. Next issue: how do you knock off the digits after the decimal? If you don't mind me pointing you to that thread again about half way down the first post I have a program inside a spoiler which contains a rounding function.
You put the number that you want to round into the first argument and you put the number of decimal places into the second argument (0 would return a whole number). Its not my idea btw, I got it from a Lua website but I forget which one. You can also use the following commands math.ceil(x) math.floor(x) where x is the number that you want to floor or ceiling.
I don't quite understand why you are a having a multiplication problem it might be that the error is talking about something else. If you could show me your code then I might be able to tell you what the problem is, unless you already solved it that is. If you don't mind me pointing you to that thread again about half way down the first post I have a program inside a spoiler which contains a rounding function. You put the number that you want to round into the first argument and you put the number of decimal places into the second argument (0 would return a whole number).
Its not my idea btw, I got it from a Lua website but I forget which one. You can also use the following commands math.ceil(x) math.floor(x) where x is the number that you want to floor or ceiling.
I don't quite understand why you are a having a multiplication problem it might be that the error is talking about something else. If you could show me your code then I might be able to tell you what the problem is, unless you already solved it that is. Code: for a,b in pairs(peripheral.getNames) do - Loop through a table that contains names of ALL connected peripherals. If peripheral.getType(b) 'batbox' then - If a detected peripheral is a batbox, then. Mfsu#mfsu+1 = peripheral.wrap(b) - Sticking a # in front of a given variable generally returns the length of that variable.
Indexes in the table, in this case. StoredEUs = storedEUs + mfsu#mfsu.getStored maxEUs = maxEUs + mfsu#mfsu.getCapacity end endBasically it just grabs all energy storage units hooked up, rather then a user-specified amount. It may or may not be worth noting that when printing numbers, Lua may or may not print a decimal point even for integers depending on the exact data type.
'tostring( numericvariable)' generally avoids this. Code: for a,b in pairs(peripheral.getNames) do - Loop through a table that contains names of ALL connected peripherals. If peripheral.getType(b) 'batbox' then - If a detected peripheral is a batbox, then. Mfsu#mfsu+1 = peripheral.wrap(b) - Sticking a # in front of a given variable generally returns the length of that variable. Indexes in the table, in this case.
StoredEUs = storedEUs + mfsu#mfsu.getStored maxEUs = maxEUs + mfsu#mfsu.getCapacity end endBasically it just grabs all energy storage units hooked up, rather then a user-specified amount. It may or may not be worth noting that when printing numbers, Lua may or may not print a decimal point even for integers depending on the exact data type. 'tostring( numericvariable)' generally avoids this. The in pairs loop is just what you can use to iterate through a table. It is good because you don't have to know how long the table is, or what the keys are to to get through the whole table. Each point in a table has a stored value which is referred to by a key - together they form a pair.
How To Terminate A Program On Mac
So when you say you are saying, 'for each pair in table t, return the key to variable i and the value to variable v'. In Bomb Bloke's example (kudos by the way I hadn't though of that) he uses the function peripheral.getNames which returns the table so that you can iterate through it.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |