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

http.request questions

Started by asto63, 02 July 2015 - 02:25 PM
asto63 #1
Posted 02 July 2015 - 04:25 PM
Hello, i want to know something, i'm making a account system from my website, and i want to take each line from a HTTP.request to know informations about player.
Example: Line 1 we have the money of player
Line 2 we have number of purchases… And i have to put each line in differents variables.

And more, my account config is like that:

Money: $$
Purchases: **

How make than "Money:" & "Purchases" dissapear, and just keep the numbers after (Or Strings)

Thanks for help.
Creator #2
Posted 02 July 2015 - 05:55 PM
Do something of the likes of
Whatever = line:sub(line:find(":")+1,-1)

Sorry for the formating but I am on mobile.
asto63 #3
Posted 02 July 2015 - 06:39 PM
Can you explain about this line? Because i don't undenstand everything…
MKlegoman357 #4
Posted 02 July 2015 - 06:48 PM
You can read each line of a response separately by using readLine() function of the returned response handle. Then, you might use a pattern like this:


local name, value = line:match("%w+: .+")
asto63 #5
Posted 02 July 2015 - 07:08 PM
Then, if i understand it will rend something like that:


values = readLine(1)
local name, value = 1:values("%w+: +")
But this last line, "line:match("%w+: ,+")". I don't understand everything…
Edited on 03 July 2015 - 07:12 AM