Update detector.luau
This commit is contained in:
+17
-8
@@ -2,9 +2,19 @@ local process = require("@lune/process")
|
|||||||
local fs = require("@lune/fs")
|
local fs = require("@lune/fs")
|
||||||
local roblox = require("@lune/roblox")
|
local roblox = require("@lune/roblox")
|
||||||
local stdio = require("@lune/stdio")
|
local stdio = require("@lune/stdio")
|
||||||
|
local serde = require("@lune/serde")
|
||||||
|
|
||||||
local args = process.args
|
local args = process.args
|
||||||
|
|
||||||
|
local outputFile = nil
|
||||||
|
local directoryMode = false
|
||||||
|
local directoryPath = nil
|
||||||
|
-- i mainly added this arg because the modelscrape files dont have extensions and i dont feel like changing all of them ~ivy
|
||||||
|
local forceBinaryRead = false
|
||||||
|
local printInstanceNames = false
|
||||||
|
local zlibDecompressFiles = false
|
||||||
|
local filesToProcess = {}
|
||||||
|
|
||||||
if #args < 1 then
|
if #args < 1 then
|
||||||
stdio.write(stdio.color("red"))
|
stdio.write(stdio.color("red"))
|
||||||
stdio.write("Error: Please provide file path(s) or use --directory flag.\n")
|
stdio.write("Error: Please provide file path(s) or use --directory flag.\n")
|
||||||
@@ -25,6 +35,9 @@ end
|
|||||||
-- recursively searches entire model
|
-- recursively searches entire model
|
||||||
function scanForWorkspace(model: {Instance}): boolean
|
function scanForWorkspace(model: {Instance}): boolean
|
||||||
for _, child in pairs(model) do
|
for _, child in pairs(model) do
|
||||||
|
if printInstanceNames then
|
||||||
|
print(child:GetFullName())
|
||||||
|
end
|
||||||
if child:IsA("Workspace") or scanForWorkspace(child:GetChildren()) then
|
if child:IsA("Workspace") or scanForWorkspace(child:GetChildren()) then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -32,7 +45,7 @@ function scanForWorkspace(model: {Instance}): boolean
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- takes in fileContents as a string and deserializes them returning the results of scanForWorkspace() on the deserialized model
|
-- takes in fileContents as a string and deserializes them returning the results of scanForWorkspace() on the deserialized model. if it can't be deserialized, it will return the results of a naive search through the xml
|
||||||
function fileContainsWorkspace(fileContents: string): boolean
|
function fileContainsWorkspace(fileContents: string): boolean
|
||||||
local success, instances = pcall(function() return roblox.deserializeModel(fileContents) end)
|
local success, instances = pcall(function() return roblox.deserializeModel(fileContents) end)
|
||||||
if not success then -- roblox doesn't like seeing <binary> files, so this is a work-around
|
if not success then -- roblox doesn't like seeing <binary> files, so this is a work-around
|
||||||
@@ -55,13 +68,6 @@ function isValidModelFile(fileName: string): boolean
|
|||||||
return ext == "rbxm" or ext == "rbxmx"
|
return ext == "rbxm" or ext == "rbxmx"
|
||||||
end
|
end
|
||||||
|
|
||||||
-- parse arguments for flags
|
|
||||||
local outputFile = nil
|
|
||||||
local directoryMode = false
|
|
||||||
local directoryPath = nil
|
|
||||||
-- i mainly added this arg because the modelscrape files dont have extensions and i dont feel like changing all of them ~ivy
|
|
||||||
local forceBinaryRead = false
|
|
||||||
local filesToProcess = {}
|
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while i <= #args do
|
while i <= #args do
|
||||||
@@ -89,6 +95,9 @@ while i <= #args do
|
|||||||
elseif arg == "--force-binary-read" then
|
elseif arg == "--force-binary-read" then
|
||||||
forceBinaryRead = true
|
forceBinaryRead = true
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
elseif arg == "--print-instance-names" then
|
||||||
|
printInstanceNames = true
|
||||||
|
i = i+1
|
||||||
else
|
else
|
||||||
-- regular file argument
|
-- regular file argument
|
||||||
if not directoryMode then
|
if not directoryMode then
|
||||||
|
|||||||
Reference in New Issue
Block a user