1 | local http = game:GetService( 'HttpService' ) |
2 |
3 | local data = http:GetAsync( 'http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=156' ) |
That data gets all assets worn by builderman, but I need to find a way to get that data into a table, possibly through methods of string manipulation, but I'm not entirely sure how to do this.
You could treat them as semicolon separated strings.
In that case, :gmatch
is a good bet:
1 | local list = { } ; |
2 | for url in data:gmatch( "[^;]+" ) do |
3 | -- Explanation of pattern: |
4 | -- ; -- Semicolons |
5 | -- [;] -- A "character class" consisting of only semicolons |
6 | -- [^;] -- a class of all NOT semicolons |
7 | -- [^;]+ -- one or more contiguous not-semicolons |
8 | table.insert(list, url); |
9 | end |
The only way I can think of how to do this is with a little bit of string manipulation. If you look the string GetAsync is returning, you'll notice that each asset is separated by a semi-colon [ ; ]. Using this, we can use some loops to find out how many assets there are (the last one does not have a semi-colon, so we'll need to add one) and then extract the asset ids from the string.
01 | local http = game:GetService( 'HttpService' ) |
02 |
03 | local data = http:GetAsync( 'http://www.roproxy.tk/Asset/AvatarAccoutrements.ashx?userId=156' ) |
04 |
05 | function createTable() |
06 | local array = { } |
07 | local assetSeparators = { } |
08 |
09 | -- Find number of assets |
10 | for value in string.gmatch(data, ";" ) do |
11 | table.insert(assetSeparators, value) |
12 | end |
13 |
14 | -- Extract assets |
15 | local lastEnd = 1 |