This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Th3RadMan's profile picture

How do I do this?

Started by Th3RadMan, 29 July 2013 - 09:25 PM
Th3RadMan #1
Posted 29 July 2013 - 11:25 PM
another question :rolleyes:/>

title: How do I do this?

look for the comments in the code:

	
function select()
	
  turtle.getFuelLevel(x)
	
  if x < 50 then
	
  turtle.select(16)
	
  turtle.refuel(1)
	
  turtle.select(1)
	
	endturtle.getItemCount(1)
	
	if 0 then turtle.select(2)
	
	  end
	
end
	
term.clear()
	
term.setCursorPos(1,1)
	
print("Enter Height:")
	
  local h = read()
	
  term.clear()
	
  term.setCursorPos(1,1)
	
print("Enter Length:")
	
  local l = read()
	
  term.clear()
	
  term.setCursorPos(1,1)
	
print("Enter Width:")
	
  local w = read() --take number from here
	
  term.clear()
	
  term.setCursorPos(1,1)
	
end
	
turtle.select(1)
	
turtle.turnLeft()
	
for w = 0, w do --and add it into this
	
select()
	
turtle.back()
	
turtle.place()
	
end
also, how does the function look, did i do the get fuel (x) correctly?

Thanks!
Edited by
Cranium #2
Posted 30 July 2013 - 10:45 AM
Split into new topic, and added [co<b></b>de] tags
jesusthekiller #3
Posted 30 July 2013 - 11:40 AM
Line 2 should be

local x = turtle.getFuelLevel()

You forgot to hit ENTER at line 7

Many more…




You are new to programming, right? You will find CCLua tutorials here: http://www.youtube.c...8&amp;v=1qj-KWxeLog

FunshineX (unlike DW20) teaches pretty well :)/>
Kilobyte #4
Posted 30 July 2013 - 05:09 PM
You should indent your code properly (you tried in first part, but failed in second. ALWAYS do it. it makes your and others life much easier when reasing the code). also the linebreaks inbetween each line are really annoying. And last of all you should choose a more specific title. 'How do i do this' is too general as it fits to pritty much all questions in this section
Th3RadMan #5
Posted 30 July 2013 - 05:15 PM
ok, i fixed a few things, added a bit more and yet i got another problem… plusfunshinex was a lot more helpful :D/>

my current problem is in the loop at the bottom, where it says "if false then", it should break the block behind, but its not doing that, also anything so far you would change at all?


function select()
local x = turtle.getFuelLevel()
  if x < 50 then
  turtle.select(16)
  turtle.refuel(1)

  turtle.select(1)
end
  local z = turtle.getItemCount(1)
  if z == 0 then
  turtle.select(2)
    end
end

term.clear()
term.setCursorPos(1,1)

print("Enter Height:")
  local h = read()
  term.clear()
  term.setCursorPos(1,1)

print("Enter Length:")
  local l = read()
  term.clear()
  term.setCursorPos(1,1)

print("Enter Width:")
  local w = read()
  term.clear()
  term.setCursorPos(1,1)
	  
turtle.select(1)
turtle.turnLeft()

for w = 1, w do
select() 
turtle.placeUp()
turtle.back()
  if false then
    turtle.turnLeft(2)
    turtle.detect()
	  if true then
	  turtle.dig()
		 turtle.turnRight(2)
    end
  end

turtle.place()
end
Th3RadMan #6
Posted 30 July 2013 - 05:17 PM
You should indent your code properly (you tried in first part, but failed in second. ALWAYS do it. it makes your and others life much easier when reasing the code). also the linebreaks inbetween each line are really annoying. And last of all you should choose a more specific title. 'How do i do this' is too general as it fits to pritty much all questions in this section

im starting to, i tried to fix it but at the end its a little messed and I'm fixing right now… then again its the second program I've ever written :blink:/>