I was looking through some HTML code when I came across this snippet
I also want to get a dictionary file into a Roblox game (using this dictionary api was too slow) but I find it impossible to copy paste a 6.5 megabyte dictionary file into a script, it is just too slow.
Is there any way to require a txt file in the same way as this code is doing?
My only lead would be the File keyword, but it does not seem to do anything.
local HTTPS = game:GetService("HttpService")
local Url = "https://api.dictionaryapi.dev/api/v2/entries/en/"
local module = {}
local function PFunk(Url)
return pcall(function()
return HTTPS:GetAsync(Url)
end)
end
module.IsAWord = function(Word)
local WordUrl = Url..tostring(Word)
local Success, WordData = PFunk(WordUrl)
if string.find(WordData,"HTTP 429") then --Too many requests
repeat
print("b")
wait(5)
local Success, WordData = PFunk(WordUrl)
until not string.find(WordData,"HTTP 429")
end
return Success
end
return module
this is not possible with roblox luau. your best bet is using json with HTTPService:JSONDecode if you are doing web/api requests, or somehow storing it into a module
Fetching a textfile is easy and can be done by simply sending a GET HTTP request to its url location. However in order to understand said textfile you may have to perform some process on it. For example it may have another encoding(for example utf16), it may be a json that needs to be json decoded(we have a function for that), or any other piece of information you need to write custom code to convert from a string to your desired data type.
Other file formats may be much harder to decode, for example decoding something like a JPEG requires huge scripts that deal with things such as discrete cosine transforms and huffman codes.