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

computercraft: kinda crappy?

Started by AuoroP, 16 May 2014 - 03:59 PM
AuoroP #1
Posted 16 May 2014 - 05:59 PM
So I'm making my first post ~40 hours after trying to sign up and I'm drowsy from lunch and somewhat despondent from the weight of all of the limitations I believe computer craft has; sorry if this post seems bare bones. I wanted to check that all these limitations are real:

(no simple state saves) computers and turtles can reboot anywhere in your code if you walk away.

computers and turtles (and all user code) can be lost forever.

(No specilication) No turtles cannot detect what kind of tool they have.

(No UI) turtles (and computers) cannot use term for their consoles.
Bubba #2
Posted 16 May 2014 - 06:33 PM
(no simple state saves) computers and turtles can reboot anywhere in your code if you walk away.

Yes, computers/turtles will shutdown when the chunk unloads. However, this can be handled by saving your progress and then continuing when the chunk reloads.


computers and turtles (and all user code) can be lost forever.

Sure, if you don't label the computer/turtle. You can label a turtle either by using the label program or the os.setComputerLabel(label) function.

(No specilication) No turtles cannot detect what kind of tool they have.
Why would you need to? As it is, a pickaxe performs at the exact same speed as every other tool and can mine every block.

(No UI) turtles (and computers) cannot use term for their consoles.
No, this is wrong. Basic computers/turtles don't have colors, but you can use the term API just fine.
Edited on 16 May 2014 - 04:35 PM
AuoroP #3
Posted 16 May 2014 - 07:58 PM
(no simple state saves) computers and turtles can reboot anywhere in your code if you walk away.

Yes, computers/turtles will shutdown when the chunk unloads. However, this can be handled by saving your progress and then continuing when the chunk reloads.

Thank you for answering. I'll address your other posts in other posts because the answer to this is not obvious to me so I hope you can explain what I'm missing

The last time I played was Minecraft 1.4.7 (FTB). I remember I was working with turtles that would keep (and save) the state required for dead reckoning. My tree farmer would work fine right up until I walked away. Sometimes, when I came back its state would be wrong and it would be wandering away.

What I think is a fundamental problem is that the turtle can reboot anywhere in your code. This means that it can reboot after you've actually moved but before you've saved that state. So my dead reckoning turtle had bad beliefs about where it was in the world after it had rebooted.
apemanzilla #4
Posted 16 May 2014 - 08:12 PM
No UI? Have you seen any of the projects here? The UI is surprisingly well developed - term.setTextColor, term.setBackgroundColor, term.setCursorPos, and term.write are all you really need to create a powerful UI.

Turtles were made to be "blind" for a reason. Can you imagine how overpowered it could be if they could see blocks, items, etc? Certain peripherals attached can be "read" for a type with the peripheral API (just not tools) but since in theory they are electrically (or redstone) powered, you could think of it as the equivalent to a bit of ROM that identifies computer hardware in real life with many things.
AuoroP #5
Posted 16 May 2014 - 08:18 PM
computers and turtles (and all user code) can be lost forever.

Sure, if you don't label the computer/turtle. You can label a turtle either by using the label program or the os.setComputerLabel(label) function.

I use an external text editor, the various computer subdirectories only get created when I've set a label and used filespace. Looking at the folders in my 1.4.7 FTB computer directory, I can give an exhaustive list of the folders:

5, 10, 11, 13, 14, 15, 16, 17, 18, 19, 21

From 0 to 20, everyone of the folders that isn't there was lost by ComputerCraft.

You can also find another similar tale from early this year:
www.computercraft.info/forums2/index.php?/topic/16721-recovering-crashed-turtles/

Thankfully the loss of my first piece of code is long ago enough that I can cooly recall a feeling of overwhelming distress without using a single allcaps word.

(No UI) turtles (and computers) cannot use term for their consoles.
No, this is wrong. Basic computers/turtles don't have colors, but you can use the term API just fine.

Yay! I tried term.clear() in a turtle prompt and it worked. So I went back and looked at my code and I was using term.setCursor instead of term.setCursorPos. That is a huge relief! Thanks!

(No specilication) No turtles cannot detect what kind of tool they have.
Why would you need to? As it is, a pickaxe performs at the exact same speed as every other tool and can mine every block.

I am currently working on a project that defines a broad class of turtle that all share the same fudnamental behaviours. Then implementation of each task the turtle will be undertaking will vary depending on its role.

To get get slightly more specific, all my turtles will interact with a chest in the same way. One of specific tasks I have in mind uses a melee turtle who can assume he will swing at everything. I also plan to have a farming turtle that assumes it will try to break and plant crops but it would be silly for it to also try to swing at everything.

If turtles could report the type of tool they have attached then seperating these behaviours could have been done automatically. I've given up on that and am writing an install script that would have been disk/startup becaus it wouldn't need interaction. Now I need to make it disk/install and take the type of turtle as an argument.

No UI? Have you seen any of the projects here? The UI is surprisingly well developed - term.setTextColor, term.setBackgroundColor, term.setCursorPos, and term.write are all you really need to create a powerful UI.

I am aware of what is possible with term because I wrote a UI using it. I wrongly, thought it required a seperate monitor to use term because the second line of my UI was using term.setCursor instead of term.setCursorPoc.
Lyqyd #6
Posted 16 May 2014 - 10:29 PM
Folders are created for computers when files are added to them, regardless of whether they are labelled or not. Files are not lost, barring highly unusual circumstances.
Bubba #7
Posted 16 May 2014 - 10:42 PM
(no simple state saves) computers and turtles can reboot anywhere in your code if you walk away.

Yes, computers/turtles will shutdown when the chunk unloads. However, this can be handled by saving your progress and then continuing when the chunk reloads.

Thank you for answering. I'll address your other posts in other posts because the answer to this is not obvious to me so I hope you can explain what I'm missing

The last time I played was Minecraft 1.4.7 (FTB). I remember I was working with turtles that would keep (and save) the state required for dead reckoning. My tree farmer would work fine right up until I walked away. Sometimes, when I came back its state would be wrong and it would be wandering away.

What I think is a fundamental problem is that the turtle can reboot anywhere in your code. This means that it can reboot after you've actually moved but before you've saved that state. So my dead reckoning turtle had bad beliefs about where it was in the world after it had rebooted.

Yep, this can be difficult to deal with. However, the solution to this is to use a GPS system so that your turtle doesn't have to guess where it is. Of course, if you're using a turtle mining system there's a good possibility that the turtle will exit the range of the GPS, at which point you would either need to use chunkloaders or an automated repeater system with the turtles.
Edited on 16 May 2014 - 08:44 PM
AuoroP #8
Posted 16 May 2014 - 11:24 PM
Folders are created for computers when files are added to them, regardless of whether they are labelled or not. Files are not lost, barring highly unusual circumstances.

I just rembered where I suspected many of those turtle folders went. They were mostly tree farmers until they weren't. Tree farmers likely got grown over and I suspected that caused their entire folder (along with files) to vanish. From my perspective, I've lost about as many folders as I still have so I hope you can indulge my curiosity while I ask you to look through an old save file in which you've lost a turtle and check to make sure there aren't any holes?
AuoroP #9
Posted 17 May 2014 - 12:53 AM
(no simple state saves) computers and turtles can reboot anywhere in your code if you walk away.

Yes, computers/turtles will shutdown when the chunk unloads. However, this can be handled by saving your progress and then continuing when the chunk reloads.

What I think is a fundamental problem is that the turtle can reboot anywhere in your code. This means that it can reboot after you've actually moved but before you've saved that state. So my dead reckoning turtle had bad beliefs about where it was in the world after it had rebooted.

Yep, this can be difficult to deal with. However, the solution to this is to use a GPS system so that your turtle doesn't have to guess where it is. Of course, if you're using a turtle mining system there's a good possibility that the turtle will exit the range of the GPS, at which point you would either need to use chunkloaders or an automated repeater system with the turtles.

However difficult it is to deal with, it is even harder to figure it that it is happening when you are learning a new language (lua) and a new platform (computercraft). What should be light fun becomes a soul crushing hunt for an error in your understanding of either. You have to be sure everything you're doing in your code is correct and then notice it only happens when you walk away, and with a technical understanding of how minecraft works, you can start to question what happens to turtles when you walk away and then figure out turtles reboot when you walk away. I am obviously of the opinion this is the crappiest (although most understandable) shortcomings; sorry needed to vent a little.

Aside from that, I feel like I need to point out how ironic it is that dead reckoning (which should be utterly simple for turltes in Minecraft who always move exactly one meter every time they move, with exactly NO accumulating positional errors) need GPS.

If I remember correctly, you cannot simply get your direction from GPS so only most of the state dead reckoning requires is otherwise recoverable. Also, I'm not seeing it as a general solution for any other state a turtle may require to remain consistent. I'm also concerned about how this affects group movements, but I cannot offhand find any compelling examples.
Lyqyd #10
Posted 17 May 2014 - 12:58 AM
There are folders that don't exist, but only because they were never created. I never put any files on those computers and didn't leave them placed long, so there are IDs that aren't in use. ComputerCraft will not, under any circumstances that I'm aware of, including the complete destruction of a computer/turtle, ever delete those folders.
Bubba #11
Posted 17 May 2014 - 01:26 AM
However difficult it is to deal with, it is even harder to figure it that it is happening when you are learning a new language (lua) and a new platform (computercraft). What should be light fun becomes a soul crushing hunt for an error in your understanding of either. You have to be sure everything you're doing in your code is correct and then notice it only happens when you walk away, and with a technical understanding of how minecraft works, you can start to question what happens to turtles when you walk away and then figure out turtles reboot when you walk away. I am obviously of the opinion this is the crappiest (although most understandable) shortcomings; sorry needed to vent a little.

Aside from that, I feel like I need to point out how ironic it is that dead reckoning (which should be utterly simple for turltes in Minecraft who always move exactly one meter every time they move, with exactly NO accumulating positional errors) need GPS.

If I remember correctly, you cannot simply get your direction from GPS so only most of the state dead reckoning requires is otherwise recoverable. Also, I'm not seeing it as a general solution for any other state a turtle may require to remain consistent. I'm also concerned about how this affects group movements, but I cannot offhand find any compelling examples.

I can understand your frustration. A lot of time does have to be invested in order to get the results that you want, and sometimes it just might not be possible. However, that is the trade-off you have to make: time for versatility. I personally enjoy ComputerCraft because it offers me a mental challenge in Minecraft, where everything else is simply a matter of long hours mining or similar tasks - but that's me. Not a lot of people enjoy coding enough to invest so much time.

As to the actual reasoning behind why computers work the way they do in regard to chunks, you have to understand how Minecraft works. Apologies if you are already "in the know", but here's the gist of it:

All computers and turtles utilize something we call a tile entity. Tile entities function like blocks, with the exception that they can, a) have more than 16 possible states or stored data, and B)/>/> they are updated every game tick. However, this extra functionality comes at a trade-off: tile entities are considerably more expensive in terms of memory and processing. Examples of tile entities are chests, pistons, signs, and of course computers.

Now by default, tile entities behave the same as any other Minecraft block - when you walk out of the chunk, everything is unloaded in order to preserve memory. However, it would be possible to make computers function as chunkloaders, which ensures that they are always loaded into memory. Of course, if computers behaved this way, you could start encountering severe lag if you have too many computers over a large area (there's a reason there are very few chunkloading blocks). So, dan200 made the decision to let users chunk load areas themselves using other mods. If all computers behaved as chunkloaders, users would be forced to either use them quite sparingly or condense them into a small area.

There are probably a few solutions that would allow computers to run autonomously from their loaded chunks, but then Dan may consider that to either be too much work to worth it or too overpowered.

Either way, I can sympathize with you but hopefully knowing why computers work the way they do will be a small consolation :)/>/>

Now, on to fixing the behavior you mentioned in your last paragraph.
you cannot simply get your direction from GPS
True, you can't get the direction from GPS directly. However, you can get it simply by moving forwards and back and checking the difference.

Also, I'm not seeing it as a general solution for any other state a turtle may require to remain consistent

I'm assuming that you refer to saving things other than movement here. Unfortunately, you're right in that you won't always be able to conclude your programs before the chunk unloads, and this could lead to some issues. The solution really is just to make your program quite versatile. There are some creative solutions for checking the surrounding area to get the state. And if you can't think of any such solutions, you could always use chunkloaders.

I also have one final thing:

If you're really unsatisfied with the way computers behave, you can always go the route of making a peripheral. This would require you to invest a good bit of time in learning how to mod, but as a whole it's not incredibly difficult and it's a very good thing to learn how to do. If you want any help doing something like this, let me know and I could point you towards some resources and help you get started.
Edited on 16 May 2014 - 11:39 PM