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

Where do I start?

Started by speed150mph, 27 January 2014 - 10:09 PM
speed150mph #1
Posted 27 January 2014 - 11:09 PM
So I am not a big time computer programmer. In fact computers confuse me. I am a mechanic and I am very good and visualizing and understanding how mechanical devices work. But to me, how a jumble of wires, diodes, switches and a couple fans in a box can understand what I am telling it to do is nothing short of black voodoo magic.

But anyways, not long after I discovered minecraft, I got Into tekkit. I was mostly into building nuclear reactors and the like, but when I saw computercraft I was suddenly sucked into the world of coding.

But now that my life story is out there my question is simple. All the codes I've learned are from YouTube videos and google searches and me copying them down without understanding what it is I was really writing. I would love to learn more about this, so that maybe one day with some luck, I can be that guy who wrote his own program showing others what to do.

What would be the best way for me to learn coding in computercraft without going to programming collage? How did you all learn?

Thank you for your input, all mighty magical computer sorcerers :)/>
CometWolf #2
Posted 28 January 2014 - 02:23 AM
The best way to learn, in my opinion, is to just start your own project. Figure out something you want to make, and make it! Whenever you need help do some googling. Personally i started out with a turtle API for coordinate based movement. Eventually that expanded into a shape builder, and for that i needed inventory management. This just went on and on, and now i can do pretty much whatever i want in cc without much documentation of any kind.
theoriginalbit #3
Posted 28 January 2014 - 02:28 AM
Someone else has asked this before, there's a big(ish) discussion, have a read;

As CometWolf said Google is your friend; if you have problems getting relevant Google results I suggest having a read of this.
Edited on 28 January 2014 - 01:31 AM
surferpup #4
Posted 28 January 2014 - 10:09 AM
Specifically:
  • Ask-a-Pro Tutorials in Ask-a-Pro Project Renewal (open the spoiler for a list). These are all pretty good tutorials.
  • Check out my Lua Basics tutorial to get familiar with the language structure.
  • Try my Redtone Basics tutorial.
  • Use good coding practices from the start (indenting, descriptively-named variables, judicious use of comments).
  • Start programming, copy simple projects and take them apart to see how they work. Make them better.
  • Keep the ComputerCraft Wiki open while you code so you can check out the various API functions. There are great tutorials in there as well.
  • Post well-formed questions on this forum showing the exact code you are working on (see Read this Post Before Asking Questions. It is incredible how far people in this forum will go to help you, as long as they know you are willing to put in the effort to show you are trying to help yourself. Some of the coders on this forum are amazing coders.
  • Read through the Ask-a-Pro forum and look at questions that have been answered on topics that may interest you. You will get to know pretty quickly the difference between a good answer and a so-so answer, and you will also see how to make better questions for your own issues. In the process, you will learn from a lot of people's mistakes and gain some great ideas.
Most importantly, have fun. Welcome to the world of ComputerCraft.
Edited on 28 January 2014 - 11:15 AM
Yevano #5
Posted 28 January 2014 - 11:28 AM
I'm surprised nobody mentioned PIL. It's a bit technical, but it's a solid reference for Lua.
TechMasterGeneral #6
Posted 28 January 2014 - 11:40 AM
I tend to learn by picking apart the programs people posted or the programs built into the mod… the computercraft wiki and google has always been my best friend when i needed help… and if you still get stuck… that is what the ask a pro section is for..
theoriginalbit #7
Posted 28 January 2014 - 07:24 PM
I'm surprised nobody mentioned PIL. It's a bit technical, but it's a solid reference for Lua.
I did
Someone else has asked this before, there's a big(ish) discussion, have a read;
ingie #8
Posted 28 January 2014 - 08:05 PM
What would be the best way for me to learn coding in computercraft without going to programming collage? How did you all learn?

I'm going to answer by taking the word "computercraft" out of that tuple question. [ but i'll re-insert it later once i've made the point :)/> ]

I've never learnt to code at any college or university… only education in it i got was at high school when i was 14-17. But it was good education, taught from the bottom up, from binary arithmetic and half-adders and karnaugh maps - so one was taught how to reduce something down to logic.
This was back in the 80s, home computers were only just becoming really popular, I'd been given a Sinclair ZX81 at christmas when I was 13.
… but I learnt to code before that, by reading Popular Computing magazine and similar, they'd have BASIC listings in them to type in… but I didn't have a computer, my mum had brought home the magazines for my elder brother but he wasn't that interested… but I found them fascinating, so I read the descriptions next to the listings, and read the code… and tried to work out what it all must mean.
I still have a pencil written note of one of my first programs - all that it did was animate a block pixel "sprite" of a space-invader type thing, over two frames - using PRINT AT x,y; "#" type commands in a loop… and when I finally got a computer I just played with it, all the time i had spare.
Experimenting with things, seeing if I could break something, and reading more and more of other people's code.

ok Mr Blah Blah, you say… how does this help? well, what I mean is

1. play and experiment - often with no goal other than the experimentation itself… I still do that a lot today - I might right a piece of code just to see if it makes sense, and then go "ok" and never use it, but I'm certain to have learnt something along the way.

2. write pseudo code before you open the terminal - you'll need to do this less and less as you get more proficient, but initially it's good to write down the concept of something as a script just in english [ or your preferred own human language :)/> ]

3. draw pictures… block diagrams, flowcharts - turn your pseudo-code english into more modular stages

this then leads to

4. modularisation + abstraction of code - this is the crux of becoming a coder rather than a "script-kiddie" so to speak, where because of your preparation in organising your concepts into modular blocks, you can then start to see how you can re-use rather than re-type…


those steps are, i'd say, in order of "how deep you are happy to go" - but whatever level you are at - don't be afraid to just type something, and see if it works! - print debugging is your friend if you're not sure whether what you're doing is right… and can help explain the internals if reading other people's pastebinned code… i.e. if you've downloaded some routine someone has written, open it up and add some print(somevariable) lines into it at points where you're not sure what it's doing… even now i often do that and go "oh, i see… that's why it wasn't working" - and it'll be something so obvious once you've printed out one of the intermediate results that you absolutely totally knew was going to be something else :)/>


… i was going to come back to ComputerCraft wasn't i … yeah, the big bonus with computercraft is that you can do all that, but with much more tangible feedback - i really wish i'd had computercraft when i was learning to code back then, it's just such a joy to write something which makes pistons move and lights turn on [ virtual as they are ].
Edited on 28 January 2014 - 07:07 PM
Buho #9
Posted 29 January 2014 - 07:29 AM
I'd go with CometWolf, though simpler.

One easy program to start with is to write a program that will help you walk underground. A 1x2 tunneler. Place turtle in front of you underground and tell it to dig forward for N blocks. It digs forward, digs up, moves forward, and repeats N times (looping). Throw a conditional in there for when fuel gets low and you're golden. It's a super-useful program to have on-hand when you're caving. It'll get you thinking about what else you can do!