computercraft programs post here to share

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here

roelie333

New Member
Jul 29, 2019
14
0
0
i was wondering if you all have programs u want to share with us to use and to inprove on or concepts or anything that has to do with programming.
post down below if u have some
 

nevakanezah

New Member
Jul 29, 2019
177
0
0
Code:
while (true) do
  if turtle.getFuelLevel < 64 then
    turtle.refuel(1)
  end
  turtle.dig()
  turtle.forward()
  turtle.digUp()
  turtle.digDown()
  turtle.down()
end
Quick and dirty staircase to bedrock. fuel goes in first slot.
 
  • Like
Reactions: Fuzzbling

vScourge

New Member
Jul 29, 2019
71
0
0
Simple one. Download latest code from pastebin ID specified then runs it. Name this script "startup" and it will run when turtle/computer boots. Requires the "enableapi_http" option to be enabled in server's ComputerCraft config file.

Code:
id = 'pastebin id here'
if fs.exists( id )
   fs.delete( id )
end
shell.run( 'pastebin', 'get', id, id )
shell.run( id )
 

nevakanezah

New Member
Jul 29, 2019
177
0
0
Simple one. Download latest code from pastebin ID specified then runs it. Name this script "startup" and it will run when turtle/computer boots. Requires the "enableapi_http" option to be enabled in server's ComputerCraft config file.
Oddly enough, last time i tried to use the pastebin command, it insisted i had the HTTP api disabled, despite having configured and rebooted the server specifically to allow it.
 

glepet1962

Well-Known Member
Nov 15, 2012
125
57
54
I'm a real big noob when it comes to the computercraft programs. I saw a mining turtle program that I wanted to try out but i didn't know what to do when downloading. Do I download as a text and then copy paste while in MC? I tried that but it didn't work. I guess I would need a little more handholding - some step by step assistance. Thanks
 

MilConDoin

New Member
Jul 29, 2019
1,204
0
0
Do you want that code to be available for all your turtles, whenever you place them?
Go to "Feed the Beast\<modpackname>\minecraft\mods\ComputerCraft\lua\rom\programs\turtle" and place the program there (at least in local play. For a server it is more difficult to add something to the rom, AFAIK).
The ComputerCraft\lua\... paths probably need to be made beforehand.
 

slay_mithos

New Member
Jul 29, 2019
1,288
0
0
I'm a real big noob when it comes to the computercraft programs. I saw a mining turtle program that I wanted to try out but i didn't know what to do when downloading. Do I download as a text and then copy paste while in MC? I tried that but it didn't work. I guess I would need a little more handholding - some step by step assistance. Thanks
I will take my not-so-finished code as example.

1/ go to the config file for computercraft, and put "B:enableAPI_http=false" to "true"

2/ get the pastebin code for the code you want (http://pastebin.com/Acewyb2T , you would only take the Acewyb2T)

3/ label your turtle/computer (label set myturtle), no space in the name.

4/ get the code to the turtle/computer (pastebin get Acewyb2T mine)
The last word is the name the program will have on your computer/turtle, here "mine".

5/ use your program with the name you typed in the previous command (mine 16).

If you did all the first 4 correctly, the 5th should work.

Alternatively, once you labeled your turtle, you can also go to the save folder for the world, there will be a folde for computercraft, containing all the folders for each turtle and computer in your world, and you can paste the file there.
Please do remove any extension to the name (like "script.txt", remove the .txt), or else you will have to type it in your turtle to start the program, that can get really annoying in the long run.


EDIT for the above poster:
Do you want that code to be available for all your turtles, whenever you place them?
Go to "Feed the Beast\<modpackname>\minecraft\mods\ComputerCraft\lua\rom\programs\turtle" and place the program there (at least in local play. For a server it is more difficult to add something to the rom, AFAIK).
The ComputerCraft\lua\... paths probably need to be made beforehand.

That is really not a good way to do it.
Sure, it will let every single turtle in your world have access to it, but refrain from making too much programs available to everything, as it will consume a little more RAM for each one on each turtle.

Plus, you might want to specialize your turtles, so a mining turtle would have no use for a program that is used to craft or to cut trees.
 

ATYPICAL

New Member
Jul 29, 2019
43
0
0
"pastebin get 505X8SHf wither"
link to my turtle program which infinitely spawns Withers and kills them using the MFFS blocks, more quick explanation in this video:
 

UNOBTANIUM

New Member
Jul 29, 2019
11
0
0
Hello there,
some weeks ago i started making a program, that chop down Fir Trees for you. I know that doesnt seems special, but if you take the menu, selfsustaining, storage, selfbuild, debug and expanded versions in count, it is a really complex program pack.
For more informations check out this thread in the ComputerCraft Forum:
http://www.computercraft.info/forum...686-fir-wood-chopper-selfbuildingmenueasy061/
If the link does not work simply google: Fir Wood Chopper and you will find it ;D

See you there ;D
UNOBTANIUM
 

Angry_Dragonoid

New Member
Jul 29, 2019
2
0
0
Hey, I'm currently writing a turtle butler program. It's not quite all the way done just yet...

So far it automatically farms and 5 x 5 x 3 (in a straight line) You have write the program of where to go, unless you just want to follow EXACTLY how to set the turtle up...It's still in Alpha. So far, it asks what you want it to do, there are extra lines that describe what functions there are. There are only two FULL operations for it to do, Tool, and Farm. when you do Tool you only have the option for either Pickaxe or Axe. Then after you choose those, it will ask what kind of material. Wood - Diamond. Any modded materials you'll have to add yourself, but the crafting would all be the same, so you would just need to make it move to the extra pickup station...There's quite a bit in this program, so I'll have to get pictures later today, I'll try to get those and then edit them into here if I can. Not uploaded anywhere just yet, I'l insert the current code into here for right now though.

The startup spoiler is for the "Login" at the startup of the turtle, after you enter the current Password, 3577, which I made the defualt (You can change it by doing Ctrl+T for a second then doing edit startup. It's a VERY short code so it shouldn't be very hard to find the four digit cooode to change it.)

term.clear()
term.setCursorPos(1,1)
write("Please Enter Password: ")
input = read("*")
while input ~= "3577" do
term.clear()
term.setCursorPos(1,1)
print("Incorrect Password...please try again!")
write("Please Enter Password: ")
input = read("*")
end
while true do
term.clear()
term.setCursorPos(1,1)
shell.run("Butler")
end

function returnCarrot()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.forward()
turtle.down()
turtle.down()
turtle.down()
turtle.turnRight()
for r = 1, 10 do
turtle.forward()
end
if turtle.detect() then
turtle.turnRight()
end
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnLeft()
end
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.up()
turtle.up()
turtle.up()
end
depositItems()
end
function depositItems()
turtle.turnRight()
cleanInv()
for t = 1, 8, 1 do
turtle.select(t)
turtle.drop()
end
turtle.turnLeft()
end
function cleanInv()
turtle.select(13)
turtle.transferTo(5)
turtle.select(5)
turtle.transferTo(13,16)
turtle.select(14)
turtle.transferTo(6)
turtle.select(6)
turtle.transferTo(14,16)
turtle.select(15)
turtle.transferTo(7)
turtle.select(7)
turtle.transferTo(15,16)
turtle.select(16)
turtle.transferTo(8)
turtle.select(8)
turtle.transferTo(16,16)
turtle.select(1)
end
function turnAround()
while turtle.detect() do
turtle.turnRight()
end
end

function getOrders()
print("What do you need?: ")
print("[1] Tools")
print("[2] Farm")
print("[3] Main PC")
write("> ")
input = io.read()
if input == "1" then
do
term.clear()
term.setCursorPos(1,1)
whatTool()
end
end
if input == "2" then
do
term.clear()
term.setCursorPos(1,1)
whichField()
end
end
end

function whatTool()
term.clear()
term.setCursorPos(1,1)
print("What tool would you like for me to make you, Sir?:")
print("[1] Pickaxe")
print("[2] Axe")
print("[3] <--")
write("> ")
tool_input = io.read()
if tool_input == "3" then
do
term.clear()
term.setCursorPos(1,1)
getOrders()
end
end
if tool_input == "2" then
do
term.clear()
term.setCursorPos(1,1)
materialChoice()
craftAxe()
end
end
if tool_input == "1" then
do
term.clear()
term.setCursorPos(1,1)
materialChoice()
craftPick()
end
end
end
function matPick2()
turtle.turnLeft()
turtle.up()
turtle.select(2)
turtle.suck(2)
turtle.down()
turtle.turnRight()
turtle.select(1)
end
function matPick1()
turtle.turnRight()
turtle.select(1)
turtle.suck(3)
turtle.turnRight()
end
function materialChoice()
term.clear()
term.setCursorPos(1,1)
print("What material should I use?")
print("[1] Wood")
print("[2] Stone")
print("[3] Iron")
print("[4] Gold")
print("[5] Diamond")
print("[6] <--")
material_input = io.read()
if material_input == "6" then
do
term.clear()
term.setCursorPos(1,1)
whatTool()
end
end
if material_input == "4" then
do
term.clear()
term.setCursorPos(1,1)
print("Getting you a Gold Pickaxe, Sir...")
moveTo()
for m = 1, 9 do
turtle.forward()
end
matPick1()
for m = 1, 6 do
turtle.forward()
end
matPick2()
for m = 1, 3 do
turtle.forward()
end
moveBack()
end
end
if material_input == "5" then
do
term.clear()
term.setCursorPos(1,1)
moveTo()
for m = 1, 15 do
turtle.forward()
end
matPick1()
for m = 1, 12 do
turtle.forward()
end
matPick2()
for m = 1, 3 do
turtle.forward()
end
moveBack()
end
end
if material_input == "3" then
do
term.clear()
term.setCursorPos(1,1)
print("Getting you an Iron Pickaxe, Sir...")
moveTo()
for m = 1, 12 do
turtle.forward()
end
matPick1()
for m = 1, 9 do
turtle.forward()
end
matPick2()
for m = 1, 3 do
turtle.forward()
end
moveBack()
end
end
if material_input == "2" then
do
term.clear()
term.setCursorPos(1,1)
print("Getting you a Stone Pickaxe, Sir...")
moveTo()
for m = 1, 6 do
turtle.forward()
end
matPick1()
turtle.forward()
turtle.forward()
turtle.forward()
matPick2()
for m = 1, 3 do
turtle.forward()
end
moveBack()
end
end
if material_input == "1" then
do
term.clear()
term.setCursorPos(1,1)
print("Getting you a Wooden Pickaxe, Sir...")
moveTo()
for m = 1, 3 do
turtle.forward()
end
turtle.turnRight()
turtle.select(1)
turtle.suck(3)
turtle.select(2)
turtle.up()
turtle.suck(2)
turtle.down()
turtle.turnRight()
for m = 1, 3 do
turtle.forward()
end
moveBack()
end
end
end


function moveTo()
depositItems()
turtle.select(1)
while not turtle.detectDown() do
turtle.down()
end
if turtle.detect() then
turtle.turnRight()
turtle.turnRight()
end
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnRight()
end
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnRight()
end
end
function moveBack()
turtle.turnLeft()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnLeft()
end
while not turtle.detect() do
turtle.forward()
end
while turtle.detect() do
turtle.up()
end
end
function craftAxe()
turtle.select(12)
turtle.equipRight()
turtle.turnLeft()
turtle.select(1)
for d = 3, 16, 1 do
turtle.select(d)
turtle.drop()
end
turtle.turnRight()
turtle.select(2)
turtle.transferTo(6,1)
turtle.transferTo(10,1)
turtle.select(1)
turtle.transferTo(2,1)
turtle.transferTo(5,1)
turtle.craft()
turtle.turnLeft()
for g = 9, 15 do
turtle.select(g)
turtle.suck()
end
turtle.select(12)
turtle.equipRight()
turtle.turnRight()
turtle.select(1)
print("Axe complete!")
end
function craftPick()
turtle.select(12)
turtle.equipRight()
turtle.turnLeft()
turtle.select(1)
for d = 3, 16, 1 do
turtle.select(d)
turtle.drop()
end
turtle.turnRight()
turtle.select(2)
turtle.transferTo(6,1)
turtle.transferTo(10,1)
turtle.select(1)
turtle.transferTo(2,1)
turtle.transferTo(3,1)
turtle.craft()
turtle.select(12)
turtle.equipRight()
turtle.turnLeft()
for g = 9, 15 do
turtle.select(g)
turtle.suck()
end
turtle.turnRight()
turtle.select(1)
print("Pickaxe complete!")
end
function gotoFarm()
depositItems()
while not turtle.detectDown() do
turtle.down()
end
turtle.turnRight()
turtle.turnRight()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnRight()
end
while not turtle.detect() do
turtle.forward()
end
turtle.turnLeft()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnLeft()
turtle.up()
turtle.up()
turtle.up()
turtle.forward()
end
end
function approachSugarCane()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnLeft()
end
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnRight()
end
turtle.up()
end
function farmSugarCane()
turtle.select(9)
turtle.equipLeft()
turtle.select(11)
turtle.equipLeft()
turtle.select(1)
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.down()
turtle.turnRight()
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
for s = 1, 5 do
turtle.forward()
turtle.dig()
end
turtle.turnRight()
turtle.down()
request()
end
function whichField()
print("Which field?")
print("[1] Wheat")
print("[2] Carrots")
print("[3] Potatos")
print("[4] Pumpkins (WIP)")
print("[5] Melons (WIP)")
print("[6] SugarCane (WIP)")
print("[7] <--")
farm_input = io.read()
if farm_input == "7" then
do
term.clear()
term.setCursorPos(1,1)
getOrders()
end
end
if farm_input == "6" then
do
gotoFarm()
approachSugarCane()
farmSugarCane()
request()
end
end
if farm_input == "5" then
do
gotoFarm()
approachPumpkins()
FarmMelons()
request()
end
end
if farm_input == "4" then
do
gotoFarm()
approachMelons()
FarmMelons()
request()
end
end
if farm_input == "3" then
do
gotoFarm()
approachPotatos()
Farm()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
Farm()
request()
end
end
if farm_input == "2" then
do
gotoFarm()
approachCarrots()
Farm()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
Farm()
request()
end
end
if farm_input == "1" then
do
gotoFarm()
approachWheat()
Farm()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
Farm()
request()
end
end
end

function request()
write("What next? Another field? Or back home?:")
request_input = io.read()
if request_input == "Return" then
do
local x, y, z = gps.locate(5)
if not x then
print("Failed to find location!")
else
print("I am at (" .. x .. ", " .. y .. ", " .. z .. ")")
end
end
end
if request_input == "Wheat" then
do
turtle.turnRight()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
do
turtle.turnRight()
end
end
turtle.select(9)
turtle.equipLeft()
turtle.select(15)
Farm()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnLeft()
Farm()
request()
end
end
end

function returnFarm()
turtle.forward()
turtle.down()
turtle.turnLeft()
while turtle.detectDown() do
turtle.forward()
end
if not turtle.detectDown() then
do
turtle.down()
turtle.down()
end
end
turtle.turnLeft()
turtle.turnLeft()
for r = 1, 10 do
turtle.forward()
end
turtle.turnRight()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
do
turtle.turnLeft()
end
end
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
do
turtle.up()
turtle.up()
turtle.up()
end
end
depositItems()
print("I'm Home!!!")
end

function approachPumpkins()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnRight()
end
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnLeft()
turtle.select(10)
turtle.equipLeft()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
turtle.digDown()
turtle.forward()
end

function approachPotatos()
turtle.turnRight()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
do
turtle.turnLeft()
turtle.turnLeft()
end
end
turtle.forward()
turtle.forward()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.select(9)
turtle.equipLeft()
turtle.select(13)
end

function approachCarrots()
turtle.turnLeft()
turtle.forward()
turtle.forward()
turtle.turnRight()
turtle.select(9)
turtle.equipLeft()
turtle.select(14)
end

function approachWheat()
turtle.turnLeft()
while not turtle.detect() do
turtle.forward()
end
if turtle.detect() then
turtle.turnRight()
end
turtle.select(9)
turtle.equipLeft()
turtle.select(15)
end

function Farm()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.turnRight()
turtle.forward()
turtle.turnRight()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
turtle.digDown()
turtle.placeDown()
turtle.forward()
end

turnAround()
getOrders()


Okay! That's all of the code! I'm having a bit of troubles on the Return function. It works PERFECTLY on the Wheat section, BUT on the Carrots, Pumpkins, Potatoes, Melons, and the Sugarcane, I don't want to have to type in MULTIPLE different return functions according to which field its it, I want to be able to just type in Return, and it finds its coordinates or something, and then according to which coodinates (field) it's at, it runs the specific function. Without me having to do a different option for EVERY FIELD! I know I'll still have to do the "Return" function for every field, but I don want to have to do something like ReturnWheat, ReturnCarrot, or ReturnPotato after each field...If you could help, that would be great! I already have it set so it finds it coordinates, now it's just to figure out how to get it to take those coordinates, and use them in a function... I'll be trying to get this going by myself, but it would be alot quicker to get this pushed out if I got help...thanks!

If you have a solution:

E-Mail: [email protected]
Skype: danielboling1
Cell: (574)-312-8134 (Call or text, text would probably be best if you can...thanks.)
You can also put my phone number into something like AIM and text me that way if you don't have a phone.
 

Angry_Dragonoid

New Member
Jul 29, 2019
2
0
0
I don't know how exactly to use the spoilers... :p It would also be great if you could let me know how to use that! Just for future reference! Thanks!
 

rhn

Too Much Free Time
Nov 11, 2013
5,706
4,420
333
I don't know how exactly to use the spoilers... :p It would also be great if you could let me know how to use that! Just for future reference! Thanks!
bZD7mIb.png

For code you want to use the Code environment however. It shows the text as it is, not as smilies and other things that happens to be interpreted as BBcode.

Also, you really want to use some "for loops" I think for those long repetitive stretches of code :p

Btw: I would not want to have my email and phone number visible on a publicly open forum like that. It is an invitation for spam and phishing mails/calls. If not worse.
 
Last edited: