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

Two Questions - Timer And Pulling Stuff From Chests...

Started by gronkdamage, 09 September 2013 - 04:56 PM
gronkdamage #1
Posted 09 September 2013 - 06:56 PM
I've got this major mining program (I'm currently on version 5 of it) and at this point, it seriously takes 3 hours (give or take) to run. What I do is mine a tunnel, and replace all blocks (that I can) from levels 4-17 - 120 blocks long (so we don't leave the range of the chunk loader…)

Question #1 (which I already know the answer to; but gonna ask anyway): Any way of pulling just cobble out of a box? I do have cobble in inventory slots 1-4, but this mining program can potentially completely fill a double-box.

Answering my own question: If I select slot 1, and then suck from the box - it'll only pull the cobble won't it… Duh, I'm an idiot. I guess it does help to write stuff out sometimes. :)/>

EDIT: Actually that didn't work; it just pulled the first 4 slots into slot 5-8 :/ So that question is back on the table.

Ok, so back on track:

Question #2: I see os.time and so forth; but is there a way of pulling the real time (ie. not minecraft time) so I can see how long this program runs? And what about getting it in a hh:mm:ss format?

ie. I want to start the program, and when it's done see:

Start: 12:30:05
Finish: 4:25:20
Time elapsed: 3:55:15 - (my brain hurts, but I think I did that in my head right..) :)/>


Thanks!
Lyqyd #2
Posted 09 September 2013 - 08:06 PM
You may be able to put at least one cobblestone block in each of the turtle's slots and then attempting the turtle.suck(), but that may simply fail if the first slot in the chest isn't cobblestone.

You cannot retrieve a real-world time without using http.
gronkdamage #3
Posted 09 September 2013 - 09:12 PM
You may be able to put at least one cobblestone block in each of the turtle's slots and then attempting the turtle.suck(), but that may simply fail if the first slot in the chest isn't cobblestone.
I considered this, and was going to test it - but I suspect it'll just fail (or fall to the floor as you say). I'll let you know :)/>

You cannot retrieve a real-world time without using http.
Hmmm, haven't done any http stuff - so not sure what the API will be like; but I'll take a look. I may just say screw it on that part. :)/>

Thanks!
campicus #4
Posted 09 September 2013 - 09:20 PM
Perhaps I don't understand your problem properly… but couldn't you just have a designated 'cobble ender chest'? Have cobble being fed into it on one end? Or a cobble barrel (from factorization)?
gronkdamage #5
Posted 09 September 2013 - 11:16 PM
Two big reasons campicus:

A - too much of a pain to move barrels around - and more importantly:
B - the chests are used to store ore that's been dug up.

See the problem is when the turtles encounter a lot of lava or a chasm. They end up using all the cobble to build the tunnels.

Maybe this will help better:

The turtle digs down 1 block (unless it's on obsidian) and places blocks to the left and right; it then goes up 16 blocks doing the same all the way up; then it goes forward - and does the same thing down. As it fills up, it returns to the start, moves ore around (to try and keep 4 stacks of cobble) and empties the rest into a chest. it then returns to it's last position, and continues on until it's done this 120 blocks forward. It then turns around, and drops torches every 8 blocks on the way back to the start.

10 turtles, running every 3rd block digs up everything in a 120 x 30 x 20 block; and you end up with these little 1 wide, 16 tall, 120 long tunnels - all perfectly lit. The next program unloads the turtle, and moves 120 blocks forward, sits down, and waits to get kicked off again. No lava, perfectly safe, only thing left is cobble. :)/>/>

It's perfect with chunkloaders, cuz you can go run off and do other stuff while they mine.
campicus #6
Posted 10 September 2013 - 12:01 AM
The way I would tackle it is:

1) Have an enderchest that is always full of cobble
2) When you run out of cobble (first 4 slots are empty, etc.) then you place that chest up, suck down your cobble, break the chest and continue on.

If you don't like that (honestly, I think that is the easiest solution) then perhaps:

1) Have 4 slots that always keep 1 cobble in them, just so when you fill up cobble you know those 4 slots will have cobble.

2) You can work out what slots have cobble (when the turtle is full) by having the turtle place a block and compare it to slot 1. If the turtle returns false for the place or compare functions, then that slot isn't cobble and you put it in your "other items" chest. If it is cobble, you can store it in your "cobble" chest.

Does this make sense or am I still not understanding your problem lol :P/>
immibis #7
Posted 10 September 2013 - 04:36 AM
You can use os.clock if the computer is not going to shut down or reboot while you're timing.
It returns a counter of real-world seconds since the computer started.

Edit: Note it's adjusted for the server's tickrate. If your server is running at half of normal speed, so will the counter. So it measures in-game time, but in real seconds.
gronkdamage #8
Posted 10 September 2013 - 06:20 AM
1) Have 4 slots that always keep 1 cobble in them, just so when you fill up cobble you know those 4 slots will have cobble.
2) You can work out what slots have cobble (when the turtle is full) by having the turtle place a block and compare it to slot 1. If the turtle returns false for the place or compare functions, then that slot isn't cobble and you put it in your "other items" chest. If it is cobble, you can store it in your "cobble" chest.
Well, great minds think alike :)/>/> This is actually something I already do :)/>/> My code for placing blocks will always leave 1 block in a slot - so when it unloads, it starts with slot 5 - checks if it's cobble (comparing to slot 1), if it is - it moves it to slot 1; then it continues all the way to slot 15. It then repeats that for slots 2-4. Finally, it dumps everything in slot 5-15 into the box and moves on…

I think for now I'm going to leave it as it is.

And thanks Immibis :)/>/> - I saw a block of code under os.clock in the wiki; i'm going to incorporate that in. :)/>/>


EDIT: I helped someone in the forum; and linked my program - so just in case anyone is curious: here's the mining program in question (we use metallurgy 3; which puts diamonds from 0-16. We use this program at 5 (at bedrock): http://pastebin.com/UHbwRh33