lune-packaging/docs/typedefs/Roblox.luau

134 lines
3.1 KiB
Lua
Raw Normal View History

-- TODO: Autogenerate this somehow ...
2023-03-24 10:10:11 +00:00
export type Instance = {}
--[=[
2023-03-24 17:48:42 +00:00
@class Roblox
2023-03-24 10:10:11 +00:00
Built-in library for manipulating Roblox place & model files
### Example usage
```lua
local roblox = require("@lune/roblox")
-- Reading & writing a place file
local game = roblox.readPlaceFile("myPlaceFile.rbxl")
local workspace = game:GetService("Workspace")
for _, child in workspace:GetChildren() do
print("Found child " .. child.Name .. " of class " .. child.ClassName)
end
roblox.writePlaceFile("myPlaceFile.rbxl", game)
```
]=]
return {
2023-03-24 10:10:11 +00:00
--[=[
2023-03-24 17:48:42 +00:00
@within Roblox
@must_use
2023-03-24 10:10:11 +00:00
Reads a place file into a DataModel instance.
### Example usage
```lua
local roblox = require("@lune/roblox")
local game = roblox.readPlaceFile("filePath.rbxl")
```
2023-03-24 17:48:42 +00:00
@param filePath The file path to read from
2023-03-24 10:10:11 +00:00
]=]
readPlaceFile = function(filePath: string): Instance
return nil :: any
end,
2023-03-24 10:10:11 +00:00
--[=[
2023-03-24 17:48:42 +00:00
@within Roblox
@must_use
2023-03-24 10:10:11 +00:00
Reads a model file into a table of instances.
### Example usage
```lua
local roblox = require("@lune/roblox")
local instances = roblox.readModelFile("filePath.rbxm")
```
2023-03-24 17:48:42 +00:00
@param filePath The file path to read from
2023-03-24 10:10:11 +00:00
]=]
readModelFile = function(filePath: string): { Instance }
return nil :: any
end,
2023-03-24 10:10:11 +00:00
--[=[
2023-03-24 17:48:42 +00:00
@within Roblox
2023-03-24 10:10:11 +00:00
Writes a DataModel instance to a place file.
### Example usage
```lua
local roblox = require("@lune/roblox")
roblox.writePlaceFile("filePath.rbxl", game)
```
2023-03-24 17:48:42 +00:00
@param filePath The file path to write to
@param dataModel The DataModel to write to the file
2023-03-24 10:10:11 +00:00
]=]
writePlaceFile = function(filePath: string, dataModel: Instance) end,
2023-03-24 10:10:11 +00:00
--[=[
2023-03-24 17:48:42 +00:00
@within Roblox
2023-03-24 10:10:11 +00:00
Writes one or more instances to a model file.
### Example usage
```lua
local roblox = require("@lune/roblox")
roblox.writeModelFile("filePath.rbxm", { instance1, instance2, ... })
```
2023-03-24 17:48:42 +00:00
@param filePath The file path to write to
@param instances The array of instances to write to the file
2023-03-24 10:10:11 +00:00
]=]
writeModelFile = function(filePath: string, instances: { Instance }) end,
2023-03-24 10:10:11 +00:00
--[=[
2023-03-24 17:48:42 +00:00
@within Roblox
@must_use
2023-03-24 10:10:11 +00:00
Gets the current auth cookie, for usage with Roblox web APIs.
2023-03-24 17:48:42 +00:00
Note that this auth cookie is formatted for use as a "Cookie" header,
and that it contains restrictions so that it may only be used for
official Roblox endpoints. To get the raw cookie value without any
additional formatting, you can pass `true` as the first and only parameter.
2023-03-24 10:10:11 +00:00
### Example usage
```lua
local roblox = require("@lune/roblox")
local net = require("@lune/net")
local cookie = roblox.getAuthCookie()
assert(cookie ~= nil, "Failed to get roblox auth cookie")
local myPrivatePlaceId = 1234567890
local response = net.request({
url = "https://assetdelivery.roblox.com/v2/assetId/" .. tostring(myPrivatePlaceId),
headers = {
Cookie = cookie,
},
})
local responseTable = net.jsonDecode(response.body)
local responseLocation = responseTable.locations[1].location
print("Download link to place: " .. responseLocation)
```
2023-03-24 17:48:42 +00:00
@param raw If the cookie should be returned as a pure value or not. Defaults to false
2023-03-24 10:10:11 +00:00
]=]
getAuthCookie = function(raw: boolean?): string?
return nil :: any
end,
2023-03-24 10:10:11 +00:00
}