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

New programmer looking for input on code and suggestions improvement.

Started by MattFightsBears, 27 December 2012 - 03:24 PM
MattFightsBears #1
Posted 27 December 2012 - 04:24 PM
I'm fairly new to programming. I just started messing around with the turtles and looked at a couple lua tutorials then wrote this. I used pretty much 100% of my coding knowledge in this program. So if it's not there, assume I don't know what it is.
The point of this post is I want to learn more about this programming language, but don't know where to go from here. So if you have any suggestions please throw them my way.

The program checks how wide a tree in front of the turtle is then cuts it down and replants.

I thought about adding functions to get more coal or saplings and putting wood block into a chest as well as a function to bone meal the tree.

I didn't add the refilling functions because I'm not happy with requiring a user to put a chest in a specific location. Untimely I would like to set up a gps array and pathing finding program so I could set waypoints of the appropriate chest so the turtle can go to them where ever they are to refill itself then find it's way back to the tree. I've seen things that lead me to believe that's possible. I think I could figure out a path finding program if I worked at it long enough, but I don't know how to call programs from inside other programs or how to store the waypoints I would need for the chest locations.

I will probably add the bonemeal function later on, but I was writing this code in survival and don't have a good bone supply as of now.
Jack #2
Posted 27 December 2012 - 05:47 PM
It's fairly standard for a program to require a user to place chests in particular locations, actually. As long as you have strong code to handle locations, there shouldn't be too many navigational difficulties.

This looks quite good for a first turtle program; it's clear that you've programmed before. Perhaps the speed could be optimized a bit, but that's a minor issue. I am curious, though… Only jungle trees are more than 1x1, right? Why did you provide such extensive support for them?

Well, that's about all I can think of. Look at mine?
ChunLing #3
Posted 27 December 2012 - 10:54 PM
Yeah, just place the chest at a given place in the treefarm. If you're not happy making/trusting the user do it exactly right, then write a program that sets up the treefarm for them.
MattFightsBears #4
Posted 28 December 2012 - 06:04 AM
It's fairly standard for a program to require a user to place chests in particular locations, actually. As long as you have strong code to handle locations, there shouldn't be too many navigational difficulties.

This looks quite good for a first turtle program; it's clear that you've programmed before. Perhaps the speed could be optimized a bit, but that's a minor issue. I am curious, though… Only jungle trees are more than 1x1, right? Why did you provide such extensive support for them?

Well, that's about all I can think of. Look at mine?

I wrote it in the ftb mod pack which has 3(that I can think of) trees that are 2x2.
MattFightsBears #5
Posted 28 December 2012 - 06:07 AM
Yeah, just place the chest at a given place in the treefarm. If you're not happy making/trusting the user do it exactly right, then write a program that sets up the treefarm for them.

Alright.