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

Logger Program

Started by Anonomit, 20 November 2012 - 03:14 PM
Anonomit #1
Posted 20 November 2012 - 04:14 PM
Hi, here's a tree farming program that's been in the works for awhile, and I finally decided to finish.

There are quite a few customizable options, such as:
  • mode (farm or bonemeal)
  • length and width of farm
  • options for delaying next cycle until logs are emptied, saplings are refilled, or both. This allows for other mods, like buildcraft, to automatically empty the logs.
  • ability to output a redstone signal (from fully customizable sides) upon completion, until ready for next cycle. Useful for powering pumps, or letting you know when the turtle has completed a cycle.
  • fuel can be turned off, simply by toggling a variable at the start of the code. This way the program won't throw an error if turtle fuel consumption is turned off.
  • Rednet compatibility comes in the form of two other programs, allowing you to start and monitor multiple loggers simultaneously, with ease.
This program was made and tested using ComputerCraft 1.47, and has not been tested on other versions. If you are not using version 1.47, there may be some bugs.

This program is a start-over-from-scratch update of this somewhat buggy, messy, 1.3-compatible version, found here: http://bit.ly/NhYPsp
That program is an updated verion of the original program, found here: http://bit.ly/NYbb3u
A video of the original program in action can be found here: http://bit.ly/NWJ84b *Note that the program has been drastically altered since this video was made, although the initial idea remains the same.

To go with this program are two others, which take advantage of the rednet capabilities.

Broadcast:

The broadcast program is meant to be run at startup on a dedicated computer with a modem. If enabled, it manages the turtles, monitors their states, and stores them for use in the Log program. This program will have debug mode on by default, so you can see what messages are being received and sent by the turtles. To turn it off, either run the program with the argument noDebug or change the value of the variable bDebugDefault to false. This variable can be found at the top of the code.

Broadcast can be found here: http://pastebin.com/q1h8UGyf

Log:

This program will start all nearby loggers that have connected to the broadcast console. Since all variables are handled by the broadcast console, it's possible to run this program from any computer with a modem and start your loggers, or retrieve information about them, such as how many are running out of saplings, and how many already have. If you have already set, but want to change the broadcast console that this program will communicate with, run the program with the argument recreate. If you only want to start certain loggers, I suggest connecting them to a different broadcast console. This way you could have multiple farms nearby, that would't interfere with each other, or a group of turtles who are set to bonemeal mode instead of farm mode, but still with rednet support.

Log can be found here: http://pastebin.com/mWeDt5NT

Logger:

The main program, it will work without the above two, but each turtle will need to be started manually, rather than by rednet. If your turtles don't consume fuel, change the value of the variable bUseFuel to false. If you are not considering using the Broadcast and Log programs, change the value of the bNoBroadcast variable to true. These variables can be found at the top of the code.

Logger can be found here: http://pastebin.com/QkW1kYqX


Please post if you find any bugs or have any suggestions, comments or questions.
That said, I hope you enjoy the programs!
Tiin57 #2
Posted 20 November 2012 - 04:16 PM
Well done. Most Lua code I see is poorly or shoddily done. This is neither. /me stamps with approval.
:(/>/>
Anonomit #3
Posted 20 November 2012 - 04:28 PM
Well done. Most Lua code I see is poorly or shoddily done. This is neither. /me stamps with approval.
:(/>/>
Thank you, although I think if you look closely you'll see a lot of unnecessary code. I modified some functions I've used in other programs, so there's still a lot of extra lines :(/>/>
UrbanRedneck #4
Posted 23 November 2012 - 09:45 AM
Nice Program works great in FTB going over to ask a pro how to stop it when done.
Anonomit #5
Posted 23 November 2012 - 11:56 AM
How to stop it? If you're using the farm mode, just wait until it's finished its cycle, and it'll stop automatically. If you're in a rush, just terminate it or shut it down. That'll screw with the broadcast console if you're using it though, mind you. If you're using the bonemeal mode, follow the on-screen instructions and press any key to stop it.
AdiCCted #6
Posted 01 December 2012 - 10:12 AM
Great program! I like all the options, and how easy it is to use i through rednet. I have 8 turtles running it around my house, and I can start them all at once from my master computer. So awesome to look out the window and see them all simultaneously start chopping down trees! Thanks!
Poodmund #7
Posted 05 January 2013 - 10:59 AM
Has something in the API changed to cause the "Log" program to fail? I can run the Logger program manually on the Turtle fine but when trying to initiate it via a networked computer I get the message, "Logger:688: attempt to index ? (a nil value)"?
Hawkertech #8
Posted 05 January 2013 - 11:27 AM
will this work with the larger redwood trees? 4 sapplins in one tree.
Poodmund #9
Posted 05 January 2013 - 11:29 AM
No it doesn't, I'd try searching the forums for another tree felling program specifically for 4 sapling trees.
mauijim #10
Posted 18 January 2013 - 09:44 AM
Would there be a way to make this to where it automatically runs when using farm mode, instead of having to start it manually? I have four farms set up and want it to run on its own, im using all three proframs.
Yusunoha #11
Posted 22 January 2013 - 05:20 AM
I've ran into a problem with the logger program
I am using the fir sapplings of ExtraBiomes XL and I set the turtle to bonemeal mode.
all is going fine till at a certain point the turtle stops chopping wood and goes down, without finishing chopping down the whole tree.
this cause the turtle to keep spamming sapplings and bonemeal when it gets down till the bonemeal runs out, because the sapplings can't grow because the top part of the last tree hasn't been chopped down yet.
redwolv #12
Posted 28 January 2013 - 08:36 AM
OK I am running version 1.481, I have found a bug in which randomly at times the turtle will chop the first block of the tree they procede right no through the tree for the whole cycle. this is really bad cause then every tree has to be manually removed before the turtle will be able to plant saplings and chop trees again.
Minithra #13
Posted 08 February 2013 - 01:22 AM
Hello. I am trying to get this directly from pastebin, and I get the :92: error. pastebin:92: attempting to index ? (a nil value)

The command I'm trying to use is: pastebin get QkW1kYqX logger.


Halp! I have no chance of ever typing all of the code in :D/> Connecting to pastebin goes well, then this :/
MinecraftFarms12 #14
Posted 23 February 2013 - 08:55 PM
Hey There is an error where My Computer need all Modems on The sides when i put broadcast and log on, cause this sucks man and really i want to run my turtles wirelessly. Also when the turtle says "use broadcast console" I put yes and it says no modem on top; what does that mean.
oh by the way I'm using CC version 1.5 Minecraft version 1.4.7 so yeah.
also there is an error on log that when i put the broadcast console id it says conflict between log and broadcast so wat does that mean.
Thanks MinecraftFarms12 :D/>
BikerEleven #15
Posted 07 March 2013 - 08:17 AM
Nice work you have done there, much better than my original mess of a program. I still wonder why I never used mod % instead of a toggle bool.
Shadow_Assailant #16
Posted 07 March 2013 - 03:48 PM
Disregard this post.
MinecraftFarms12 #17
Posted 11 March 2013 - 09:46 PM
Anonomit's Program Edited A Little Bit

Logger: http://pastebin.com/6B3mVJGG

Log: http://pastebin.com/GMDCVGSz

Broadcast: http://pastebin.com/5Sn0r95E

All Credit Goes To Anonomit :D/> B)/>
oxgon #18
Posted 24 March 2013 - 08:18 AM
I don't know if this is still being worked with but I can't get it to work with bonemeal.
jake5253 #19
Posted 15 April 2013 - 10:51 AM
This is a great program! I really appreciate all the work that went into it, but it really bothers me there is no "exit" in Logger. I needed to refuel and couldn't figure out a way to refuel it manually without breaking the turtle and re-placing it; so, here is an edit with only 4 extra lines. I placed them where it lists "press r to begin, s to recreate, c to clear etc..":


                print( "Press 'x' to exit" )
			    if event == "char" and param1 == "x" then --exit on x keystroke
			    shell.run("clear")
			    return

http://pastebin.com/LZzgNEmx
RustyDagger #20
Posted 04 June 2014 - 03:45 PM
This would be great if it didnt insist on having a modem on every Gdam side of it????? WTF Its just none on XX side terminate… until you cover the whole thing dont you think thats a little excessive and makes it hard to use?
McDugen #21
Posted 11 June 2014 - 11:05 AM
Hay Great Logger. Best one I have found yet. I was wondering though could you make it suck up the saplings from around the tree when it makes its logging run? the first run will be sapling free but the runs following it should try to pick them up or eventually you will run out of saplings or maybe make it dump logs and grab sapplings from a chest
Edited on 11 June 2014 - 08:45 PM
MineFarms #22
Posted 14 June 2014 - 10:02 PM
Hey RustyDagger check out my other post MinecraftFarms12. I have made it so you don't have to have a modem on every side. :)/>