Hello,
I’m writing a automatic clothing script for my plugin.
(Like Roblox’s Avatar Shop, But Text Version.)
function listCatalog(typeId,maxSearch) --I will use typeId variable later.
local search = 0
local id = 1
while wait() do
if search > maxSearch then
break
end
local ok,item = pcall(function()
return market:GetProductInfo(id,Enum.InfoType.Asset)
end)
print(item.AssetId)
if item and ok then
search = search + 1
print(id)
end
id = id + 1
end
end
But,this search takes long time. I want my script faster.
I saw a solution from here:
But I don’t want use another web service. There is a way to make script faster?
(I think Http Service will solve my problem, but I need some tips for this.)
1 Like
I’m pretty sure you need another site. You can learn more about HTTPService here: link
Ok. I used JavaScript Host Servce called glitch.
There is my script now:
function listCatalog(dressId,maxSearch)
local search = 0
local id = 1
local appName = "roblox-http-service"
local baseUrl = "https://"..appName..".glitch.me/catalog/json"
local out = http:JSONDecode(http:GetAsync(baseUrl))
print(out)
print("------------------------------------")
print(unpack(out))
end
And my result: (output may be messy )
table: 0xb3c975f9899a6e27
------------------------------------
table: 0x8d5cdc735398500f table: 0xa88fc2d7248bc6d7 table: 0x4fa2489d1e8eccff
table: 0x2ecad3235081be87 table: 0x5272922c31fb1d1f table: 0x495fb8467bb69167
table: 0x87f88d0af4927597 table: 0x66c7b4f74a974dbf table: 0x54259e7d0093d9c7
table: 0xd300f80ad79ee9ef table: 0x1dd944da63a571df table: 0x20eafd2c286f01a7
table: 0xdfb751b60ea3958f table: 0xdd502838c4e6e557 table: 0x9b3e1c87b0797907
table: 0xdae90b5ae5b7452f table: 0xc1c403d12bebd2b7 table: 0x178232e2885192e7
table: 0x115aec4dc2d504cf table: 0x309970bd53793717 table: 0x4bfd3110565be83f
table: 0x6212d8c9e046da47 table: 0x8d574ea4abcd546f table: 0xe875b40375c14377
table: 0x4e88dfa93e46bf5f table: 0x28cda91bb2fe970f table: 0x0320956c6c391bd7
table: 0x49698a7813ce3b87 table: 0xf6ef7b548456d037 table: 0xb991a3dbd25d5e1f
table: 0x64b2b38128d85467 table: 0xc3764a396626264f table: 0x3d2c398cfa2f0ebf
table: 0x3ea1e5400e2416ef table: 0xfd9b3eeed47ea2f7 table: 0xa0681075e23bfcdf
table: 0x7b350ff298f4caa7 table: 0xba12076f5632488f table: 0xf0ef1f010c105a57 table:
0x343de95aca16ac7f table: 0x696b21cf701bf207 table: 0x02865a31ba18802f
But, I want to seperate this tables to unpack it and get data. How can I do?
Edit: I rewrited this script like this:
function listCatalog(dressId,maxSearch)
local search = 0
local id = 1
local appName = "roblox-http-service"
local baseUrl = "https://"..appName..".glitch.me/catalog/json"
local out = http:JSONDecode(http:GetAsync(baseUrl))
print(out)
print("Type:".. type(out))
print("------------------------------------")
print(unpack(out))
print("Type:".. type(unpack(out)))
print("------------------------------------")
print(unpack(out).Name)
end
And result is this:
table: 0x839ff3c6fbee7aff
Type:table
------------------------------------
table: 0x8ca34a4b72e48917 table: 0x42e0cab1c0b96fcf table: 0xb8fbf217551c59ef
table: 0x1c6d22d1e1e1fc3f table: 0xcef8f28b3379973f table: 0xe7968dfebbf579cf table:
0x4f7f806e488276e7 table: 0xb1071507939ed2ff table: 0xa012c94d50d44fcf table:
0x6e390ad9a64b383f table: 0x371481c5614b5cef table: 0xde2cb0e44c8003c7 table:
0x3be90546820a4e4f table: 0xe767d72b7143d54f table: 0x5931b9ee7b8189ff table:
0x6e5603fa5d27cb6f table: 0xd500b14c8a93ec37 table: 0xe4836cfd22a41927 table:
0x613f3b6a2c125a6f table: 0xf69107a288422d8f table: 0x6b41ea41d6480e97 table:
0x68a817ca8d00e9a7 table: 0xd4fae15d7c96aeef table: 0x4062773e9e6c3ad7 table:
0xbf9460a52ab91abf table: 0xc43e1344212dd9c7 table: 0xbfc77bce9f99ff4f table:
0xa47314506561ba57 table: 0x7d5729522ce1d1b7 table: 0xd08b7bb0d219a0ef table:
0x2cebbec84cb52bd7 table: 0xd7ee8ffc0d2d5bff table: 0x642d065623dd8d87 table:
0x3e1b29861e422d57 table: 0x3ac8f375fde6bd6f table: 0x5f8a21d612db7a37 table:
0xc6c36fa517534e17 table: 0x9a169dc5e25c8d1f table: 0x4aafa9c8933b7c47 table:
0x57486c76ba356ccf table: 0xf5d4565747cfb7ff table: 0x5b0246308105b74f
Type:table
------------------------------------
Coder Wings
Now that you have a table of tables, you will have to iterate through that table using
for index, value in pairs(out) do
print(index.Name) -- whatever else you want from the table
end
1 Like
Yep, that worked but I changed like this:
for index,value in pairs(out) do
print(value.Name)
end
But thanks!
1 Like
Oops, that was an error on my part. Glad you spotted it though