Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- @CloneTrooper1019, 2014
- -- A few useful functions that load as part of the function environment in a plugin (for ROBLOX).
- -- Put this script into Notepad, save it as a .lua file, create a folder inside of roblox's plugin folder and put this file in here.
- util = LoadLibrary("RbxUtility")
- _env = getfenv()
- _env.import = function (asset)
- if not asset or type(asset) ~= "number" then return end
- asset = math.floor(asset)
- local obj = game:GetService("InsertService"):LoadAsset(asset):GetChildren()
- for _,v in pairs(obj) do
- v.Parent = workspace
- if v:findFirstChild("ThumbnailCamera") then
- workspace.CurrentCamera.CoordinateFrame = v.ThumbnailCamera.CoordinateFrame
- end
- end
- game.Selection:Set(obj)
- end
- _env.product = function (asset,prop)
- if not asset or type(asset) ~= "number" then return end
- asset = math.floor(asset)
- local info = game:GetService("MarketplaceService"):GetProductInfo(asset)
- if prop and info[prop] then
- print(info[prop])
- else
- print(util.EncodeJSON(info))
- end
- end
- _env.selected = function ()
- return game.Selection:Get()[1]
- end
- _env.allSelected = function ()
- return game.Selection:Get()
- end
- _env.encode = function (t)
- if not table_ or type(t) ~= "table" then return end
- print(util.EncodeJSON(t))
- return util.EncodeJSON(t)
- end
- _env.decode = function (json)
- if not json or type(json) ~= "string" then return end
- return util.DecodeJSON(json)
- end
- _env.help = function ()
- local help = {
- ["import(int assetId)"] = "- Inserts a model into the workspace using the InsertService";
- ["product(int assetId, string property)"] = "- Prints the ProductInfo of an asset in JSON";
- ["selected()"] = "- Returns the first selected object in studio";
- ["allSelected()"] = "- Returns a table of all selected objects in studio";
- ["encode(table t)"] = "- Prints a JSON string of the table argument 't'";
- ["decode(string json)"] = "- Returns a table from a JSON string, or nil";
- }
- print(string.rep("-",160))
- print()
- print("ENVIRONMENT FUNCTIONS")
- print()
- for func,desc in pairs(help) do
- print(func)
- print(" "..desc)
- print()
- end
- print()
- print(string.rep("-",160))
- end
- print("Command Env Loaded. Type 'help()' to see all the functions.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement