forked from StrafesNET/map-tool
126 lines
2.9 KiB
Lua
126 lines
2.9 KiB
Lua
--local Model=game:GetService'InsertService':LoadAsset(1079831188):GetChildren()[1] Model:SetModelCFrame(CFrame.new(0,Model:GetModelSize().y/2,0))
|
|
--[[ Load ID list
|
|
local ids={5692157375}
|
|
local ServerStorage=game:GetService'ServerStorage'
|
|
local function load(id)
|
|
local Model=game:GetObjects("rbxassetid://"..id)[1]
|
|
Model.Parent=workspace
|
|
Model:MoveTo(Vector3.new(0,Model:GetExtentsSize().y/2,0))
|
|
wait()
|
|
Model.Parent=ServerStorage
|
|
end
|
|
for i=1,#ids do
|
|
local succ,err=ypcall(load,ids[i])
|
|
if not succ then
|
|
print(ids[i],"error",err)
|
|
end
|
|
end
|
|
--]]
|
|
--[[ Format map names
|
|
local c=game:GetService'ServerStorage':GetChildren()
|
|
for i=1,#c do
|
|
local le_name=c[i].Name:gsub("%s+","_"):lower()
|
|
c[i].Name=le_name
|
|
local DisplayName=c[i]:FindFirstChild("DisplayName",true)
|
|
if DisplayName and DisplayName.ClassName=="StringValue" then
|
|
local dn=DisplayName.Value
|
|
local ndn={}
|
|
for w in dn:gmatch'%S+' do
|
|
ndn[#ndn+1]=w:sub(1,1):upper()..w:sub(2)
|
|
end
|
|
if table.concat(ndn," ")~=dn then
|
|
print("Fix name:",le_name)
|
|
end
|
|
end
|
|
end
|
|
--]]
|
|
--[[ Duplicate script labeler
|
|
local IsA=game.IsA
|
|
|
|
local ID=0
|
|
local SourceHash={}
|
|
local SourceHashCount={}
|
|
local NameHash={}
|
|
local IDHash={}
|
|
|
|
local c=game:GetService'ServerStorage':GetDescendants()
|
|
for i=1,#c do
|
|
local s=c[i]
|
|
if IsA(s,"LuaSourceContainer") then
|
|
local src=s.Source
|
|
NameHash[s]=s.Name
|
|
local id=SourceHash[src]
|
|
if id then
|
|
s.Name="copy "..id
|
|
SourceHashCount[id]=SourceHashCount[id]+1
|
|
else
|
|
ID=ID+1
|
|
IDHash[ID]=s
|
|
SourceHash[src]=ID
|
|
SourceHashCount[ID]=1
|
|
if src:find'getfenv' or src:find'require' then
|
|
s.Name="flagged "..ID
|
|
else
|
|
s.Name="unique "..ID
|
|
end
|
|
end
|
|
end
|
|
end
|
|
for i=1,ID do
|
|
local s=IDHash[i]
|
|
local hc=SourceHashCount[i]
|
|
s.Name=s.Name..(hc==1 and " (1 copy)" or " ("..hc.." copies)")
|
|
end
|
|
_G.NameHash=NameHash
|
|
--]]
|
|
--[[ Undo labeler
|
|
local NameHash=_G.NameHash
|
|
for s,n in next,NameHash do
|
|
s.Name=n
|
|
end
|
|
--]]
|
|
local IsA=workspace.IsA
|
|
local GetChildren=workspace.GetChildren
|
|
local function rsearch(search,cond1,cond2)
|
|
local found={}
|
|
for _,thing in next,GetChildren(search) do
|
|
if not cond1 or cond1(thing) then
|
|
found[#found+1]=thing
|
|
end
|
|
if not cond2 or cond2(thing) then
|
|
local nfound=#found
|
|
local r=rsearch(thing,cond1,cond2)
|
|
for i=1,#r do
|
|
found[nfound+i]=r[i]
|
|
end
|
|
end
|
|
end
|
|
return found
|
|
end
|
|
local function cond1(thing)
|
|
return IsA(thing,"LuaSourceContainer")
|
|
end
|
|
local Maps=GetChildren(game:GetService'ServerStorage')
|
|
for i=1,#Maps do
|
|
local Map=Maps[i]
|
|
if Map.ClassName=="Model" then
|
|
local Scripts=rsearch(Map,cond1)
|
|
if #Scripts>0 then
|
|
local ScriptHolder=Instance.new("Model",workspace)
|
|
ScriptHolder.Name=Map.Name.."("..#Scripts..")"
|
|
for i=1,#Scripts do
|
|
local sc=Scripts[i]
|
|
local scd
|
|
if sc.ClassName~="ModuleScript" then
|
|
sc.Disabled=true
|
|
end
|
|
local s=sc:Clone()
|
|
s.Name=sc:GetFullName()
|
|
s.Parent=ScriptHolder
|
|
if sc.ClassName~="ModuleScript" then
|
|
sc.Disabled=scd
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end |