I am creating a plugin that turns RetroStudio into Roblox. However, there is one issue that kept bugging me, and it’s the issue how setting properties too fast will make it error.
I know, you could say:
However, adding a task.wait() slows down the exporting process and makes things export in a minute, however I want to achieve fast exporting times while also silencing errors.
Doing a simple task.wait() just does this:
Here’s my module code:
local httpService = game:GetService("HttpService")
local constructors = require(script:FindFirstChild("Constructors"))
assert(httpService.HttpEnabled, "HttpService must be enabled via the code: \"game.HttpService.HttpEnabled = true\" in the command line!")
local function construct(n, v, obj)
local func = constructors[typeof(obj[n])]
if func then
obj[n] = func(v)
else
obj[n] = v
end
end
local function create(lua)
local startTime = os.clock()
local created = false
local success, fail = pcall(function()
for _, props in pairs(lua) do
local obj = Instance.new(props.ClassName)
props.ClassName = nil
for n, v in pairs(props) do
construct(n, v, obj)
end
end
end)
if not success then
warn("Error found! Error:", fail)
end
local endTime = os.clock()
print("Created object(s) in:", endTime - startTime)
end
return function(jsons)
local startTime = os.clock()
local iters = 0
for _, json in pairs(jsons) do
local success, var = pcall(function()
return httpService:JSONDecode(json)
end)
iters += 1
warn("--- JSON #"..iters.." ---")
if not success then
warn("JSON is not a JSON, continuing...")
continue
end
create(var)
end
local endTime = os.clock()
warn("Exported in:", endTime - startTime)
end
Too long, didn’t read: I want to silence errors in this script while also keeping the exporting times at such low values.