Jump to content




How do I do this?


  • You cannot reply to this topic
5 replies to this topic

#1 Th3RadMan

  • Members
  • 28 posts

Posted 29 July 2013 - 10: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, 30 July 2013 - 09:38 AM.
added code tags


#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 30 July 2013 - 09:45 AM

Split into new topic, and added [code][/code] tags

#3 jesusthekiller

  • Banned
  • 562 posts
  • LocationWrocław, Poland

Posted 30 July 2013 - 10: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&v=1qj-KWxeLog

FunshineX (unlike DW20) teaches pretty well :)

#4 Kilobyte

  • Members
  • 122 posts

Posted 30 July 2013 - 04: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

#5 Th3RadMan

  • Members
  • 28 posts

Posted 30 July 2013 - 04: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


#6 Th3RadMan

  • Members
  • 28 posts

Posted 30 July 2013 - 04:17 PM

View PostKilobyte, on 30 July 2013 - 04:09 PM, said:

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:





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users