lune
lune copied to clipboard
Example scripts
Save instances in a place as individual model files example shows us this:
local fs = require("@lune/fs")
local roblox = require("@lune/roblox")
-- Here we load a file just like in the first example
local file = fs.readFile("myPlaceFile.rbxl")
local game = roblox.deserializePlace(file)
local workspace = game:GetService("Workspace")
-- Make sure a directory exists to save our models in
fs.writeDir("models")
-- Then we save all of our instances in Workspace as model files, in our new directory
-- Note that a model file can actually contain several instances at once, so we pass a table here
for _, child in workspace:GetChildren() do
file = roblox.serializeModel({ child })
fs.writeFile("models/" .. child.Name, file)
end
I believe it should be fs.writeFile("generated/" .. child.Name .. ".rbxm", file) and contain the .rbxm extension for this files to be usable.
@filiptibell idk if it's a good idea, but I haven't found any documentation on how to export script files. Also it's being really hard with Luau Language Server since it doesn't have all the properties the script should have, especially the .Source one, (Roblox LSP on the other hand does).
Maybe adding similar example will make life easier for someone
local fs = require("@lune/fs")
local roblox = require("@lune/roblox")
local file = fs.readFile("Test of rounding item around player.rbxl")
local game = roblox.deserializePlace(file)
local serverScriptService = game:GetService("ServerScriptService")
fs.writeDir("scripts")
for _, child in serverScriptService:GetChildren() do
if child:IsA("BaseScript") then
local scriptSource = child.Source
fs.writeFile("generated/" .. child.Name .. ".luau", scriptSource)
end
end