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

[Turtle] Skipping Some Code...

Started by H4X0RZ, 17 September 2013 - 09:54 AM
H4X0RZ #1
Posted 17 September 2013 - 11:54 AM
Hello com,
this program doesn't work because it doesn't check the disk slot… why isn't it workingg?
theoriginalbit #2
Posted 17 September 2013 - 12:06 PM
Can you please give a description of what it is meant to do? i.e. what task is this code performing?
H4X0RZ #3
Posted 17 September 2013 - 12:11 PM
Can you please give a description of what it is meant to do? i.e. what task is this code performing?
Maybe you've seen this cobblestone contest.
this program is an early version of my submission and the task of this "snippet" is to just find out were the disk is and where the diskdrive is. But it skips the loop where it should try to find out the disk slot.
theoriginalbit #4
Posted 17 September 2013 - 12:18 PM
And is the disk drive in the Turtle, or the world already?
H4X0RZ #5
Posted 17 September 2013 - 12:42 PM
And is the disk drive in the Turtle, or the world already?
The the turtle sucks the disk drive out of a chest (the disk is in the chest to. it sucks anything out of it). goes one block up and tries to place the items it has sucken (is that the right form?). If it found a block to place it saves this slot as his "diskdrive" slot. the it places the block out of the "diskdrive" slot and tries to drop every item into the diskdrive. if it has found an item which can be dropped into the disk drive and it is a disk it will save the slot where it founds the disk als the "disk" slot. is that enough information?
theoriginalbit #6
Posted 17 September 2013 - 01:00 PM
and tries to place the items it has sucken (is that the right form?)
Sucked. :)/>

Ok so now that I know what exactly you're trying to do, I can make some suggestions that are better for you.

Firstly, since any block can be in the chest, and any block can be placed in the world, I suggest that once the block is placed you perform peripheral.getType("front") == "drive" to validate if it is a drive, if not, break it and try again

Secondly, as an added extra you could also call do and not disk.hasAudio("front") on line 20 to make sure that it isn't a music disk which would also return true to the `isPresent` call.

Thirdly, I'm not too sure why you're doing your loops 1-4, can you elaborate some more why you picked 4? Why do you assume that the drive and disk will be in the first 4 slots?

Fourth, your code to find the drive is flawed because it doesn't break the block once placed if it is not the disk drive

Lastly, as for your actual problem, I can only speculate that it is because in the second for loop you're not selecting the slot meaning you're just dropping from the previously selected one (the disk drive one). Oh also lines 15 and 16 are redundant, the drive is already placed down.
H4X0RZ #7
Posted 17 September 2013 - 04:23 PM
Thx bit :)/>
i will try it out tomorrow after school (btw, I hate tomorror because I have school from 8:00 AM to 4:00 PM… -.-)