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

Lua Learning Stuffs

Started by applesauce10189, 05 February 2014 - 07:04 PM
applesauce10189 #1
Posted 05 February 2014 - 08:04 PM
What are some good ways to learn lua and the API's? I want to be good with lua like Bomb Bloke and just about everyone else who comments on my ask a pro threads.
theoriginalbit #2
Posted 05 February 2014 - 08:12 PM
Practise, practise, practise.

Have a read of this, there's some good suggestions.

EDIT: Oh I should also mention that getting other peoples code and reading it — in an attempt to understand it — definitely helps too; especially if you play around with it too, see what happens when you change things.
Edited on 05 February 2014 - 10:27 PM
Kashin #3
Posted 05 February 2014 - 08:18 PM
If by API's you're refering to CC, then just have a look at the wiki, and some of the uploaded programs people have made.

Set some goals for what you want to be able to do, try and try again, then read some similar code and see if you can figure out the problem ;)/>
surferpup #4
Posted 05 February 2014 - 11:15 PM
I wrote a Lua Basics Tutorial that will familiarize you with Lua Basics -- Variable Scope, Code Blocks and Control Structures. It will teach you the minimum required to get programming in Lua as far as the language is concerned.
applesauce10189 #5
Posted 06 February 2014 - 12:16 AM
If by API's you're refering to CC, then just have a look at the wiki, and some of the uploaded programs people have made.

Set some goals for what you want to be able to do, try and try again, then read some similar code and see if you can figure out the problem ;)/>
Okay then. New goal, make a button program that'll control my house on a server.
Kashin #6
Posted 06 February 2014 - 04:49 PM
Sounds great :)/> Good luck with that, let us know how it works out for you.
applesauce10189 #7
Posted 07 February 2014 - 02:31 AM
I'd say its going well so far,



local m = peripheral.wrap("top")
m.setBackgroundColor(colors.black)
m.clear()
m.setCursorPos(1,1)
m.setBackgroundColor(colors.lime)
m.write("             ")
m.setCursorPos(1,2)
m.write("             ")
m.setCursorPos(1,3)
m.write("             ")
local event, side, xPos, yPos = os.pullEvent("monitor_touch")
m.setCursorPos(1,4)
m.write("X: "..xPos.." Y: "..yPos)
if xPos <= 13 and yPos <= 3 then
  m.write("IT WORKED! IT WORKED!")
end
oeed #8
Posted 07 February 2014 - 03:35 AM
Practise, practise, practise.

Have a read of this, there's some good suggestions.

EDIT: Oh I should also mention that getting other peoples code and reading it — in an attempt to understand it — definitely helps too; especially if you play around with it too, see what happens when you change things.

If you're going to look at other peoples code make sure you don't just look at. As theoriginalbit said, playing around with it is far better than reading. It's like my teachers always say about revision for exams, "Reading the textbook is useless, doing questions isn't" (or something along those lines, you know what I mean)
applesauce10189 #9
Posted 07 February 2014 - 06:25 AM
Practise, practise, practise.

Have a read of this, there's some good suggestions.

EDIT: Oh I should also mention that getting other peoples code and reading it — in an attempt to understand it — definitely helps too; especially if you play around with it too, see what happens when you change things.

If you're going to look at other peoples code make sure you don't just look at. As theoriginalbit said, playing around with it is far better than reading. It's like my teachers always say about revision for exams, "Reading the textbook is useless, doing questions isn't" (or something along those lines, you know what I mean)
I don't think I'm ready to make a button program, I looked at direwolf20's button api and was lost around arrays. I get the just but it just confuses the living heck outta me.
surferpup #10
Posted 09 February 2014 - 12:41 AM
I don't think I'm ready to make a button program, I looked at direwolf20's button api and was lost around arrays. I get the just but it just confuses the living heck outta me.

Parts I and II of the The Complete Monitor Buttons and Control Tutorial are now posted. If you work through those two parts, you will definitely get how to deal with monitors and create and draw buttons.

Parts III and IV are coming, and they will deal with events and putting everything together.

If you are interested in just a program to tear apart, please look at the Door Control Program contained in the 7th response to this post – you should have no problem working through it.
awsmazinggenius #11
Posted 10 February 2014 - 11:36 AM
"Arrays"? I'm 99 percent sure he means tables, as they are quite similar in other languages (at least in some that I have seen). Do you know those?