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

building program

Started by Dark_Eav, 03 February 2014 - 08:15 AM
Dark_Eav #1
Posted 03 February 2014 - 09:15 AM
Hi guys,

I want to program a tool to build easy structures in minecraft since i wanna build a tower with repeating floors.

I started to set up some functions and and wanted to test them by just using one of them at the end of the program but it doesnt work.

I want the turtle to build with 2 materials f.e. stone and glass.
Stone is in slots 1-8 and glass in slots 9-12.
Slot 13, 15 and 16 each got a enderchest in it, filled with fuel, stone and glass.

Here is my program:


function refuel()
  turtle.select(13)
  turtle.placeUp()
  turtle.suckUp()
  turtle.refuel()
  turtle.digUp()
end
function refill(x)
  if x == 1 then
	turtle.select(15)
	turtle.placeUp()
	for i = 1,8 do
	  turtle.select(i)
	  while turtle.getItemCount(i) == 0 do
		turtle.suckUp()
	  end
	end
	turtle.select(15)
	turtle.digUp()
  else do
	turtle.select(16)
	turtle.placeUp()
	for i = 9,12 do
	  turtle.select(i)
	  while turtle.getItemCount(i) == 0 do
		turtle.suckUp()
	  end
	end
	turtle.select(16)
	turtle.digUp()
  end
end

function place()
  turtle.placeDown()
  turtle.forward()
end

place()
end

if i run the programm nothing happens. No error no placing of stone (i got slot 1 selected and its allready filled with stone).
I dont know why this is not working can you tell me my mistake?
My plans for improvements are to addd some return values to test if the functions worked and to edit the function place with a variable to use it multiple times in a row and seperately for stone and glass.
Also feel free to suggest improvements to my code or any helpfull tips.
surferpup #2
Posted 03 February 2014 - 10:13 AM
You are placing down – is there anything beneath the turtle? Which slot did you select for the turtle to draw from for the place function?

Is your turtle already fueled up and ready to go? It won't go without fuel.

I think you are doing a good job organizing your code. You may want to make your variables and functions local.
Bomb Bloke #3
Posted 03 February 2014 - 10:17 AM
  else do

That extra "do" you've put there isn't needed. Remove it (so's the line simply reads "else"), then remove the "end" from the very bottom of your script, and try it again.