It looks like you're new here. If you want to get involved, click one of these buttons!
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.
Comments
@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
@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
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?
@Stevon8ter Whoa, now we are getting really pushy!
Better get that tutorial finished fast, Stevon8er is getting cranky!
Hahaha
Well I don't need it anyways
well not soon... I already got my patterns set up thanks to @SkyTheCoder's post-tutorial on my textbox thing 
But I wanna learn them one day, just not now
Here is my try: It probably has a lot of improvement room.
Lua Patterns
Hello! Many of you probably think Lua patterns are like rocket since, but in Lua. This is quite the opposite.
The only confusing part is rememberimg all the characters and string functions.
We will start off with a basic example. The string.find() function. You give it somthing to look for in a
string, like "car" in racecar, and it will return the starting and ending position of the car like so:
But what if you don't really know what to look for in "racecar?" Then you will need the character "." which basically
fills in any symbol or letter in its position. Lets test it out:
Here is another useful objects to learn:
"%u" == Matches a letter in uppercase
"%d" == Matches a number
"%D" == Matches all letters, but not digits.
But even with those we are still held back. What if we don't know what we are looking for?
Thats where the more advanced ones come in:
"+" == Matches the last character as many times as possible.
"*" == Matches the last character as many times as possible.
"?" -- Makes the last character optional
"-" == Matches the last character as few times as possible.
One other thing you should know about these. They do not count as a string. You have to
put them inside of '' instead. So it will be like:
string.sub() -- Gets rid of parts in a string by giving it a starting and ending point.
string.gsub() -- Gets rid of a certian pattern.
string.match() -- Returns a certain pattern.
While there are more, these are the most important.
:-*
You almost got it... I went to sleep and came back to this. I'll make a tutorial...
Update: Opening Pages on my Mac...
Update: Lot of stuff to cover...
Update: Getting there...
Update: I keep on realizing more things to add...
It's ok, we're just teasing you, no rush..take your time and make it good
@Ignatz I know. :P Almost done, I have to go now though, but when I come back I'll add some extra helpful links and proofread it.
Currently tallies up to 1,764 words and 5 pages.
Don't leave! Come on we need this so much! I told you no programmer could get his head around it, you're mean
xD