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

[Turtle][Question] Inventory Wierdness

Started by DarkEspeon, 21 January 2013 - 09:43 AM
DarkEspeon #1
Posted 21 January 2013 - 10:43 AM
I am working on a farming turtle, but something weird happens when it picks up seeds, and there is only one seed, or none in the first slot, the new seeds go to the 4th(the 2nd being bone meal, and 3rd being wheat)

can someone please help me understand what it is doing, and how to fix it? thanks so much!

EDIT: It's only seeds from fully grown wheat, not just planted seeds, or in one of the other stages of wheat growth
SuicidalSTDz #2
Posted 21 January 2013 - 11:49 AM
Please post the code so we can help you :)/>
DarkEspeon #3
Posted 21 January 2013 - 11:52 AM
i don't have any code yet, just manually entering digDown, placeDown, and select(1) or select(2), working on the code later to automate it, just wondering if there is a reason why the seeds aren't stacking even though the first slot only has 1 or 2 seeds,
SuicidalSTDz #4
Posted 21 January 2013 - 11:58 AM
i don't have any code yet, just manually entering digDown, placeDown, and select(1) or select(2), working on the code later to automate it, just wondering if there is a reason why the seeds aren't stacking even though the first slot only has 1 or 2 seeds,
Are you doing turtle.select(slot#)?

Edit: I would suggest making a program then debugging
theoriginalbit #5
Posted 21 January 2013 - 11:58 AM
Try selecting slot 4 and using turtle.transferTo(1) and see if it can actually combine the 2 stacks. If that doesn't work see if YOU can combine the stacks. If you can't then it's not CC it's mc.
SuicidalSTDz #6
Posted 21 January 2013 - 12:01 PM
Try selecting slot 4 and using turtle.transferTo(1) and see if it can actually combine the 2 stacks. If that doesn't work see if YOU can combine the stacks. If you can't then it's not CC it's mc.
My farming program has no problem with stacking so.. Most likely the manual typing of the code
DarkEspeon #7
Posted 21 January 2013 - 12:02 PM
@suicidal: yes
@theoriginalbit: its CC, cause transferTo works, and i can combine the stacks. Does this mean after every harvest I will have to add turtle.select(4) turtle.transferTo(1)?

also, using feed the beast mindcrack, maybe it is a mod conflict that causes the seeds to not stack or something like that
theoriginalbit #8
Posted 21 January 2013 - 12:03 PM
@suicidal: yes
@theoriginalbit: its CC, cause transferTo works, and i can combine the stacks. Does this mean after every harvest I will have to add turtle.select(4) turtle.transferTo(1)?
Well I'll check to see if I can replicate the issue when I get back to my computer… If I can't then yeh you'll have to use transferTo… If I can replicate then post this in bugs with a detailed explanation for Cloudy to replicate.
DarkEspeon #9
Posted 21 January 2013 - 12:04 PM
@theoriginalbit: ok, thanks, how long will it be till you get back to your computer, if you don't mind me asking?
theoriginalbit #10
Posted 21 January 2013 - 12:08 PM
@theoriginalbit: ok, thanks, how long will it be till you get back to your computer, if you don't mind me asking?
About 10mins…
DarkEspeon #11
Posted 21 January 2013 - 12:32 PM
ok, and also would this work, until i find out if the seed thing is just a bug with me or a bug with cc, for a farm that is 4x15, where it goes up the 15 first, then turns and does another 15, and another, and the 4th, then goes to a chest, and drops all the stuff off(except the seeds and bonemeal)?



local rows = 15
local columns = 4
local y = 1
local x = 1
function transferSeeds()
  if turtle.getItemSpace(1) > 0 then
    for i = 3, 16 do
      if turtle.compareTo(1) then
        turtle.transferTo(1, turtle.getItemSpace(1))
      end
    end
  end
end
function farm()
  turtle.digDown()
  turtle.select(1)
  turtle.placeDown()
  turtle.select(2)
  turtle.placeDown()
  turtle.select(1)
  turtle.digDown()
  transferSeeds()
end
while true do
  if y < columns then
    if x < rows then
      farm()
    end
  end
  if x == rows then
    x = 0
    if y == 1 then
      y = y + 1
      turtle.turnRight()
      turtle.forward()
      turtle.turnRight()
    end
    if y == 2 then
      y = y + 1
      turtle.turnLeft()
      turtle.forward()
      turtle.turnLeft()
    end
    if y == 3 then
      y = y + 1
      turtle.turnRight()
      turtle.forward()
      turtle.turnRight()
    end
    if y == 4 then
      y = 1
      turtle.turnRight()
      turtle.forward()
      turtle.forward()
      turtle.forward()
      turtle.forward()
      turtle.turnRight()
      turtle.back()
      transferSeeds()
      for s = 3, 16 do
        turtle.select(s)
        turtle.dropDown()
      end
      turtle.forward()
    end
  end
end
theoriginalbit #12
Posted 21 January 2013 - 12:41 PM
I'm running CC1.481… I could kind of replicate the issue… if the bonemeal slot was selected when digging the wheat it would put the seeds at the end. however if the seed slot was selected when digging the wheat the seed would go into the slot… I think its just the way CC deals with block breaking. it starts where its selected and then goes forward from there…
DarkEspeon #13
Posted 21 January 2013 - 01:01 PM
ok… well, i just tested the code above, and it kindof worked… lost of bugs, first of which i was an idiot, and used if y == 1, incrimented y, then if y == 2, not thinking about what i was doing, so it got to the last row of the field and kinda went herp a derps flerp… think i got that ironed out though…. lmfao the whole time it went derp though


ok everything worked… until it finished the third row, then it restarted itself…. odd
theoriginalbit #14
Posted 21 January 2013 - 01:03 PM
ok… well, i just tested the code above, and it kindof worked… lost of bugs, first of which i was an idiot, and used if y == 1, incrimented y, then if y == 2, not thinking about what i was doing, so it got to the last row of the field and kinda went herp a derps flerp… think i got that ironed out though…. lmfao the whole time it went derp though
Oh oops sorry didn't even see that code post…
DarkEspeon #15
Posted 21 January 2013 - 01:07 PM
its ok, but it pauses oddly ever 2-5 blocks, and like i said in the edit above, it stopped and the whole turtle restarted after the third row

edit: tried it again, and it stopped right after it turned after the third row… weird

edit2: code might help… fail

local rows = 15
local columns = 4
local y = 1
local x = 1
turtle.select(16)
turtle.refuel(64)
turtle.select(1)
function transferSeeds()
  if turtle.getItemSpace(1) > 0 then
    for i = 3, 16 do
      if turtle.compareTo(1) then
        turtle.transferTo(1, turtle.getItemSpace(1))
      end
    end
  end
end
function farm()
  turtle.digDown()
  turtle.select(1)
  turtle.placeDown()
  turtle.select(2)
  turtle.placeDown()
  turtle.select(1)
  turtle.digDown()
  transferSeeds()
end
while true do
  if y < columns then
    if x < rows then
      farm()
      turtle.forward()
      x = x+1
    end
  end
  if x == rows then
    if y == 1 then
      x = 1
      y = y + 1
      turtle.turnRight()
      turtle.forward()
      turtle.turnRight()
    elseif y == 2 then
      x = 1
      y = y + 1
      turtle.turnLeft()
      turtle.forward()
      turtle.turnLeft()
    elseif y == 3 then
      x = 1
      y = y + 1
      turtle.turnRight()
      turtle.forward()
      turtle.turnRight()
    elseif y == 4 then
      y = 1
      x = 1
      turtle.turnRight()
      turtle.forward()
      turtle.forward()
      turtle.forward()
      turtle.turnRight()
      turtle.back()
      transferSeeds()
      for s = 3, 16 do
        turtle.select(s)
        turtle.dropDown()
      end
      turtle.forward()
    end
  end
end
theoriginalbit #16
Posted 21 January 2013 - 01:41 PM
ok firstly turtle.refuel(64) is exactly the same as saying turtle.refuel()

for your main movement loop I might be inclined to do something more like this ( note this is typed here, so it may have some syntax or logical errors, damn small space to type *shakes fist* )
it will require some additions for your code, but hopefully you get the point :)/>

local function forward()

  if not turtle.forward() then
    if turtle.getFuelLevel() == 0 then
      -- out of fuel
    elseif turtle.detect() then
      -- *wild block appears*
    else
      turtle.attack() -- incase of mobs
    end
  end
end

for c = 1, columns - 1 do
  for r = 1, rows do
    forward()

    -- below here may need to be reversed depending on the way you want it to move
    if c % 2 == 0 then
      turtle.turnLeft()
      forward()
      turtle.turnRight()
    else
      turtle.turnRight()
      forward()
      turtle.turnRight()
    end
  end
end
DarkEspeon #17
Posted 21 January 2013 - 01:50 PM
can you help me figure out why it reboots after the third row is done please? its so weird… it just randomly reboots before it can plant or break any wheat
theoriginalbit #18
Posted 21 January 2013 - 01:52 PM
yeh i couldn't see a reason why, thats why I wrote the move logic to try and if it still happens then we know its not because of the movement loop…
ChunLing #19
Posted 21 January 2013 - 01:57 PM
Select slot one before digging the wheat, and the seeds will go into the first slot.
DarkEspeon #20
Posted 21 January 2013 - 02:32 PM
well, using the code you gave me, the original bit, it went forward one block, then immediately turned…