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

I can't get my Blaze Rods farm to work

Started by Bichmoute, 01 April 2013 - 01:15 PM
Bichmoute #1
Posted 01 April 2013 - 03:15 PM
Hello, I'm new to this forum please excuse my poor english I'm French and doing what I can to be understood! And please excuse too the typing mystakes I'll probably make,gyping on a Vita isnt ideal.

Anyway, I'm posting here because I'm completely useless at programming these damn turtles. I'm trying to build an automatic blaze rod farm : a crafty turtle crafts blaze rods with 2 blaze powder and a minium stone, then drops it in a pipe system where half of the blaze rods produce energy in generators and the other half goes back in a macerator to do the blaze powder that is then crafted aigain etc…

My system is entirely functionnal except for the turtle that I cant manage to program correctly. Actually the only thing I managed to do is this :

While true do
turtle.craft()
turtle.drop()
end

Ofcourse this isnt working at all because in order to craft blaze rods, the turtle needs to have 2 slots occupied by blaze powder and 1 by the minium stone and my blaze powders arriving in he turtle all go in the same slot and are almost immediatly ejected because of the drop command.

Could somebody make me or help me to do something functionnal ?

Thanks in advance and I hoped I respected all the rules :)/>
Sora Firestorm #2
Posted 01 April 2013 - 03:22 PM
First off, make sure you have a sleep() or something in that loop,
otherwise you'll cause it to crash via 'too long without yielding'.

Second, have you tried through turtle.getItemCount() and whatnot that you have
everything you need in its proper place before you craft?
Bichmoute #3
Posted 01 April 2013 - 03:35 PM
Nope, as I sad my knowledge does not extend further than the programI've written. Thanks for the few ideas, I'll check this out tomorrow (It's 3.30 Am for me, starting to get way too tired for programming now ^^ )
Sora Firestorm #4
Posted 01 April 2013 - 04:04 PM
Oh, I just realized…

So, let's say your Minium stone is in slot 1, and you blaze powder is
in slot 2. if you use something like


-- a couple vars to keep track of slots
-- simply for organization

local miniumSlot = 1;
local powderSlot = 2;
local rodSlot = 4;

-- put this in your crafting loop
if turtle.getItemCount(powderSlot) > 1 then
  turtle.select(powderSlot);
  turtle.transferTo(powderSlot + 1, turtle.getItemCount(powderSlot) / 2);
  -- Crafting results go into the slot you have selected, so make sure rodSlot is selected.
  turtle.select(rodSlot);
  turtle.craft();
end


The big thing in this if statement is the turtle.transferTo() function.
It takes two arguments, the slot to put the items in (In our case, the slot after powderSlot), and how many items to move (Again, in our case,
it's half of the contents of powderSlot)

If you don't understand anything, don't hesitate to ask about it!
Good luck!

~Sora
Bichmoute #5
Posted 02 April 2013 - 09:57 AM
Thank you very much for your answer, after a little while looking at your program, I finally exactly understood how it works, but it still won't craft the blaze rods. Here is the program I've put in my turtle :


local miniumSlot = 1;
local powderSlot = 2;
local rodSlot = 4;
while true do
if turtle.getItemCount(powderSlot) > 1 then
turtle.select(powderSlot);
turtle.transferTo(powderSlot + 1, turtle.getItemCount(powderSlot) / 2);
turtle.select(rodSlot);
turtle.craft();
turtle.drop()
end

I get an error in line 7 if I remember well. If you need more informations,, i'll give them to you tomorrow, I won't be able to check minecraft tonight but if you see already what's wrong with the program it would be great :)/>
Sora Firestorm #6
Posted 02 April 2013 - 10:38 AM
At the end of your if stament (after 'end'), put a line like this in -


-- To prevent crashes from not yielding
sleep(0.5);

Ofcourse, you can change 0.5 to a different delay, but 0.5 should be fine.

And the error you're getting, it's because you haven't ended you while loop. Go ahead and tack on another 'end'.