Make a tutorial!

Hi, recently I’ve seen some new people join, and some people quit because they got frustrated. So I decided to make this thread. The rules are simple, know what you are talking about, and make if its a hard to learn subject, add the requirements.

Here is mine:
Requirements: Basic Lua Pattern knowledge (Highly suggested)

Hello everybody, today we will be learning about the http.request. In a nutshell, you can access a websites source code, and pick out the parts you want to display. There are other things you can do with it, like sending data to it. But since I don’t have a website to test it out on, we won’t be covering that.
The first thing you will need to know is how to link a url to it. Most of you now a days don’t use http://www.websiteName.com anymore, since google and other search engines have made it easier. But Codea still needs it. so inside of the http.request type this:

http.request("http://www.example.com")

Thats not all we need to add though. If thats it, then where would it put all the informtion? For this we have to make two functions for it, the fail function if it can’t reach the website, and the success function if it did reach it. You can name them whatever you like.
You should now have this:

http.request("http://www.example.com", success, fail)

Now we add the functions.

function fail(error)

end

and

function success(data,status,header)

end

We added the callbacks inside of the functions that way the http.request knows where to send things. In this tutorial we will just be covering the data and error one, though.

If you add a

print(data)

Inside of the success function now, you will see quite a few lines of code. Don’t let this scare you off, though. A lot of it Codea Doesn’t need!

While most of you have seen the reference inside of Codea explaining this, it isn’t always that easy. Most of the time you will have to find the information you need. So if I went to http://www.merriam-webster.com/dictionary/dog and tried catching information about it, like the orgin. I would have to manually find the part of the code that talks about it, and sub.string() and string.match() until I just get that part of the information.

@Prynok, Looks very good, if u need any help, don’t be afraid to ask

I’m a little confused, Lua patterns aren’t HTTP requests.

(I can make a tutorial on Lua patterns though)

I think a tutorial on patterns is a really good idea

(but don’t leave it in the forum where it will get lost, put it on the wiki as well)

I have a good knowledge of them… Just not too sure where to start.

@SkyTheCoder What I was saying is that you will need to know how to use Lua patterns to find the parts of the website you want.

@SkyTheCoder - if you want to write a tutorial, start at the beginning, put yourself in the mind of the beginner, and go from there. It doesn’t matter if it isn’t perfect. We don’t have anything at the moment! I am happy to read it over first, if you like.

But don’t do it if you don’t want to…no obligation.

@Prynok, I think you got the order of fail and success functions mixed up… Could really make a beginners life hard if it succeeds but nothing happens and they know they followed the tutorial right.

@JatAttak I feel so embarrassed, you are correct. Fixing it now.

@Prynok, no need to be embarrassed. It’s the little things like that that get us all :slight_smile:

@Prynok Tip: use http://www.example.com

websitename.com is a domain owned by someone else, just not hosted at the moment. example.com is designed to be used, without contacting the owners, in documents and stuff as an example website.

Sorry, I hadn’t realized it said it required Lua string matching, I thought it meant the tutorial was on Lua string matching.

@SkyTheCoder if you write a tuto on patterns i’ll be glad to use it! Make it as a codea project with many simple examples so we can copy paste from the code what we need. That would be great, cause many time i tell myself: ‘i could do that with patterns. Mmmm… Gee, that’s so complicated, i’ll do that later’. And i dont.

Yes, we’d like the tutorial by tomorrow please, so we can finish our homework :))

Bump. Nothing published yet? ~X(

I AM WAITING! Hurry up!

It’s been an hour already!

You mean 2 by now! Gimme that code! I need to go to do my nap so gimme that code!

Ugh! I guess no scripter knows how to do it! Its been like a day now!

Edit: If someone really wants a example/tutorial on Lua patterns, I think I’m eligible to make one :wink:

Omg probably even the president doesn’t know how to use patterbs, then why the heck did that dumb ass of a lua programmer even include such a ******* useless feature? :o