ComputerCraft Code Writers

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

39cluesEKAT

New Member
Jul 29, 2019
95
0
0
Here is a thread I would like to post for people who need help with computercraft. A person can post their problem, and another person will come to their aid and write their program. Also, a little tutorial on how to make slight changes to that program to fit a persons specifications. Here is a program I would like built:

A touchscreen elevator with numbers on each of the buttons. The program would hopefully be able to remember what floor it is on, and subtract or add the number of required blocks up or down. A redstone pulse to a bundled cable will do. In my building, there will be 25 floors, each eight blocks tall. On startup, the computer will have to go all the way down to make sure it knows what floor it would be on. Also, if possible, a way to call an elevator to that floor using the rednet. Resources is not an issue, neither is space if it can output to a bundled cable.
 

Chocorate

New Member
Jul 29, 2019
1,257
0
0
Yeah, how do i start writing programs? I keep getting stuck on the part where you click the computer screen.
 

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
So you want someone to build you programs?

Now I can understand "I have this program idea, it does x. I figured out how to do everything else except this. Can anyone help me out?"
If you said: "I have this idea, and would anyone know if it is possible? Any problems I may have while trying to program it?" that could work.
But "I'm too lazy to think this through, and I'd like someone to create a program for me from scratch with very little information."
I don't think that cuts it.

I'm not sure if you thought this through, because people don't spend their time on the forums writing programs for other people.


They spend their time rapping.
 
  • Like
Reactions: Abdiel

Chocorate

New Member
Jul 29, 2019
1,257
0
0
So you want someone to build you programs?

Now I can understand "I have this program idea, it does x. I figured out how to do everything else except this. Can anyone help me out?"
If you said: "I have this idea, and would anyone know if it is possible? Any problems I may have while trying to program it?" that could work.
But "I'm stupid, and I'd like someone to create a program for me from scratch with very little information."
I don't think that cuts it.

I'm not sure if you thought this through, because people don't spend their time on the forums writing programs for other people.


They spend their time rapping.
People who have a lot of spare time on their hands help people. While I do agree that the thread creator should have given more information and met us half way, that's not the way to respond to it. Telling people they did something wrong and they're stupid doesn't help.
 
  • Like
Reactions: jumpfight5

jumpfight5

New Member
Jul 29, 2019
1,750
0
1
People who have a lot of spare time on their hands help people. While I do agree that the thread creator should have given more information and met us half way, that's not the way to respond to it. Telling people they did something wrong and they're stupid doesn't help.

Edited. Unfortunately I have yet to see anyone full on create a program for someone who asked. Especially something as complex as that. I can see someone helping him if he got the bulk of the program down, but it just annoys me how he asks for a working code. It's like asking you to download my world, make a frame quarry, and send me the new download.
It's effort. If I wanted a program built, I'd look up some wikis, work my way up to something this complex, and build it myself. Run into a problem? That's when you ask other people.

Now if the problem is tutorial-finding, there's SethBling.
 

Fuzzlewhumper

New Member
Jul 29, 2019
500
0
0
Gunna give everyone the shaft ...

Code:
--Make a shaft
local length = 5
local slot = 1
 
if turtle.getFuelLevel() < (length * 3) then
print "Not enough Fuel"
error()
end
 
for i = 1,length do
 
slot = 16
while turtle.getItemCount(1) < 6 do
  turtle.select(slot)
  turtle.transferTo(1)
  slot = slot -1
  if slot == 0 then
  print "Out of Materials"
  for b = 1, length - i do
    turtle.back()
  end
  error()
  end
end
 
turtle.select(1)
 
if turtle.detect() then
turtle.dig()
end
 
if turtle.detectDown() == false then
if not turtle.placeDown() then
end
 
end
 
turtle.turnLeft()
 
if turtle.detect() == false then
turtle.place()
end
 
turtle.turnRight()
turtle.turnRight()
 
if turtle.detect() == false then
turtle.place()
end
 
turtle.turnLeft()
 
if turtle.detectUp() then
turtle.digUp()
end
 
turtle.up()
 
if turtle.detectUp() == false then
turtle.placeUp()
end
 
turtle.turnLeft()
 
if turtle.detect() == false then
turtle.place()
end
 
turtle.turnRight()
turtle.turnRight()
 
if turtle.detect() == false then
turtle.place()
end
 
turtle.turnLeft()
 
turtle.down()
 
turtle.forward()
 
end
 
for i = 1, length do
turtle.back()
end
For this you'll need a turtle with a pickaxe so it can dig out when it needs to.
First fuel up your turtle by giving it some charcoal or coal or wood or lava and type refuel all
Then fill up the turtle with the materials you want to use to make the shaft with.
edit the length variable to the length you want the shaft to be.
Run the program.

You'll end up with a straight and long shaft. Perfect for when you want to delve deeply into the nether.

I got tired of the ghasts shootin at me in the nether so I threw this together so I wouldn't drop to my death in the darn lava.

It's not whatcha call art, it's just a down dirty bit o code to get the job done.
 
  • Like
Reactions: Chocorate

Fuzzlewhumper

New Member
Jul 29, 2019
500
0
0
Pfft, got another one I use with the quarry turtle.

I call it Stashit (Shash It), whatever you thought you read is wrong cuz you just got a dirty mind.

Code:
turtle.select(4)
 
while true do
if turtle.suck() then
  if (turtle.compareTo(1) or turtle.compareTo(2) or turtle.compareTo(3)) then
  turtle.dropDown()
  else
  turtle.dropUp()
  end
else
  sleep(10)
end
end
Just need a basic turtle and no attachments, tools, fuel, just works right outta the box.
Set it up facing the chest you want it to work with.
Fill the first three slots in the turtle with the items you don't really want to keep. If you wanna keep everything, fill those three slots with a stick or something you can't possibly mine out of the environment.
Under the turtle can be lava, a chest, or I prefer one of those blue crystals that damages you - it also destroys stuff like cactus does.
Above it should be the chest you want filled with the good loots.

It'll grab an item from the chest it's facing. Compare that item to the items in the first three slots, and if it's a match - drop it down to it's doom. Heck, ya can just dig a little hole and if you wanna collect the crud just jump down for it otherwise it'll despawn in 5 minutes.

After the chest it's maintaining is empty the turtle will go into sleep mode for 10 seconds and check the chest again. So it's not intensive on the server checking constantly.
If you want this turtle to be doing this when the server restarts or the chunk loads, just name the program startup and it'll run automatically. Hit CTRL-T and hold for 3 seconds to terminate a running turtle program.

Later. :p
 

theoctagon

New Member
Jul 29, 2019
13
0
0
Greetings;

Initially speaking, this thread was for an elevator program. I have one, however its a bit of a cheat. I use the Elevator mod, and either wireless redstone or bundled cable, and sticky pistons w/elevator base blocks above and below the floors. I'm no master programmer by a very long shot, but this works for me. Simply put, computer on each floor w/menu. Select your floor - it sends a signal to the designated floor, which based on your calculated direction, pushes out an elevator base either above or below the floor to stop you (depending on direction up or down). The mod has an elevator base block that prevents damage on long descents.

It requires:
Computercraft and computers.​
Elevator Mod(allows for 'chutes' to be set up for specific directions (up or down or sideways))​
Currently set up for bundled cable use, so it requires the bundleAPI - can be slightly altered for wireless redstone use and simple redstone input.​
Output can be wired or wireless. Wireless works best.​

Sends and receives signals through to the floors, no need to remember and no 'elevator' to call. Slight drawback if rednet is used to send signals, and that is distance of transmission. There is a limit for the rednet modems. There is no limit to wireless however. Something to consider in your designs.

****************************************
os.loadAPI("/rom/apis/bundleAPI")
-- elevator program
-- set modem side, cable side, computerid below
-- must have bundleAPI loaded

flr = 0
curflr = 6 -- your current floor of installation
outputside = "back"
modemside = "right"
-- computer id numbers
-- comp# = current floor
-- # = computer id #
comp1 = 1
comp2 = 5
comp3 = 3
comp4 = 16
comp5 = 5
comp6 = 18
comp7 = 7
comp8 = 20
comp9 = 21
comp10 = 22

local self = os.getComputerLabel()

function chgflr(flr,dir)
print(flr," = floor passed")
if flr == 1 then
flr = tonumber(comp1)
elseif flr == 2 then
flr = tonumber(comp2)
elseif flr == 3 then
flr = tonumber(comp3)
elseif flr == 4 then
flr = tonumber(comp4)
elseif flr == 5 then
flr = tonumber(comp5)
elseif flr == 6 then
flr = tonumber(comp6)
elseif flr == 7 then
flr = tonumber(comp7)
elseif flr == 8 then
flr = tonumber(comp8)
elseif flr == 9 then
flr = tonumber(comp9)
elseif flr == 10 then
flr = tonumber(comp10)
end
print(flr," ",dir)
rednet.send(flr,dir)
print("Message sent to the ",flr," floor")
print("Your direction is ",dir)
print("You have 10 seconds to arrive.")
os.sleep(10)
term.clear()
end

function scrnmsg(flr,dir)
term.clear()
term.setCursorPos(1,1)
print("Hello, I am ", self)
print("Please select floor: ")
print("1: Floor 1 ")
print("2: Floor 2")
print("3: Floor 3")
print("4: Floor 4")
print("5: Floor 5")
print("6: Floor 6")
print("7: Floor 7")
print("8: Floor 8")
print("9: Floor 9")
print(" ")
print("Any other key to exit")
flr = read()
-- can insert an integrity check here to ensure choice
-- otherwise exits with error at command line
flr = tonumber(flr)
print()
print("You've selected: ", flr)

if flr == curflr then
print("Same floor")
flr = 0
return
end

if flr <= curflr then
dir = "up"
end

if flr >= curflr then
dir = "down"
end

if flr <= 1 then
flr = 1
end

-- print(flr)
chgflr(flr,dir)

return
end

function listen(sender, message)
rednet.open(modemside)
sender, message = rednet.receive()
print("Sender: ", sender, " Sent the following message: ",message)
if message == "up" then
colr="red"
bundleAPI.on(outputside,colr)
print("Activated upper")
os.sleep(15)
bundleAPI.off(outputside,colr)
end
if message == "down" then
colr="blue"
bundleAPI.on(outputside,colr)
print("Activated lower")
os.sleep(15)
bundleAPI.off(outputside,colr)
end

return sender, message
end

--- Begin program run
while true do
term.clear()
print("Starting .....")
parallel.waitForAny(scrnmsg, listen)
-- print("next ...") -- testing
-- print(flr) -- testing
-- print("Done") -- testing
end

***********************

Hope it helps!
 

Bigglesworth

New Member
Jul 29, 2019
1,069
0
0
You'll learn fast faster watching this series and following along ingame than staring at a bunch of pre-made code.