-- RbxApi Stuff


local apiUrl = "http://anaminus.github.io/rbx/json/api/latest.json"
local maxChunkSize = 100 * 1000
local ApiJson
if script:FindFirstChild("RawApiJson") then
	ApiJson = script.RawApiJson
else
	ApiJson = ""
end


function getLocalApiJson()
	local rawApiJson = require(ApiJson)()
	return rawApiJson
end

function getCurrentApiJson()
	local jsonStr = nil
	if readfile and getelysianpath then
		if readfile(getelysianpath().."Xpl0rerApi.txt") then
			print("Api found in folder!")
			jsonStr = readfile(getelysianpath().."Xpl0rerApi.txt")
			return jsonStr
		end
	end
	local success, err = pcall(function()
		jsonStr = httpGet(apiUrl)
		print("Fetched json successfully")
	end)
	if success then
		print("Returning json")
		--print(jsonStr:sub(1,500))
		return jsonStr
	else
		print("Error fetching json: " .. tostring(err))
		print("Falling back to local copy")
		return getLocalApiJson()
	end
end

function splitStringIntoChunks(jsonStr)
	-- Splits up a string into a table with a given size
	local t = {}
	for i = 1, math.ceil(string.len(jsonStr)/maxChunkSize) do
		local str = jsonStr:sub((i-1)*maxChunkSize+1, i*maxChunkSize)
		table.insert(t, str)
	end
	return t
end

local jsonToParse = getCurrentApiJson()
local apiChunks = splitStringIntoChunks(jsonToParse)

function getRbxApi()