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

Computercraft bug - or am I just missing the obvious?

Started by gronkdamage, 02 April 2013 - 03:47 PM
gronkdamage #1
Posted 02 April 2013 - 05:47 PM
for z = 2,16 do
turtle.select(z)
if turtle.compareTo(1) == false then
turtle.drop()
end
end

Why on earth would that drop anything from slot 1?
Kingdaro #2
Posted 02 April 2013 - 07:05 PM
…It wouldn't?
theoriginalbit #3
Posted 02 April 2013 - 07:14 PM
Is there more to your script than this? It could be happening somewhere else…
gronkdamage #4
Posted 02 April 2013 - 07:57 PM
There is more code - but it's blocked fine. And it worked fine in 1.4.7; like it should have. That's what's weird; it started this behavior (not working) with 1.52.


Here's the full program - it's still being worked on; and sorry it's not blocked properly - but ….

Spoilerlocal loops = 2

– functions
local function tryDown()
while not turtle.down() do
if turtle.detectDown() then
turtle.digDown()
else
turtle.attackDown()
sleep( 0.75 )
end
end
end

local function tryUp()
while not turtle.up() do
if turtle.detectUp() then
turtle.digUp()
else
turtle.attackUp()
sleep( 0.5 )
end
end
end

local function tryForward()
while not turtle.forward() do
if turtle.detect() then
turtle.dig()
else
turtle.attack()
sleep( 0.5 )
end
end
end

–start getting oak
turtle.select(1)
for i = 1,loops do

– get sapling and plant…
turtle.turnLeft()
turtle.suck()
turtle.turnRight()
turtle.place()

– put the rest back
turtle.turnLeft()
turtle.drop()
turtle.turnRight()

– get bone
turtle.turnRight()
turtle.suck()
turtle.turnLeft()
for zz = 1,20 do
turtle.place()
sleep(0.5)
end

– put the rest back
turtle.turnRight()
turtle.drop()
turtle.turnLeft()

– cutdown tree
tryForward()
for y = 1,7 do
tryUp()
for x = 1,2 do
tryForward()
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.dig()
turtle.turnRight()
turtle.dig()
turtle.turnRight()
tryForward()
end
end

for z = 2,16 do
turtle.select(z)
if turtle.compareTo(1) == false then
turtle.drop()
end
end

for y = 1,7 do
tryDown()
end
turtle.back()

– put wood in box
turtle.turnLeft()
turtle.turnLeft()
for y = 1,16 do
turtle.select(y)
turtle.drop()
end
turtle.select(1)
turtle.turnLeft()
turtle.turnLeft()
print ("Pausing for 45 seconds…")
print ("Working on loop # ",i," of ",loops,".")
sleep(45)
end
gronkdamage #5
Posted 02 April 2013 - 08:05 PM
Try putting that code by itself in a turtle; it's gotta be a computercraft bug. I'll go report it. It's acting REALLY strangely. (It looks like drop might now drop everything? Not just the slot?)
theoriginalbit #6
Posted 02 April 2013 - 08:08 PM
its your code right here


--start getting oak
turtle.select(1)
for i = 1,loops do
  -- get sapling and plant...
  turtle.turnLeft()
  turtle.suck()
  turtle.turnRight()
  turtle.place()

  -- put the rest back
  turtle.turnLeft()
  turtle.drop()
that drops the first slot…
gronkdamage #7
Posted 02 April 2013 - 08:18 PM
Read the rest of the program :)/> - that part is correct :)/> - it is supposed to pick up from the box to the left; plants trees, puts the rest back. Goes to the box to the right; picks up bonemeal - places it on the tree; then puts it back… (ie. it's putting a sapling down and fertalizing it…)

The bug is at the top of the tree, after it's cut the wood - it's supposed to look at the first slot (which will be wood) then drop anything that isn't matching what's in slot 1; that's the problem - it's dropping everything (including slot 1)…

Try putting the first piece of code in a turtle (the lines I have above) - and put something in slot 1, slot 10 that match; then something in slot 16 (put 20 things) - and make it drop(1) - watch what happens… It bugs out.
gronkdamage #8
Posted 02 April 2013 - 08:23 PM
Actually don't even bother with a program - load 1 item in each slot; then go to lua

type in this:

turtle.select(1)
turtle.drop()
turtle.drop()

watch what happens… It starts dropping stuff from slot 2, then 3, then 4 - even tho slot 1 is still selected.
theoriginalbit #9
Posted 02 April 2013 - 08:23 PM
oops there it is…

line 98 — 101



for y = 1,16 do
  turtle.select(y)
  turtle.drop()
end
theoriginalbit #10
Posted 02 April 2013 - 08:25 PM
Actually don't even bother with a program - load 1 item in each slot; then go to lua

type in this:

turtle.select(1)
turtle.drop()
turtle.drop()

watch what happens… It starts dropping stuff from slot 2, then 3, then 4 - even tho slot 1 is still selected.
doesn't do that for me… rename startups, reboot your turtle and try it right away.
gronkdamage #11
Posted 03 April 2013 - 11:56 AM
So using default configuration; removed all mods but CC and Forge 611 - it's still doing it :(/>

What version of forge do you use?
PixelToast #12
Posted 03 April 2013 - 03:58 PM
the absolute latest
gronkdamage #13
Posted 03 April 2013 - 05:28 PM
Strange - I tried it with the latest (and CC only); and with the recomended. Everytime, it would drop from slots that weren't selected… :/ I'll report it as a bug; but we did a fresh install - and it still does it (both on my server - and in single player)…
gronkdamage #14
Posted 03 April 2013 - 08:02 PM
Just an update; when I fill every slot - the code works exactly as it should. When 1 slot is empty; it bugs out.
PonyKuu #15
Posted 04 April 2013 - 04:41 AM
You can make a workaround. If it drops things from other slots only if you try to drop something from an empty slot, do this:


for i = 2,16 do
  if turtle.getItemCount(i) > 0 then
	turtle.select(i)
	if not turtle.compareTo(1) then
	  turtle.drop()
	end
  end
end

Edit: And it will run a bit faster, since turtle.select requires about a tick to be done, when turtle.getItemCount performed almost instantly
Edited on 04 April 2013 - 02:48 AM
gronkdamage #16
Posted 04 April 2013 - 10:54 AM
Thanks PonyKuu - Cloudy confirmed the bug; but I'll give this a try :)/>